@Test public void backupThrowsIfTimestampTableDoesNotExist() { kv.dropTable(AtlasDbConstants.TIMESTAMP_TABLE); assertThatThrownBy(backupRunner::backupExistingTimestamp).isInstanceOf(IllegalStateException.class); }
@Test public void restoreThrowsIfTimestampTableDoesNotExist() { kv.dropTable(AtlasDbConstants.TIMESTAMP_TABLE); assertThatThrownBy(backupRunner::restoreFromBackup).isInstanceOf(IllegalStateException.class); }
@Before public void setUp() { kv.dropTable(AtlasDbConstants.TIMESTAMP_TABLE); }
@Test public void canBackupTimestampTableIfItDoesNotExist() { kv.dropTable(AtlasDbConstants.TIMESTAMP_TABLE); assertThat(invalidator.backupAndInvalidate()).isEqualTo(CassandraTimestampUtils.INITIAL_VALUE); }
@Before public void setUp() { kv.dropTable(AtlasDbConstants.TIMESTAMP_TABLE); backupRunner.ensureTimestampTableExists(); }
@Test(timeout = 10 * 1000) public void testTableCreationCanOccurAfterError() { try { kvs.createTable(BAD_TABLE, AtlasDbConstants.GENERIC_TABLE_METADATA); } catch (Exception e) { // failure expected } kvs.createTable(GOOD_TABLE, AtlasDbConstants.GENERIC_TABLE_METADATA); kvs.dropTable(GOOD_TABLE); }
@Test public void restoringTimestampTableIfItDoesNotExistIsANoOp() { kv.dropTable(AtlasDbConstants.TIMESTAMP_TABLE); invalidator.revalidateFromBackup(); assertWeCanReadInitialValue(); }
@Test public void cannotDropTable() { assertThrowsAtlasDbDependencyExceptionAndDoesNotChangeCassandraSchema(() -> getTestKvs().dropTable(TABLE_TO_DROP)); }
@Test public void testCreatingMultipleTablesAtOnce() throws InterruptedException { int threadCount = 16; CyclicBarrier barrier = new CyclicBarrier(threadCount); ForkJoinPool threadPool = new ForkJoinPool(threadCount); threadPool.submit(() -> IntStream.range(0, threadCount).parallel().forEach(i -> { try { barrier.await(); slowTimeoutKvs.createTable(GOOD_TABLE, AtlasDbConstants.GENERIC_TABLE_METADATA); } catch (BrokenBarrierException | InterruptedException e) { // Do nothing } })); threadPool.shutdown(); Preconditions.checkState(threadPool.awaitTermination(90, TimeUnit.SECONDS), "Not all table creation threads completed within the time limit"); slowTimeoutKvs.dropTable(GOOD_TABLE); }
@Test public void testGetMetadataCaseInsensitive() { // Make two casewise-different references to the "same" table TableReference caseSensitiveTable = TableReference.createFromFullyQualifiedName("test.cased_table"); TableReference wackyCasedTable = TableReference.createFromFullyQualifiedName("test.CaSeD_TaBlE"); byte[] initialMetadata = new TableDefinition() { { rowName(); rowComponent("blob", ValueType.BLOB); columns(); column("bar", "b", ValueType.BLOB); conflictHandler(ConflictHandler.IGNORE_ALL); sweepStrategy(TableMetadataPersistence.SweepStrategy.NOTHING); } }.toTableMetadata().persistToBytes(); kvs.createTable(caseSensitiveTable, initialMetadata); // retrieve the metadata and see that it's the same as what we just put in byte[] existingMetadata = kvs.getMetadataForTable(caseSensitiveTable); assertThat(initialMetadata, is(existingMetadata)); // retrieve same metadata with a wacky cased version of the "same" name existingMetadata = kvs.getMetadataForTable(wackyCasedTable); assertThat(initialMetadata, is(existingMetadata)); kvs.dropTable(caseSensitiveTable); }