Improving net test tools and scenarios.

Change-Id: I2b53fa7b28e1135d2356ae58d4ee8ac35184d9b8
diff --git a/tools/test/scenarios/basic-net.xml b/tools/test/scenarios/basic-net.xml
deleted file mode 100644
index a574cba..0000000
--- a/tools/test/scenarios/basic-net.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<!--
-  ~ Copyright 2015 Open Networking Laboratory
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-<scenario name="basic-net" description="Basic network functionality test">
-    <group name="Basic-Net">
-        <step name="Push-Topos" exec="onos-push-topos ${OCN}"/>
-
-        <step name="Install-Apps"
-              exec="onos ${OC1} app activate org.onosproject.openflow org.onosproject.proxyarp org.onosproject.fwd"/>
-        <step name="Check-Apps" requires="Install-Apps"
-              exec="onos-check-apps ${OC1} drivers,openflow,proxyarp,fwd"/>
-
-        <step name="Wipe-Out-Data" requires="~Check-Apps"
-              exec="onos ${OC1} wipe-out please"/>
-
-        <step name="Check-Summary" requires="~Wipe-Out-Data"
-              exec="onos-check-summary ${OC1} [0-9]* 0 0 0"/>
-
-        <step name="Start-Mininet" requires="Install-Apps,Check-Summary,Push-Topos"
-              exec="onos-mininet start topos/att-onos ${ONOS_INSTANCES}"/>
-
-        <step name="Wait-For-Mininet" requires="Install-Apps,Check-Summary"
-              exec="onos-mininet wait 15"/>
-
-        <step name="Check-Summary-Again" requires="Wait-For-Mininet"
-              exec="onos-check-summary ${OC1} [0-9]* 25 112 0"/>
-
-        <step name="Config-Topo" requires="Check-Summary-Again"
-              exec="onos-topo-cfg ${OC1} ${ONOS_ROOT}/tools/test/topos/attmpls.json"/>
-
-        <step name="Check-Summary-Yet-Again" requires="~Config-Topo"
-              exec="onos-check-summary ${OC1} [0-9]* 25 112 25"/>
-
-        <step name="Ping-All" requires="Wait-For-Mininet,~Check-Summary-Again"
-              exec="onos-mininet send py net.pingAll(1)"/>
-
-        <step name="Verify-Ping-All" requires="~Ping-All"
-              exec="onos-mininet expect Results: .* dropped"/>
-
-        <step name="Stop-Mininet" requires="~Verify-Ping-All"
-              exec="onos-mininet stop"/>
-    </group>
-</scenario>
\ No newline at end of file
diff --git a/tools/test/scenarios/net-link-up-down.xml b/tools/test/scenarios/net-link-up-down.xml
new file mode 100644
index 0000000..f421227
--- /dev/null
+++ b/tools/test/scenarios/net-link-up-down.xml
@@ -0,0 +1,38 @@
+<!--
+  ~ Copyright 2015 Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<scenario name="net-link-up-down" description="Network link up-down test">
+    <!-- TODO: parametrize this via recipes -->
+    <group name="Net-Link-Up-Down">
+        <step name="Ping-1"
+              exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/>
+        <step name="Link-1-Down" requires="Ping-1"
+              exec="onos-mininet sendAndExpect link s4 s5 down --expect ."/>
+        <step name="Ping-2" requires="Link-1-Down"
+              exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/>
+        <step name="Link-2-Down" requires="Ping-2"
+              exec="onos-mininet sendAndExpect link s4 s7 down --expect ."/>
+        <step name="Ping-3" requires="Link-2-Down"
+              exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect 100% packet loss"/>
+        <step name="Link-1-Up" requires="Ping-3"
+              exec="onos-mininet sendAndExpect link s4 s7 up --expect ."/>
+        <step name="Ping-4" requires="Link-1-Up"
+              exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/>
+        <step name="Link-2-Up" requires="Ping-4"
+              exec="onos-mininet sendAndExpect link s4 s5 up --expect ."/>
+        <step name="Ping-5" requires="Link-2-Up"
+              exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/>
+    </group>
+</scenario>
\ No newline at end of file
diff --git a/tools/test/scenarios/net-pingall.xml b/tools/test/scenarios/net-pingall.xml
new file mode 100644
index 0000000..70ce510
--- /dev/null
+++ b/tools/test/scenarios/net-pingall.xml
@@ -0,0 +1,28 @@
+<!--
+  ~ Copyright 2015 Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<scenario name="net-pingall" description="Network pingall test">
+    <!-- TODO: parametrize this via recipes -->
+    <group name="Net-Pingall">
+        <step name="Ping-All-And-Verify"
+              exec="onos-mininet sendAndExpect py net.pingAll(1) --expect Results: .* dropped"/>
+
+        <step name="Check-Summary-For-Hosts" requires="~Ping-All-And-Verify"
+              exec="onos-check-summary ${OC1} [0-9]* 25 112 25"/>
+
+        <step name="Config-Topo" requires="Check-Summary-For-Hosts"
+              exec="onos-topo-cfg ${OC1} ${ONOS_ROOT}/tools/test/topos/attmpls.json"/>
+    </group>
+</scenario>
\ No newline at end of file
diff --git a/tools/test/scenarios/net-setup.xml b/tools/test/scenarios/net-setup.xml
new file mode 100644
index 0000000..95347f0
--- /dev/null
+++ b/tools/test/scenarios/net-setup.xml
@@ -0,0 +1,45 @@
+<!--
+  ~ Copyright 2015 Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<scenario name="net-setup" description="Network setup steps">
+    <!-- TODO: parametrize this via recipes -->
+    <group name="Net-Setup">
+        <step name="Push-Topos" exec="onos-push-topos ${OCN}"/>
+
+        <step name="Install-Apps"
+              exec="onos ${OC1} app activate org.onosproject.openflow org.onosproject.proxyarp org.onosproject.fwd"/>
+
+        <step name="Check-Apps" requires="Install-Apps"
+              exec="onos-check-apps ${OC1} drivers,openflow,proxyarp,fwd"/>
+
+        <step name="Wipe-Out-Data-Before" requires="~Check-Apps" exec="onos-wipe-out"/>
+
+        <step name="Initial-Summary-Check" requires="~Wipe-Out-Data-Before"
+              exec="onos-check-summary ${OC1} [0-9]* 0 0 0"/>
+
+        <step name="Start-Mininet"
+              requires="Install-Apps,Initial-Summary-Check,Push-Topos"
+              exec="onos-mininet start topos/topo att-onos.py ${ONOS_INSTANCES}"/>
+
+        <step name="Wait-For-Mininet" requires="Start-Mininet"
+              exec="onos-mininet wait 15"/>
+
+        <step name="Check-Summary" requires="Wait-For-Mininet"
+              exec="onos-check-summary ${OC1} [0-9]* 25 112 0"/>
+
+        <step name="Balance-Masters" requires="Check-Summary"
+              exec="onos ${OC1} balance-masters"/>
+    </group>
+</scenario>
\ No newline at end of file
diff --git a/tools/test/scenarios/net-smoke.xml b/tools/test/scenarios/net-smoke.xml
new file mode 100644
index 0000000..fec1652
--- /dev/null
+++ b/tools/test/scenarios/net-smoke.xml
@@ -0,0 +1,29 @@
+<!--
+  ~ Copyright 2015 Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<scenario name="net-smoke" description="Basic network functionality smoke test">
+    <group name="Net-Smoke">
+        <import file="${ONOS_SCENARIOS}/net-setup.xml"/>
+
+        <import file="${ONOS_SCENARIOS}/net-pingall.xml"/>
+        <dependency name="Net-Pingall" requires="Net-Setup"/>
+
+        <import file="${ONOS_SCENARIOS}/net-link-up-down.xml"/>
+        <dependency name="Net-Link-Up-Down" requires="~Net-Pingall"/>
+
+        <import file="${ONOS_SCENARIOS}/net-teardown.xml"/>
+        <dependency name="Net-Teardown" requires="~Net-Link-Up-Down"/>
+    </group>
+</scenario>
\ No newline at end of file
diff --git a/tools/test/scenarios/net-teardown.xml b/tools/test/scenarios/net-teardown.xml
new file mode 100644
index 0000000..fa52ce3
--- /dev/null
+++ b/tools/test/scenarios/net-teardown.xml
@@ -0,0 +1,21 @@
+<!--
+  ~ Copyright 2015 Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<scenario name="net-setup" description="Network teardown steps">
+    <group name="Net-Teardown">
+        <step name="Stop-Mininet" exec="onos-mininet stop"/>
+        <step name="Wipe-Out-Data-After" requires="~Stop-Mininet" exec="onos-wipe-out"/>
+    </group>
+</scenario>
\ No newline at end of file
diff --git a/tools/test/scenarios/smoke.xml b/tools/test/scenarios/smoke.xml
index 27818ee..1614f78 100644
--- a/tools/test/scenarios/smoke.xml
+++ b/tools/test/scenarios/smoke.xml
@@ -14,17 +14,17 @@
   ~ limitations under the License.
   -->
 <scenario name="smoke-test" description="ONOS smoke test">
