ONOS-7045 vnet stc

Change-Id: I1e8731d4da3c8c981ae7a7d1d6da58981c9eb7cf
diff --git a/tools/test/scenarios/net-activate-fwdvn.xml b/tools/test/scenarios/net-activate-fwdvn.xml
new file mode 100644
index 0000000..61e8344
--- /dev/null
+++ b/tools/test/scenarios/net-activate-fwdvn.xml
@@ -0,0 +1,33 @@
+<!--
+  ~ Copyright 2017-present Open Networking Foundation
+  ~
+  ~ 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-activate-fwdvn" description="Install and activate virtual network forwarding app">
+    <group name="Net-Activate-Fwdvn" cwd="${HOME}/vn_fwd-master">
+        <import file="${ONOS_SCENARIOS}/net-details-fwdvn.xml"/>
+
+        <step name="Install-Fwdvn-App" requires="Net-Details-Fwdvn"
+              exec="onos-app ${OCI} install! target/${fwdVnAppOarFileName}"/>
+
+        <step name="Activate-Fwdvn-App" requires="^"
+              exec="onos ${OC1} app activate ${fwdVnAppFullName}"/>
+
+        <group name="Check-Fwdvn-App-Activated" requires="Activate-Fwdvn-App">
+            <parallel var="${OC#}">
+                <step name="Check-Fwdvn-App-Activated-${#}"
+                      exec="onos-check-apps ${#} ${fwdVnAppName} includes"/>
+            </parallel>
+        </group>
+    </group>
+</scenario>
diff --git a/tools/test/scenarios/net-deactivate-fwdvn.xml b/tools/test/scenarios/net-deactivate-fwdvn.xml
new file mode 100644
index 0000000..cf7e9ec
--- /dev/null
+++ b/tools/test/scenarios/net-deactivate-fwdvn.xml
@@ -0,0 +1,30 @@
+<!--
+  ~ Copyright 2017-present Open Networking Foundation
+  ~
+  ~ 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-deactivate-fwdvn" description="Deactivate virtual network forwarding app">
+    <group name="Net-Deactivate-Fwdvn">
+        <import file="${ONOS_SCENARIOS}/net-details-fwdvn.xml" namespace="deactivating"/>
+
+        <step name="Deactivate-Fwdvn-App" requires="deactivating.Net-Details-Fwdvn"
+              exec="onos ${OC1} app deactivate ${fwdVnAppFullName}"/>
+
+        <group name="Check-Fwdvn-App-Deactivated" requires="Deactivate-Fwdvn-App">
+            <parallel var="${OC#}">
+                <step name="Check-Fwdvn-App-Deactivated-${#}"
+                      exec="onos-check-apps ${#} ${fwdVnAppName} excludes"/>
+            </parallel>
+        </group>
+    </group>
+</scenario>
diff --git a/tools/test/scenarios/net-details-fwdvn.xml b/tools/test/scenarios/net-details-fwdvn.xml
new file mode 100644
index 0000000..d66eeb4
--- /dev/null
+++ b/tools/test/scenarios/net-details-fwdvn.xml
@@ -0,0 +1,34 @@
+<!--
+  ~  Copyright 2017-present Open Networking Foundation
+  ~
+  ~  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.
+  -->
+
+<!-- Currently the virtual network forwarding app is not in the ONOS codebase.
+  ~  When it is moved to the ONOS codebase, settings such as fwdVnAppFullName
+  ~  will be changed.
+  -->
+<scenario name="net-details-fwdvn" description="Virtual network forwarding app details">
+    <group name="Net-Details-Fwdvn" unless="${fwdVnAppFullName}">
+
+        <step name="Set-FwdVnAppFullName" unless="${fwdVnAppFullName}"
+              exec="echo @stc fwdVnAppFullName=org.postech.fwdvn"/>
+
+        <step name="Set-FwdVnAppName" unless="${fwdVnAppName}"
+              exec="echo @stc fwdVnAppName=fwdvn"/>
+
+        <step name="Set-FwdVnAppOarFileName" unless="${fwdVnAppOarFileName}"
+              exec="echo @stc fwdVnAppOarFileName=fwdvn-1.0-SNAPSHOT.oar"/>
+
+    </group>
+</scenario>
diff --git a/tools/test/scenarios/net-setup-vnet1.xml b/tools/test/scenarios/net-setup-vnet1.xml
new file mode 100644
index 0000000..f36eb1e
--- /dev/null
+++ b/tools/test/scenarios/net-setup-vnet1.xml
@@ -0,0 +1,76 @@
+<!--
+  ~  Copyright 2017-present Open Networking Foundation
+  ~
+  ~  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-vnet1" description="Virtual Network (vnet1) setup steps">
+    <group name="Net-Setup-Vnet1">
+
+        <step name="Get-TenantId" unless="${tenantId}"
+              exec="echo @stc tenantId=TestTenant"/>
+
+        <step name="Set-PhysicalDevice1" unless="${physicalDevice1}"
+              exec="echo @stc physicalDevice1=of:0000000000000001"/>
+
+        <step name="Set-PhysicalDevice2" unless="${physicalDevice2}"
+              exec="echo @stc physicalDevice2=of:0000000000000002"/>
+
+        <step name="Set-VirtualDevice-Setup" unless="${virtualDevice}"
+              exec="echo @stc virtualDevice=of:1122334455660001"/>
+
+        <step name="Set-VirtualHost1-Id-Setup" unless="${virtualHost1Id}"
+              exec="echo @stc virtualHost1Id=3A:13:39:73:9F:83"/>
+
+        <step name="Set-VirtualHost2-Id-Setup" unless="${virtualHost2Id}"
+              exec="echo @stc virtualHost2Id=7A:64:F7:85:9B:31"/>
+
+        <step name="Create-Tenant" requires="~Get-TenantId"
+              exec="onos ${OCI} vnet-add-tenant ${tenantId}"/>
+
+        <step name="Query-Tenant" requires="^"
+              exec="onos-check-vnet ${OCI} checkTenant ${tenantId}"/>
+
+        <step name="Create-Vnet" requires="^"
+              exec="onos ${OCI} vnet-create ${tenantId}"/>
+
+        <step name="Query-Vnet" requires="^"
+              exec="onos-check-vnet ${OCI} getNetworkId ${tenantId}"/>
+
+        <step name="Create-VirtualDevice-1" requires="^"
+              exec="onos ${OCI} vnet-create-device ${networkId} ${virtualDevice}"/>
+
+        <step name="Show-VirtualDevice" requires="^"
+              exec="onos ${OCI} vnet-devices ${networkId}"/>
+
+        <step name="Create-VirtualPort-1" requires="^"
+              exec="onos ${OCI} vnet-create-port ${networkId} ${virtualDevice} 1 ${physicalDevice1} 1"/>
+
+        <step name="Create-VirtualPort-2" requires="^"
+              exec="onos ${OCI} vnet-create-port ${networkId} ${virtualDevice} 2 ${physicalDevice2} 1"/>
+
+        <step name="Show-VirtualPorts-1" requires="^"
+              exec="onos ${OCI} vnet-ports ${networkId} ${virtualDevice}"/>
+
+        <step name="Create-VirtualHost-1" requires="^"
+              exec="onos ${OCI} vnet-create-host ${networkId} ${virtualHost1Id} 65535 ${virtualDevice} 1"/>
+
+        <step name="Create-VirtualHost-2" requires="^"
+              exec="onos ${OCI} vnet-create-host ${networkId} ${virtualHost2Id} 65535 ${virtualDevice} 2"/>
+
+        <step name="Show-VirtualHosts-1" requires="^"
+              exec="onos ${OCI} vnet-hosts ${networkId}"/>
+
+        <step name="Show-PhysicalHosts-1" requires="^"
+              exec="onos ${OCI} hosts "/>
+    </group>
+</scenario>
diff --git a/tools/test/scenarios/net-teardown-vnet1.xml b/tools/test/scenarios/net-teardown-vnet1.xml
new file mode 100644
index 0000000..e461674
--- /dev/null
+++ b/tools/test/scenarios/net-teardown-vnet1.xml
@@ -0,0 +1,55 @@
+<!--
+  ~  Copyright 2017-present Open Networking Foundation
+  ~
+  ~  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-teardown-vnet1" description="Virtual Network (vnet1) teardown steps">
+    <group name="Net-Teardown-Vnet1">
+
+        <step name="Check-NetworkId-Variable-Exists" exec="test '${networkId}' != ''"/>
+
+        <step name="Set-VirtualDevice-Teardown" unless="${virtualDevice}"
+              exec="echo @stc virtualDevice=of:1122334455660001"/>
+
+        <step name="Set-VirtualHost1-Id-Teardown" unless="${virtualHost1Id}"
+              exec="echo @stc virtualHost1Id=3A:13:39:73:9F:83"/>
+
+        <step name="Set-VirtualHost2-Id-Teardown" unless="${virtualHost2Id}"
+              exec="echo @stc virtualHost2Id=7A:64:F7:85:9B:31"/>
+
+        <step name="Remove-VirtualHost-2" requires="^"
+              exec="onos ${OCI} vnet-remove-host ${networkId} ${virtualHost2Id}/None"/>
+
+        <step name="Remove-VirtualHost-1" requires="^"
+              exec="onos ${OCI} vnet-remove-host ${networkId} ${virtualHost1Id}/None"/>
+
+        <step name="Remove-VirtualPort-2" requires="^"
+              exec="onos ${OCI} vnet-remove-port ${networkId} ${virtualDevice} 2"/>
+
+        <step name="Remove-VirtualPort-1" requires="^"
+              exec="onos ${OCI} vnet-remove-port ${networkId} ${virtualDevice} 1"/>
+
+        <step name="Remove-VirtualDevice-1" requires="^"
+              exec="onos ${OCI} vnet-remove-device ${networkId} ${virtualDevice}"/>
+
+        <step name="Remove-Vnet" requires="^"
+              exec="onos ${OCI} vnet-remove ${networkId}"/>
+
+        <step name="Check-TenantId-Variable-Exists" requires="^"
+              exec="test '${tenantId}' != ''"/>
+
+        <step name="Remove-Tenant" requires="Check-TenantId-Variable-Exists"
+              exec="onos ${OCI} vnet-remove-tenant ${tenantId}"/>
+
+    </group>
+</scenario>
diff --git a/tools/test/scenarios/vnet1-test.xml b/tools/test/scenarios/vnet1-test.xml
new file mode 100644
index 0000000..99f2ec0
--- /dev/null
+++ b/tools/test/scenarios/vnet1-test.xml
@@ -0,0 +1,46 @@
+<!--
+  ~ Copyright 2017-present Open Networking Foundation
+  ~
+  ~ 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="vnet1-test" description="vnet 1 test">
+        <import file="${ONOS_SCENARIOS}/net-setup.xml"/>
+        <dependency name="Net-Setup"/>
+
+        <import file="${ONOS_SCENARIOS}/net-deactivate-fwd.xml"/>
+        <dependency name="Net-Deactivate-Fwd" requires="Net-Setup"/>
+
+        <step name="Check-ping-does-not-work-1" requires="Net-Deactivate-Fwd"
+              exec="onos-mininet sendAndExpect h1 ping -c3 h2 --expect \ 100% packet loss"/>
+
+        <import file="${ONOS_SCENARIOS}/net-setup-vnet1.xml"/>
+        <dependency name="Net-Setup-Vnet1" requires="Check-ping-does-not-work-1"/>
+
+        <import file="${ONOS_SCENARIOS}/net-activate-fwdvn.xml"/>
+        <dependency name="Net-Activate-Fwdvn" requires="Net-Setup-Vnet1"/>
+
+        <step name="Check-ping-does-work-1" requires="Net-Activate-Fwdvn"
+              exec="onos-mininet sendAndExpect h1 ping -c3 h2 --expect \ 0% packet loss"/>
+
+        <import file="${ONOS_SCENARIOS}/net-deactivate-fwdvn.xml"/>
+        <dependency name="Net-Deactivate-Fwdvn" requires="Check-ping-does-work-1"/>
+
+         <step name="Check-ping-does-not-work-2" requires="Net-Deactivate-Fwdvn"
+               exec="onos-mininet sendAndExpect h1 ping -c3 h2 --expect \ 100% packet loss"/>
+
+        <import file="${ONOS_SCENARIOS}/net-teardown-vnet1.xml"/>
+        <dependency name="Net-Teardown-Vnet1" requires="~Net-Deactivate-Fwdvn,~Check-ping-does-not-work-2"/>
+
+        <import file="${ONOS_SCENARIOS}/net-teardown.xml"/>
+        <dependency name="Net-Teardown" requires="~Net-Teardown-Vnet1"/>
+</scenario>