Search in sources :

Example 6 with SingleBackendCliTestRunner

use of com.palantir.atlasdb.cli.runner.SingleBackendCliTestRunner 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"));
    }
}
Also used : KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) SingleBackendCliTestRunner(com.palantir.atlasdb.cli.runner.SingleBackendCliTestRunner) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) DaggerTestAtlasDbServices(com.palantir.atlasdb.services.test.DaggerTestAtlasDbServices) TestAtlasDbServices(com.palantir.atlasdb.services.test.TestAtlasDbServices) TimestampService(com.palantir.timestamp.TimestampService) Test(org.junit.Test)

Aggregations

SingleBackendCliTestRunner (com.palantir.atlasdb.cli.runner.SingleBackendCliTestRunner)6 DaggerTestAtlasDbServices (com.palantir.atlasdb.services.test.DaggerTestAtlasDbServices)6 TestAtlasDbServices (com.palantir.atlasdb.services.test.TestAtlasDbServices)6 TimestampService (com.palantir.timestamp.TimestampService)5 Test (org.junit.Test)5 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)4 SerializableTransactionManager (com.palantir.atlasdb.transaction.impl.SerializableTransactionManager)4 GlobalClock (com.palantir.atlasdb.cleaner.GlobalClock)1 Clock (com.palantir.common.time.Clock)1 LockClient (com.palantir.lock.LockClient)1 LockRefreshToken (com.palantir.lock.LockRefreshToken)1 LockRequest (com.palantir.lock.LockRequest)1 LockService (com.palantir.lock.LockService)1 Scanner (java.util.Scanner)1