-    <import file="${ONOS_ROOT}/tools/test/scenarios/prerequisites.xml"/>
+    <import file="${ONOS_SCENARIOS}/prerequisites.xml"/>
 
-    <import file="${ONOS_ROOT}/tools/test/scenarios/setup.xml"/>
+    <import file="${ONOS_SCENARIOS}/setup.xml"/>
     <dependency name="Setup" requires="Prerequisites"/>
 
-    <import file="${ONOS_ROOT}/tools/test/scenarios/basic-net.xml"/>
-    <dependency name="Basic-Net" requires="Setup"/>
+    <import file="${ONOS_SCENARIOS}/net-smoke.xml"/>
+    <dependency name="Net-Smoke" requires="Setup"/>
 
-    <import file="${ONOS_ROOT}/tools/test/scenarios/archetypes.xml"/>
-    <dependency name="Archetypes" requires="~Basic-Net,Setup"/>
+    <import file="${ONOS_SCENARIOS}/archetypes.xml"/>
+    <dependency name="Archetypes" requires="~Net-Smoke,Setup"/>
 
-    <import file="${ONOS_ROOT}/tools/test/scenarios/wrapup.xml"/>
-    <dependency name="Wrapup" requires="~Archetypes,~Setup,~Basic-Net"/>
+    <import file="${ONOS_SCENARIOS}/wrapup.xml"/>
+    <dependency name="Wrapup" requires="~Archetypes,~Setup,~Net-Smoke"/>
 </scenario>