}
}
});
}
final SploutConfiguration config = SploutConfiguration.getTestConfig();
final int iterationsToPerform = config.getInt(QNodeProperties.VERSIONS_PER_TABLESPACE) + 5;
for(int i = 0; i < iterationsToPerform; i++) {
iteration.incrementAndGet();
log.info("Deploy iteration: " + iteration.get());
deployIteration(iteration.get(), random, client, testTablespace);
new TestUtils.NotWaitingForeverCondition() {
@Override
public boolean endCondition() {
synchronized(iterationsSeen) {
return iterationsSeen.size() == (iteration.get() + 1);
}
}
}.waitAtMost(5000);
}
assertEquals(false, failed.get());
service.shutdownNow(); // will interrupt all threads
while(!service.isTerminated()) {
Thread.sleep(100);
}
CoordinationStructures coord = TestUtils.getCoordinationStructures(config);
assertNotNull(coord.getCopyVersionsBeingServed().get(TABLESPACE));
// Assert that there is only MAX_VERSIONS versions of the tablespace (due to old version cleanup)
new TestUtils.NotWaitingForeverCondition() {
@Override
public boolean endCondition() {
QNodeHandler handler = (QNodeHandler) qNodes.get(0).getHandler();
int seenVersions = 0;
for(Map.Entry<TablespaceVersion, Tablespace> tablespaceVersion : handler.getContext()
.getTablespaceVersionsMap().entrySet()) {
if(tablespaceVersion.getKey().getTablespace().equals(TABLESPACE)) {
seenVersions++;
}
}
return seenVersions <= config.getInt(QNodeProperties.VERSIONS_PER_TABLESPACE);
}
}.waitAtMost(5000);
} finally {
closeSploutEnsemble();
FileUtils.deleteDirectory(new File(TMP_FOLDER));