Thomas Vachuska

Improved STC to show commands being executed.

Enhanced the net-smoke test scenario.

Change-Id: Idc828a6a4f18a02db1723a58a6020c4f07b8f3f1
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 <!-- TODO: parametrize this via recipes --> 17 <!-- TODO: parametrize this via recipes -->
18 <group name="Net-Setup"> 18 <group name="Net-Setup">
19 <step name="Push-Topos" exec="onos-push-topos ${OCN}"/> 19 <step name="Push-Topos" exec="onos-push-topos ${OCN}"/>
20 + <step name="Stop-Mininet-If-Needed" env="~" exec="onos-mininet stop"/>
20 21
21 <step name="Install-Apps" 22 <step name="Install-Apps"
22 exec="onos ${OC1} app activate org.onosproject.openflow org.onosproject.proxyarp org.onosproject.fwd"/> 23 exec="onos ${OC1} app activate org.onosproject.openflow org.onosproject.proxyarp org.onosproject.fwd"/>
...@@ -30,11 +31,11 @@ ...@@ -30,11 +31,11 @@
30 exec="onos-check-summary ${OC1} [0-9]* 0 0 0"/> 31 exec="onos-check-summary ${OC1} [0-9]* 0 0 0"/>
31 32
32 <step name="Start-Mininet" 33 <step name="Start-Mininet"
33 - requires="Install-Apps,Initial-Summary-Check,Push-Topos" 34 + requires="Install-Apps,Initial-Summary-Check,Push-Topos,Stop-Mininet-If-Needed"
34 exec="onos-mininet start topos/topo att-onos.py ${ONOS_INSTANCES}"/> 35 exec="onos-mininet start topos/topo att-onos.py ${ONOS_INSTANCES}"/>
35 36
36 <step name="Wait-For-Mininet" requires="Start-Mininet" 37 <step name="Wait-For-Mininet" requires="Start-Mininet"
37 - exec="onos-mininet wait 15"/> 38 + exec="onos-mininet wait 20"/>
38 39
39 <step name="Check-Summary" requires="Wait-For-Mininet" 40 <step name="Check-Summary" requires="Wait-For-Mininet"
40 exec="onos-check-summary ${OC1} [0-9]* 25 140 0"/> 41 exec="onos-check-summary ${OC1} [0-9]* 25 140 0"/>
......
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
21 <dependency name="Reactive-Forwarding.Net-Pingall" requires="Net-Setup"/> 21 <dependency name="Reactive-Forwarding.Net-Pingall" requires="Net-Setup"/>
22 22
23 <import file="${ONOS_SCENARIOS}/net-link-down-up.xml" namespace="Reactive-Forwarding"/> 23 <import file="${ONOS_SCENARIOS}/net-link-down-up.xml" namespace="Reactive-Forwarding"/>
24 - <dependency name="Reactive-Forwarding.Net-Link-Down-Up" requires="~Reactive-Forwarding.Net-Pingall"/> 24 + <dependency name="Reactive-Forwarding.Net-Link-Down-Up" requires="Net-Setup,~Reactive-Forwarding.Net-Pingall"/>
25 25
26 <import file="${ONOS_SCENARIOS}/net-host-intent.xml"/> 26 <import file="${ONOS_SCENARIOS}/net-host-intent.xml"/>
27 - <dependency name="Host-Intent-Connectivity" requires="~Reactive-Forwarding.Net-Link-Down-Up"/> 27 + <dependency name="Host-Intent-Connectivity" requires="Net-Setup,~Reactive-Forwarding.Net-Link-Down-Up"/>
28 28
29 <import file="${ONOS_SCENARIOS}/net-teardown.xml"/> 29 <import file="${ONOS_SCENARIOS}/net-teardown.xml"/>
30 <dependency name="Net-Teardown" requires="~Host-Intent-Connectivity"/> 30 <dependency name="Net-Teardown" requires="~Host-Intent-Connectivity"/>
......
...@@ -425,7 +425,7 @@ public class Compiler { ...@@ -425,7 +425,7 @@ public class Compiler {
425 last = end + 1; 425 last = end + 1;
426 } 426 }
427 sb.append(pString.substring(last)); 427 sb.append(pString.substring(last));
428 - return sb.toString(); 428 + return sb.toString().replace('\n', ' ').replace('\r', ' ');
429 } 429 }
430 430
431 /** 431 /**
......
...@@ -166,7 +166,7 @@ public final class Main { ...@@ -166,7 +166,7 @@ public final class Main {
166 // Processes the scenario 'list' command. 166 // Processes the scenario 'list' command.
167 private void processList() { 167 private void processList() {
168 coordinator.getRecords() 168 coordinator.getRecords()
169 - .forEach(event -> logStatus(event.time(), event.name(), event.status())); 169 + .forEach(event -> logStatus(event.time(), event.name(), event.status(), event.command()));
170 } 170 }
171 171
172 // Processes the scenario 'run' command for range of steps. 172 // Processes the scenario 'run' command for range of steps.
...@@ -188,12 +188,12 @@ public final class Main { ...@@ -188,12 +188,12 @@ public final class Main {
188 private static class Listener implements StepProcessListener { 188 private static class Listener implements StepProcessListener {
189 @Override 189 @Override
190 public void onStart(Step step) { 190 public void onStart(Step step) {
191 - logStatus(currentTimeMillis(), step.name(), IN_PROGRESS); 191 + logStatus(currentTimeMillis(), step.name(), IN_PROGRESS, step.command());
192 } 192 }
193 193
194 @Override 194 @Override
195 public void onCompletion(Step step, Status status) { 195 public void onCompletion(Step step, Status status) {
196 - logStatus(currentTimeMillis(), step.name(), status); 196 + logStatus(currentTimeMillis(), step.name(), status, null);
197 } 197 }
198 198
199 @Override 199 @Override
...@@ -202,8 +202,12 @@ public final class Main { ...@@ -202,8 +202,12 @@ public final class Main {
202 } 202 }
203 203
204 // Logs the step status. 204 // Logs the step status.
205 - private static void logStatus(long time, String name, Status status) { 205 + private static void logStatus(long time, String name, Status status, String cmd) {
206 - print("%s %s%s %s%s", time(time), color(status), name, action(status), color(null)); 206 + if (cmd != null) {
207 + print("%s %s%s %s%s -- %s", time(time), color(status), name, action(status), color(null), cmd);
208 + } else {
209 + print("%s %s%s %s%s", time(time), color(status), name, action(status), color(null));
210 + }
207 } 211 }
208 212
209 // Produces a description of event using the specified step status. 213 // Produces a description of event using the specified step status.
......
...@@ -109,7 +109,7 @@ class ScenarioStore { ...@@ -109,7 +109,7 @@ class ScenarioStore {
109 * @param step test step or group 109 * @param step test step or group
110 */ 110 */
111 synchronized void markStarted(Step step) { 111 synchronized void markStarted(Step step) {
112 - add(new StepEvent(step.name(), IN_PROGRESS)); 112 + add(new StepEvent(step.name(), IN_PROGRESS, step.command()));
113 save(); 113 save();
114 } 114 }
115 115
...@@ -120,7 +120,7 @@ class ScenarioStore { ...@@ -120,7 +120,7 @@ class ScenarioStore {
120 * @param status new step status 120 * @param status new step status
121 */ 121 */
122 synchronized void markComplete(Step step, Status status) { 122 synchronized void markComplete(Step step, Status status) {
123 - add(new StepEvent(step.name(), status)); 123 + add(new StepEvent(step.name(), status, null));
124 save(); 124 save();
125 } 125 }
126 126
......
...@@ -18,27 +18,33 @@ package org.onlab.stc; ...@@ -18,27 +18,33 @@ package org.onlab.stc;
18 import org.onlab.stc.Coordinator.Status; 18 import org.onlab.stc.Coordinator.Status;
19 19
20 import static java.lang.Long.parseLong; 20 import static java.lang.Long.parseLong;
21 +import static org.onlab.stc.Coordinator.Status.valueOf;
21 22
22 /** 23 /**
23 * Represents an event of execution of a scenario step or group. 24 * Represents an event of execution of a scenario step or group.
24 */ 25 */
25 public class StepEvent { 26 public class StepEvent {
26 27
28 + private static final String SEP = "~";
29 +
27 private final String name; 30 private final String name;
28 private final long time; 31 private final long time;
29 private final Status status; 32 private final Status status;
33 + private final String command;
30 34
31 /** 35 /**
32 * Creates a new step record. 36 * Creates a new step record.
33 * 37 *
34 - * @param name test step or group name 38 + * @param name test step or group name
35 - * @param time time in millis since start of epoch 39 + * @param time time in millis since start of epoch
36 - * @param status step completion status 40 + * @param status step completion status
41 + * @param command step command
37 */ 42 */
38 - public StepEvent(String name, long time, Status status) { 43 + public StepEvent(String name, long time, Status status, String command) {
39 this.name = name; 44 this.name = name;
40 this.time = time; 45 this.time = time;
41 this.status = status; 46 this.status = status;
47 + this.command = command;
42 } 48 }
43 49
44 /** 50 /**
...@@ -46,9 +52,10 @@ public class StepEvent { ...@@ -46,9 +52,10 @@ public class StepEvent {
46 * 52 *
47 * @param name test step or group name 53 * @param name test step or group name
48 * @param status status 54 * @param status status
55 + * @param command step command
49 */ 56 */
50 - public StepEvent(String name, Status status) { 57 + public StepEvent(String name, Status status, String command) {
51 - this(name, System.currentTimeMillis(), status); 58 + this(name, System.currentTimeMillis(), status, command);
52 } 59 }
53 60
54 /** 61 /**
...@@ -78,10 +85,19 @@ public class StepEvent { ...@@ -78,10 +85,19 @@ public class StepEvent {
78 return status; 85 return status;
79 } 86 }
80 87
88 + /**
89 + * Returns the step command.
90 + *
91 + * @return step command
92 + */
93 + public String command() {
94 + return command;
95 + }
96 +
81 97
82 @Override 98 @Override
83 public String toString() { 99 public String toString() {
84 - return name + ":" + time + ":" + status; 100 + return name + SEP + time + SEP + status + SEP + command;
85 } 101 }
86 102
87 /** 103 /**
...@@ -91,7 +107,8 @@ public class StepEvent { ...@@ -91,7 +107,8 @@ public class StepEvent {
91 * @return step record 107 * @return step record
92 */ 108 */
93 public static StepEvent fromString(String string) { 109 public static StepEvent fromString(String string) {
94 - String[] fields = string.split(":"); 110 + String[] fields = string.split("~");
95 - return new StepEvent(fields[0], parseLong(fields[1]), Status.valueOf(fields[2])); 111 + return new StepEvent(fields[0], parseLong(fields[1]), valueOf(fields[2]),
112 + fields[3].equals("null") ? null : fields[3]);
96 } 113 }
97 } 114 }
......
...@@ -17,8 +17,8 @@ package org.onlab.stc; ...@@ -17,8 +17,8 @@ package org.onlab.stc;
17 17
18 import org.junit.BeforeClass; 18 import org.junit.BeforeClass;
19 import org.junit.Test; 19 import org.junit.Test;
20 +import org.onlab.util.Tools;
20 21
21 -import java.io.FileNotFoundException;
22 import java.io.IOException; 22 import java.io.IOException;
23 23
24 import static org.onlab.stc.CompilerTest.getStream; 24 import static org.onlab.stc.CompilerTest.getStream;
...@@ -36,23 +36,26 @@ public class CoordinatorTest { ...@@ -36,23 +36,26 @@ public class CoordinatorTest {
36 @BeforeClass 36 @BeforeClass
37 public static void setUpClass() throws IOException { 37 public static void setUpClass() throws IOException {
38 CompilerTest.setUpClass(); 38 CompilerTest.setUpClass();
39 + Tools.removeDirectory(StepProcessorTest.DIR);
40 +
39 StepProcessor.launcher = "true "; 41 StepProcessor.launcher = "true ";
40 } 42 }
41 43
42 @Test 44 @Test
43 - public void simple() throws FileNotFoundException, InterruptedException { 45 + public void simple() throws IOException, InterruptedException {
44 executeTest("simple-scenario.xml"); 46 executeTest("simple-scenario.xml");
45 } 47 }
46 48
47 @Test 49 @Test
48 - public void complex() throws FileNotFoundException, InterruptedException { 50 + public void complex() throws IOException, InterruptedException {
49 executeTest("scenario.xml"); 51 executeTest("scenario.xml");
50 } 52 }
51 53
52 - private void executeTest(String name) throws FileNotFoundException, InterruptedException { 54 + private void executeTest(String name) throws IOException, InterruptedException {
53 Scenario scenario = loadScenario(getStream(name)); 55 Scenario scenario = loadScenario(getStream(name));
54 Compiler compiler = new Compiler(scenario); 56 Compiler compiler = new Compiler(scenario);
55 compiler.compile(); 57 compiler.compile();
58 + Tools.removeDirectory(compiler.logDir());
56 coordinator = new Coordinator(scenario, compiler.processFlow(), compiler.logDir()); 59 coordinator = new Coordinator(scenario, compiler.processFlow(), compiler.logDir());
57 coordinator.addListener(listener); 60 coordinator.addListener(listener);
58 coordinator.reset(); 61 coordinator.reset();
......
...@@ -32,7 +32,7 @@ import static org.onlab.stc.Coordinator.Status.SUCCEEDED; ...@@ -32,7 +32,7 @@ import static org.onlab.stc.Coordinator.Status.SUCCEEDED;
32 */ 32 */
33 public class StepProcessorTest { 33 public class StepProcessorTest {
34 34
35 - private static final File DIR = new File("/tmp/stc/foo"); 35 + static final File DIR = new File("/tmp/stc/foo");
36 36
37 private final Listener delegate = new Listener(); 37 private final Listener delegate = new Listener();
38 38
......