Thomas Vachuska
Committed by Gerrit Code Review

Fixing a few STC glitches.

Change-Id: I38c0a81911e392be0d6e1d392511456b57acf16c
......@@ -19,4 +19,5 @@ scenario=${1:-smoke}
[ -t 1 ] && stcColor=true || unset stcColor
java -jar $JAR $scenario "$@"
[ -z "$stcDebug" ] && DEBUG_OPTS=""
java $DEBUG_OPTS -jar $JAR $scenario "$@"
......
......@@ -83,7 +83,7 @@ public class Coordinator {
this.logDir = logDir;
this.store = new ScenarioStore(processFlow, logDir, scenario.name());
this.delegate = new Delegate();
this.latch = new CountDownLatch(store.getSteps().size());
this.latch = new CountDownLatch(1);
}
/**
......@@ -349,7 +349,9 @@ public class Coordinator {
store.markComplete(step, status);
listeners.forEach(listener -> listener.onCompletion(step, status));
executeSucessors(step);
latch.countDown();
if (store.isComplete()) {
latch.countDown();
}
}
@Override
......
......@@ -157,27 +157,26 @@ public final class Main {
// Processes the scenario 'run' command.
private void processRun() {
try {
coordinator.reset();
coordinator.start();
int exitCode = coordinator.waitFor();
pause(100); // allow stdout to flush
System.exit(exitCode);
} catch (InterruptedException e) {
print("Unable to execute scenario %s", scenarioFile);
}
coordinator.reset();
runCoordinator();
}
// Processes the scenario 'run' command for range of steps.
private void processRunRange() {
coordinator.reset(list(runFromPatterns), list(runToPatterns));
runCoordinator();
}
// Processes the scenario 'list' command.
private void processList() {
coordinator.getRecords()
.forEach(event -> logStatus(event.time(), event.name(), event.status(), event.command()));
System.exit(0);
}
// Processes the scenario 'run' command for range of steps.
private void processRunRange() {
// Runs the coordinator and waits for it to finish.
private void runCoordinator() {
try {
coordinator.reset(list(runFromPatterns), list(runToPatterns));
coordinator.start();
int exitCode = coordinator.waitFor();
pause(100); // allow stdout to flush
......
......@@ -125,6 +125,16 @@ class ScenarioStore {
}
/**
* Returns true if all steps in the store have been marked as completed
* regardless of the completion status.
*
* @return true if all steps completed one way or another
*/
synchronized boolean isComplete() {
return !statusMap.values().stream().anyMatch(s -> s == WAITING || s == IN_PROGRESS);
}
/**
* Indicates whether there are any failures.
*
* @return true if there are failed steps
......