Thomas Vachuska
Committed by Gerrit Code Review

Fixing a few STC glitches.

Change-Id: I38c0a81911e392be0d6e1d392511456b57acf16c
...@@ -19,4 +19,5 @@ scenario=${1:-smoke} ...@@ -19,4 +19,5 @@ scenario=${1:-smoke}
19 19
20 [ -t 1 ] && stcColor=true || unset stcColor 20 [ -t 1 ] && stcColor=true || unset stcColor
21 21
22 -java -jar $JAR $scenario "$@" 22 +[ -z "$stcDebug" ] && DEBUG_OPTS=""
23 +java $DEBUG_OPTS -jar $JAR $scenario "$@"
......
...@@ -83,7 +83,7 @@ public class Coordinator { ...@@ -83,7 +83,7 @@ public class Coordinator {
83 this.logDir = logDir; 83 this.logDir = logDir;
84 this.store = new ScenarioStore(processFlow, logDir, scenario.name()); 84 this.store = new ScenarioStore(processFlow, logDir, scenario.name());
85 this.delegate = new Delegate(); 85 this.delegate = new Delegate();
86 - this.latch = new CountDownLatch(store.getSteps().size()); 86 + this.latch = new CountDownLatch(1);
87 } 87 }
88 88
89 /** 89 /**
...@@ -349,8 +349,10 @@ public class Coordinator { ...@@ -349,8 +349,10 @@ public class Coordinator {
349 store.markComplete(step, status); 349 store.markComplete(step, status);
350 listeners.forEach(listener -> listener.onCompletion(step, status)); 350 listeners.forEach(listener -> listener.onCompletion(step, status));
351 executeSucessors(step); 351 executeSucessors(step);
352 + if (store.isComplete()) {
352 latch.countDown(); 353 latch.countDown();
353 } 354 }
355 + }
354 356
355 @Override 357 @Override
356 public void onOutput(Step step, String line) { 358 public void onOutput(Step step, String line) {
......
...@@ -157,27 +157,26 @@ public final class Main { ...@@ -157,27 +157,26 @@ public final class Main {
157 157
158 // Processes the scenario 'run' command. 158 // Processes the scenario 'run' command.
159 private void processRun() { 159 private void processRun() {
160 - try {
161 coordinator.reset(); 160 coordinator.reset();
162 - coordinator.start(); 161 + runCoordinator();
163 - int exitCode = coordinator.waitFor();
164 - pause(100); // allow stdout to flush
165 - System.exit(exitCode);
166 - } catch (InterruptedException e) {
167 - print("Unable to execute scenario %s", scenarioFile);
168 } 162 }
163 +
164 + // Processes the scenario 'run' command for range of steps.
165 + private void processRunRange() {
166 + coordinator.reset(list(runFromPatterns), list(runToPatterns));
167 + runCoordinator();
169 } 168 }
170 169
171 // Processes the scenario 'list' command. 170 // Processes the scenario 'list' command.
172 private void processList() { 171 private void processList() {
173 coordinator.getRecords() 172 coordinator.getRecords()
174 .forEach(event -> logStatus(event.time(), event.name(), event.status(), event.command())); 173 .forEach(event -> logStatus(event.time(), event.name(), event.status(), event.command()));
174 + System.exit(0);
175 } 175 }
176 176
177 - // Processes the scenario 'run' command for range of steps. 177 + // Runs the coordinator and waits for it to finish.
178 - private void processRunRange() { 178 + private void runCoordinator() {
179 try { 179 try {
180 - coordinator.reset(list(runFromPatterns), list(runToPatterns));
181 coordinator.start(); 180 coordinator.start();
182 int exitCode = coordinator.waitFor(); 181 int exitCode = coordinator.waitFor();
183 pause(100); // allow stdout to flush 182 pause(100); // allow stdout to flush
......
...@@ -125,6 +125,16 @@ class ScenarioStore { ...@@ -125,6 +125,16 @@ class ScenarioStore {
125 } 125 }
126 126
127 /** 127 /**
128 + * Returns true if all steps in the store have been marked as completed
129 + * regardless of the completion status.
130 + *
131 + * @return true if all steps completed one way or another
132 + */
133 + synchronized boolean isComplete() {
134 + return !statusMap.values().stream().anyMatch(s -> s == WAITING || s == IN_PROGRESS);
135 + }
136 +
137 + /**
128 * Indicates whether there are any failures. 138 * Indicates whether there are any failures.
129 * 139 *
130 * @return true if there are failed steps 140 * @return true if there are failed steps
......