Thomas Vachuska
Committed by Gerrit Code Review

Enhancing STC

Change-Id: Ibb8a001f5c6550860c4ade97378af7e97876a0ab
...@@ -13,7 +13,8 @@ cat $aux ...@@ -13,7 +13,8 @@ cat $aux
13 cut -c7- $aux | cut -d\ -f1 | sort > $aux.1 13 cut -c7- $aux | cut -d\ -f1 | sort > $aux.1
14 14
15 # Normalize the expected apps 15 # Normalize the expected apps
16 -apps=${ONOS_APPS:-drivers,openflow} 16 +apps=${2:-$ONOS_APPS}
17 +apps=${apps:-drivers,openflow}
17 (for app in ${apps//,/ }; do echo org.onosproject.$app; done) | sort > $aux.2 18 (for app in ${apps//,/ }; do echo org.onosproject.$app; done) | sort > $aux.2
18 19
19 # Check for differences 20 # Check for differences
......
1 +#!/bin/bash
2 +# -----------------------------------------------------------------------------
3 +# Checks whether all and only the ONOS instances configured active.
4 +# -----------------------------------------------------------------------------
5 +
6 +aux=/tmp/stc-$$.log
7 +trap "rm -f $aux $aux.1 $aux.2 2>/dev/null" EXIT
8 +
9 +onos ${1:-$OCI} "onos:nodes" > $aux
10 +cat $aux
11 +
12 +# Normalize the nodes
13 +cut -d= -f3 $aux | cut -d: -f1 | sort > $aux.1
14 +
15 +# Normalize the expected apps
16 +ONOS_NODES=$(env | egrep "OC[0-9]*=" | cut -d= -f2 | sort)
17 +nodes=${2:-$ONOS_NODES}
18 +(for node in $nodes; do echo $node; done) | sort > $aux.2
19 +
20 +# Check for differences
21 +diff $aux.1 $aux.2
1 +#!/bin/bash
2 +# -----------------------------------------------------------------------------
3 +# Untars ONOS tar.gz on the remote machine and runs ONOS.
4 +# -----------------------------------------------------------------------------
5 +
6 +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 +. $ONOS_ROOT/tools/build/envDefaults
8 +
9 +node=${1:-$OCI}
10 +remote=$ONOS_USER@$node
11 +
12 +ssh $remote "
13 + [ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1
14 + cd /tmp && rm -fr /tmp/$ONOS_BITS
15 + tar zxf /tmp/$ONOS_BITS.tar.gz
16 +
17 + cd /tmp/$ONOS_BITS
18 + bin/onos-service server 1>/tmp/onos.out 2>/tmp/onos.err &
19 +
20 + # Setup a symlink to allow other tools to work
21 + sudo ln -s /tmp/$ONOS_BITS $ONOS_INSTALL_DIR
22 +"
...@@ -5,3 +5,5 @@ export OC1="10.128.11.1" ...@@ -5,3 +5,5 @@ export OC1="10.128.11.1"
5 export OC2="10.128.11.2" 5 export OC2="10.128.11.2"
6 export OC3="10.128.11.3" 6 export OC3="10.128.11.3"
7 export OCN="10.128.11.4" 7 export OCN="10.128.11.4"
8 +
9 +export OCT=$OC1
......
...@@ -18,10 +18,11 @@ ...@@ -18,10 +18,11 @@
18 <step name="Push-Bits" exec="onos-push-bits-through-proxy" if="${OCT}"/> 18 <step name="Push-Bits" exec="onos-push-bits-through-proxy" if="${OCT}"/>
19 19
20 <parallel var="${OC#}"> 20 <parallel var="${OC#}">
21 + <step name="Push-Bits-${#}" exec="onos-push-bits ${OC#}" unless="${OCT}"/>
21 <step name="Uninstall-${#}" exec="onos-uninstall ${OC#}"/> 22 <step name="Uninstall-${#}" exec="onos-uninstall ${OC#}"/>
22 23
23 <step name="Install-${#}" exec="onos-install ${OC#}" 24 <step name="Install-${#}" exec="onos-install ${OC#}"
24 - requires="Uninstall-${#},Push-Bits"/> 25 + requires="Uninstall-${#},Push-Bits-${#},Push-Bits"/>
25 26
26 <step name="Wait-for-Start-${#}" exec="onos-wait-for-start ${OC#}" 27 <step name="Wait-for-Start-${#}" exec="onos-wait-for-start ${OC#}"
27 requires="Install-${#}"/> 28 requires="Install-${#}"/>
......
1 +<!--
2 + ~ Copyright 2015 Open Networking Laboratory
3 + ~
4 + ~ Licensed under the Apache License, Version 2.0 (the "License");
5 + ~ you may not use this file except in compliance with the License.
6 + ~ You may obtain a copy of the License at
7 + ~
8 + ~ http://www.apache.org/licenses/LICENSE-2.0
9 + ~
10 + ~ Unless required by applicable law or agreed to in writing, software
11 + ~ distributed under the License is distributed on an "AS IS" BASIS,
12 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + ~ See the License for the specific language governing permissions and
14 + ~ limitations under the License.
15 + -->
16 +<scenario name="tar-setup" description="ONOS cluster setup via onos.tar.gz">
17 + <group name="Setup-Instances">
18 + <step name="Push-Bits" exec="onos-push-bits-through-proxy" if="${OCT}"/>
19 +
20 + <parallel var="${OC#}">
21 + <step name="Push-Bits-${#}" exec="onos-push-bits ${OC#}"
22 + unless="${OCT}"/>
23 + <step name="Uninstall-${#}" exec="onos-uninstall ${OC#}"/>
24 + <step name="Kill-${#}" env="~" exec="onos-kill ${OC#}"/>
25 +
26 + <step name="Untar-And-Run-${#}" exec="onos-untar-and-run ${OC#}"
27 + requires="Uninstall-${#},Push-Bits-${#},Push-Bits"/>
28 +
29 + <step name="Wait-for-Start-${#}" exec="onos-wait-for-start ${OC#}"
30 + requires="Untar-And-Run-${#}"/>
31 +
32 + <step name="Check-Logs-${#}" exec="onos-check-logs ${OC#}"
33 + requires="~Wait-for-Start-${#}"/>
34 + <step name="Check-Components-${#}"
35 + exec="onos-check-components ${OC#}"
36 + requires="~Wait-for-Start-${#}"/>
37 + <step name="Check-Apps-${#}" exec="onos-check-apps ${OC#} drivers"
38 + requires="~Wait-for-Start-${#}"/>
39 +
40 + <step name="Check-Nodes-${#}" exec="onos-check-nodes ${OC#} ${OC#}"
41 + requires="~Wait-for-Start-${#}"/>
42 + </parallel>
43 + </group>
44 +
45 + <group name="Setup-Cluster" requires="Setup-Instances" unless="${NO_CLUSTER}">
46 + <step name="Form-Cluster" exec="onos-form-cluster cell"/>
47 + <parallel var="${OC#}">
48 + <step name="Wait-for-Start-Again-${#}"
49 + exec="onos-wait-for-start ${OC#}"
50 + requires="Form-Cluster"/>
51 +
52 + <step name="Check-Logs-Again-${#}" exec="onos-check-logs ${OC#}"
53 + requires="~Wait-for-Start-Again-${#}"/>
54 + <step name="Check-Components-Again-${#}"
55 + exec="onos-check-components ${OC#}"
56 + requires="~Wait-for-Start-Again-${#}"/>
57 + <step name="Check-Apps-Again-${#}"
58 + exec="onos-check-apps ${OC#} drivers"
59 + requires="~Wait-for-Start-Again-${#}"/>
60 +
61 + <step name="Check-Nodes-Again-${#}" exec="onos-check-nodes ${OC#}"
62 + requires="~Wait-for-Start-Again-${#}"/>
63 + </parallel>
64 + </group>
65 +
66 +</scenario>
...@@ -106,7 +106,8 @@ public class Compiler { ...@@ -106,7 +106,8 @@ public class Compiler {
106 ImmutableSet.copyOf(dependencies)); 106 ImmutableSet.copyOf(dependencies));
107 107
108 // Extract the log directory if there was one specified 108 // Extract the log directory if there was one specified
109 - String path = scenario.definition().getString(LOG_DIR, DEFAULT_LOG_DIR); 109 + String defaultPath = DEFAULT_LOG_DIR + scenario.name();
110 + String path = scenario.definition().getString(LOG_DIR, defaultPath);
110 logDir = new File(expand(path)); 111 logDir = new File(expand(path));
111 } 112 }
112 113
......
...@@ -38,6 +38,7 @@ class ScenarioStore { ...@@ -38,6 +38,7 @@ class ScenarioStore {
38 38
39 private final ProcessFlow processFlow; 39 private final ProcessFlow processFlow;
40 private final File storeFile; 40 private final File storeFile;
41 + private final File logDir;
41 42
42 private final List<StepEvent> events = Lists.newArrayList(); 43 private final List<StepEvent> events = Lists.newArrayList();
43 private final Map<String, Status> statusMap = Maps.newConcurrentMap(); 44 private final Map<String, Status> statusMap = Maps.newConcurrentMap();
...@@ -51,6 +52,7 @@ class ScenarioStore { ...@@ -51,6 +52,7 @@ class ScenarioStore {
51 */ 52 */
52 ScenarioStore(ProcessFlow processFlow, File logDir, String name) { 53 ScenarioStore(ProcessFlow processFlow, File logDir, String name) {
53 this.processFlow = processFlow; 54 this.processFlow = processFlow;
55 + this.logDir = logDir;
54 this.storeFile = new File(logDir, name + ".stc"); 56 this.storeFile = new File(logDir, name + ".stc");
55 load(); 57 load();
56 } 58 }
...@@ -63,6 +65,7 @@ class ScenarioStore { ...@@ -63,6 +65,7 @@ class ScenarioStore {
63 statusMap.clear(); 65 statusMap.clear();
64 processFlow.getVertexes().forEach(step -> statusMap.put(step.name(), WAITING)); 66 processFlow.getVertexes().forEach(step -> statusMap.put(step.name(), WAITING));
65 try { 67 try {
68 + removeLogs();
66 PropertiesConfiguration cfg = new PropertiesConfiguration(storeFile); 69 PropertiesConfiguration cfg = new PropertiesConfiguration(storeFile);
67 cfg.clear(); 70 cfg.clear();
68 cfg.save(); 71 cfg.save();
...@@ -171,4 +174,18 @@ class ScenarioStore { ...@@ -171,4 +174,18 @@ class ScenarioStore {
171 } 174 }
172 } 175 }
173 176
177 + /**
178 + * Removes all scenario log files.
179 + */
180 + private void removeLogs() {
181 + File[] logFiles = logDir.listFiles();
182 + if (logFiles != null && logFiles.length > 0) {
183 + for (File file : logFiles) {
184 + if (!file.delete()) {
185 + print("Unable to delete log file %s", file);
186 + }
187 + }
188 + }
189 + }
190 +
174 } 191 }
......