use of com.palantir.atlasdb.services.test.TestAtlasDbServices in project atlasdb by palantir.
the class TestSweepCommand method testSweepTable.
@Test
public void testSweepTable() throws Exception {
try (SingleBackendCliTestRunner runner = makeRunner(paramsWithDryRunSet(SWEEP_COMMAND, "-t", TABLE_ONE.getQualifiedName()))) {
TestAtlasDbServices services = runner.connect(moduleFactory);
SerializableTransactionManager txm = services.getTransactionManager();
TimestampService tss = services.getTimestampService();
KeyValueService kvs = services.getKeyValueService();
createTable(kvs, TABLE_ONE, TableMetadataPersistence.SweepStrategy.CONSERVATIVE);
createTable(kvs, TABLE_TWO, TableMetadataPersistence.SweepStrategy.CONSERVATIVE);
long ts1 = put(txm, TABLE_ONE, "foo", "bar");
long ts2 = put(txm, TABLE_TWO, "foo", "tar");
long ts3 = put(txm, TABLE_ONE, "foo", "baz");
long ts4 = put(txm, TABLE_TWO, "foo", "taz");
long ts5 = tss.getFreshTimestamp();
String stdout = sweep(runner, ts5);
Scanner scanner = new Scanner(stdout);
final long cellValuesExamined = Long.parseLong(scanner.findInLine("\\d+ cell values").split(" ")[0]);
final long deletedCells = Long.parseLong(scanner.findInLine("deleted \\d+ stale versions of those cells").split(" ")[1]);
Assert.assertEquals(2, cellValuesExamined);
Assert.assertEquals(1, deletedCells);
Assert.assertEquals("baz", get(kvs, TABLE_ONE, "foo", ts5));
Assert.assertEquals(deletedValue("bar"), get(kvs, TABLE_ONE, "foo", mid(ts1, ts3)));
Assert.assertEquals(ImmutableSet.of(deletedTimestamp(ts1), ts3), getAllTs(kvs, TABLE_ONE, "foo"));
Assert.assertEquals("taz", get(kvs, TABLE_TWO, "foo", ts5));
Assert.assertEquals("tar", get(kvs, TABLE_TWO, "foo", mid(ts3, ts4)));
Assert.assertEquals(ImmutableSet.of(ts2, ts4), getAllTs(kvs, TABLE_TWO, "foo"));
}
}
use of com.palantir.atlasdb.services.test.TestAtlasDbServices in project atlasdb by palantir.
the class TestSweepCommand method testSweepStartRow.
@Test
public void testSweepStartRow() throws Exception {
try (SingleBackendCliTestRunner runner = makeRunner(paramsWithDryRunSet(SWEEP_COMMAND, "-t", TABLE_ONE.getQualifiedName(), "-r", BaseEncoding.base16().encode("foo".getBytes(StandardCharsets.UTF_8))))) {
TestAtlasDbServices services = runner.connect(moduleFactory);
SerializableTransactionManager txm = services.getTransactionManager();
TimestampService tss = services.getTimestampService();
KeyValueService kvs = services.getKeyValueService();
createTable(kvs, TABLE_ONE, TableMetadataPersistence.SweepStrategy.CONSERVATIVE);
long ts1 = put(txm, TABLE_ONE, "foo", "bar");
long ts2 = put(txm, TABLE_ONE, "foo", "biz");
long ts3 = put(txm, TABLE_ONE, "boo", "biz");
long ts4 = put(txm, TABLE_ONE, "foo", "baz");
long ts5 = tss.getFreshTimestamp();
sweep(runner, ts5);
Assert.assertEquals("baz", get(kvs, TABLE_ONE, "foo", ts5));
Assert.assertEquals(deletedValue("bar"), get(kvs, TABLE_ONE, "foo", mid(ts1, ts3)));
Assert.assertEquals(deletedValue("biz"), get(kvs, TABLE_ONE, "foo", mid(ts2, ts4)));
Assert.assertEquals("biz", get(kvs, TABLE_ONE, "boo", mid(ts3, ts5)));
Assert.assertEquals(ImmutableSet.of(deletedTimestamp(ts1), deletedTimestamp(ts2), ts4), getAllTs(kvs, TABLE_ONE, "foo"));
Assert.assertEquals(ImmutableSet.of(ts3), getAllTs(kvs, TABLE_ONE, "boo"));
}
}
use of com.palantir.atlasdb.services.test.TestAtlasDbServices in project atlasdb by palantir.
the class TestTimestampCommand method oneTimeSetup.
@BeforeClass
public static void oneTimeSetup() throws Exception {
lock = StringLockDescriptor.of("lock");
moduleFactory = new AtlasDbServicesFactory() {
@Override
public TestAtlasDbServices connect(ServicesConfigModule servicesConfigModule) {
return DaggerTestAtlasDbServices.builder().servicesConfigModule(servicesConfigModule).build();
}
};
}
Aggregations