Thomas Vachuska
Committed by Gerrit Code Review

Fixed STC logic when skipping steps and groups of steps. Doh!

Change-Id: I6a1f690133bc0a5d1efbdf1333fe80a983e7dda8
...@@ -26,5 +26,5 @@ ...@@ -26,5 +26,5 @@
26 <dependency name="Archetypes" requires="Setup"/> 26 <dependency name="Archetypes" requires="Setup"/>
27 27
28 <import file="${ONOS_SCENARIOS}/wrapup.xml"/> 28 <import file="${ONOS_SCENARIOS}/wrapup.xml"/>
29 - <dependency name="Wrapup" requires="~Archetypes,~Setup,~Net-Fast"/> 29 + <dependency name="Wrapup" requires="Prerequisites,~Archetypes,~Setup,~Net-Fast"/>
30 </scenario> 30 </scenario>
......
...@@ -25,6 +25,7 @@ import java.util.Map; ...@@ -25,6 +25,7 @@ import java.util.Map;
25 import java.util.Set; 25 import java.util.Set;
26 import java.util.concurrent.CountDownLatch; 26 import java.util.concurrent.CountDownLatch;
27 import java.util.concurrent.ExecutorService; 27 import java.util.concurrent.ExecutorService;
28 +import java.util.concurrent.TimeUnit;
28 import java.util.regex.Matcher; 29 import java.util.regex.Matcher;
29 import java.util.regex.Pattern; 30 import java.util.regex.Pattern;
30 31
...@@ -41,7 +42,7 @@ import static org.onlab.stc.Coordinator.Status.*; ...@@ -41,7 +42,7 @@ import static org.onlab.stc.Coordinator.Status.*;
41 */ 42 */
42 public class Coordinator { 43 public class Coordinator {
43 44
44 - private static final int MAX_THREADS = 16; 45 + private static final int MAX_THREADS = 64;
45 46
46 private final ExecutorService executor = newFixedThreadPool(MAX_THREADS); 47 private final ExecutorService executor = newFixedThreadPool(MAX_THREADS);
47 48
...@@ -143,13 +144,15 @@ public class Coordinator { ...@@ -143,13 +144,15 @@ public class Coordinator {
143 } 144 }
144 145
145 /** 146 /**
146 - * Wants for completion of the entire process flow. 147 + * Waits for completion of the entire process flow.
147 * 148 *
148 * @return exit code to use 149 * @return exit code to use
149 * @throws InterruptedException if interrupted while waiting for completion 150 * @throws InterruptedException if interrupted while waiting for completion
150 */ 151 */
151 public int waitFor() throws InterruptedException { 152 public int waitFor() throws InterruptedException {
152 - latch.await(); 153 + while (!store.isComplete()) {
154 + latch.await(1, TimeUnit.SECONDS);
155 + }
153 return store.hasFailures() ? 1 : 0; 156 return store.hasFailures() ? 1 : 0;
154 } 157 }
155 158
...@@ -234,15 +237,26 @@ public class Coordinator { ...@@ -234,15 +237,26 @@ public class Coordinator {
234 substitute(step.command()))); 237 substitute(step.command())));
235 } 238 }
236 } else if (directive == SKIP) { 239 } else if (directive == SKIP) {
237 - if (step instanceof Group) { 240 + skipStep(step);
238 - Group group = (Group) step;
239 - group.children().forEach(child -> delegate.onCompletion(child, SKIPPED));
240 - }
241 - delegate.onCompletion(step, SKIPPED);
242 } 241 }
243 } 242 }
244 243
245 /** 244 /**
245 + * Recursively skips the specified step or group and any steps/groups within.
246 + *
247 + * @param step step or group
248 + */
249 + private void skipStep(Step step) {
250 + if (step instanceof Group) {
251 + Group group = (Group) step;
252 + store.markComplete(step, SKIPPED);
253 + group.children().forEach(this::skipStep);
254 + }
255 + delegate.onCompletion(step, SKIPPED);
256 +
257 + }
258 +
259 + /**
246 * Determines the state of the specified step. 260 * Determines the state of the specified step.
247 * 261 *
248 * @param step test step 262 * @param step test step
...@@ -258,8 +272,8 @@ public class Coordinator { ...@@ -258,8 +272,8 @@ public class Coordinator {
258 Status depStatus = store.getStatus(dependency.dst()); 272 Status depStatus = store.getStatus(dependency.dst());
259 if (depStatus == WAITING || depStatus == IN_PROGRESS) { 273 if (depStatus == WAITING || depStatus == IN_PROGRESS) {
260 return NOOP; 274 return NOOP;
261 - } else if ((depStatus == FAILED || depStatus == SKIPPED) && 275 + } else if (((depStatus == FAILED || depStatus == SKIPPED) && !dependency.isSoft()) ||
262 - !dependency.isSoft()) { 276 + (step.group() != null && store.getStatus(step.group()) == SKIPPED)) {
263 return SKIP; 277 return SKIP;
264 } 278 }
265 } 279 }
......