use of com.palantir.atlasdb.cli.command.CleanCassLocksStateCommand in project atlasdb by palantir.
the class CassandraKeyValueServiceIntegrationTest method testCleanCassLocksStateCli.
@Test
public void testCleanCassLocksStateCli() throws Exception {
CassandraKeyValueServiceImpl ckvs = (CassandraKeyValueServiceImpl) keyValueService;
SchemaMutationLockTables lockTables = new SchemaMutationLockTables(ckvs.getClientPool(), CassandraContainer.KVS_CONFIG);
SchemaMutationLockTestTools lockTestTools = new SchemaMutationLockTestTools(ckvs.getClientPool(), new UniqueSchemaMutationLockTable(lockTables, LockLeader.I_AM_THE_LOCK_LEADER));
grabLock(lockTestTools);
createExtraLocksTable(lockTables);
new CleanCassLocksStateCommand().runWithConfig(CassandraContainer.KVS_CONFIG);
// depending on which table we pick when running cleanup on multiple lock tables, we might have a table with
// no rows or a table with a single row containing the cleared lock value (both are valid clean states).
List<CqlRow> resultRows = lockTestTools.readLocksTable().getRows();
assertThat(resultRows, either(is(empty())).or(hasSize(1)));
if (resultRows.size() == 1) {
Column resultColumn = Iterables.getOnlyElement(Iterables.getOnlyElement(resultRows).getColumns());
long lockId = SchemaMutationLock.getLockIdFromColumn(resultColumn);
assertThat(lockId, is(SchemaMutationLock.GLOBAL_DDL_LOCK_CLEARED_ID));
}
}
Aggregations