diff options
Diffstat (limited to 'framework/src/onos/tools/test/scenarios')
13 files changed, 341 insertions, 20 deletions
diff --git a/framework/src/onos/tools/test/scenarios/bin/curl-with-retry b/framework/src/onos/tools/test/scenarios/bin/curl-with-retry new file mode 100755 index 00000000..c9546aea --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/curl-with-retry @@ -0,0 +1,23 @@ +#!/bin/bash + +aux=/tmp/stc-$$.log +trap "rm -f $aux 2>/dev/null" EXIT + +url=$1 + + +echo curl-with-retry: $* + +set -x +for i in {1..3}; do + curl -f -uonos:rocks ${url} >$aux + if [ $? = 0 ]; then + cat $aux + exit 0 + fi + sleep 1 +done + +cat $aux +exit 1 + diff --git a/framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py b/framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py new file mode 100755 index 00000000..928531fd --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/find-link-in-cluster.py @@ -0,0 +1,54 @@ +#! /usr/bin/env python + +import requests +import sys + +from requests.auth import HTTPBasicAuth + +if len(sys.argv) != 9: + print "usage: find-link-in-cluster onos-node name cluster-id expected-length src-device-id src-port dst-device-id dst-port" + sys.exit(1) + +node = sys.argv[1] +name = sys.argv[2] +cluster = sys.argv[3] +length = int(sys.argv[4]) +srcDeviceId = sys.argv[5] +srcPort = sys.argv[6] +dstDeviceId = sys.argv[7] +dstPort = sys.argv[8] + + +linksRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/' + + cluster + '/links', + auth=HTTPBasicAuth('onos', 'rocks')) + +if linksRequest.status_code != 200: + print linksRequest.text + sys.exit(1) + +linksJson = linksRequest.json() +linksLength = len(linksJson["links"]) + +if linksLength != length: + print "Expected length {} but got {}".format(length, linksLength) + sys.exit(1) + +for link in linksJson["links"]: + if srcDeviceId == link["src"]["device"] and srcPort == link["src"]["port"]: + if dstDeviceId == link["dst"]["device"] and dstPort == link["dst"]["port"]: + print "@stc " + name + "SrcDevice=" + link["src"]["device"] + print "@stc " + name + "SrcPort=" + link["src"]["port"] + print "@stc " + name + "DstDevice=" + link["dst"]["device"] + print "@stc " + name + "DstPort=" + link["dst"]["port"] + print "@stc " + name + "Type=" + link["type"] + print "@stc " + name + "State=" + link["state"] + sys.exit(0) + +print "Could not find link from {}:{} to {}:{}"\ + .format(srcDeviceId, srcPort, dstDeviceId, dstPort) +sys.exit(1) + + + + diff --git a/framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py b/framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py new file mode 100755 index 00000000..6d1970f7 --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/find-topo-infrastructure.py @@ -0,0 +1,34 @@ +#! /usr/bin/env python + +import requests +import sys +import urllib + +from requests.auth import HTTPBasicAuth + +if len(sys.argv) != 4: + print "usage: find-topo-infrastructure onos-node name connect-point" + sys.exit(1) + +node = sys.argv[1] +name = sys.argv[2] +id = sys.argv[3] + +infrastructureRequest = requests.get('http://' + node + ':8181/onos/v1/topology/infrastructure/' + + urllib.quote_plus(id), + auth=HTTPBasicAuth('onos', 'rocks')) + +if infrastructureRequest.status_code != 200: + print infrastructureRequest.text + sys.exit(1) + +infrastructureJson = infrastructureRequest.json() + +print "@stc " + name + "Infrastructure=" + str(infrastructureJson["infrastructure"]) + +sys.exit(0) + + + + + diff --git a/framework/src/onos/tools/test/scenarios/bin/query-cluster.py b/framework/src/onos/tools/test/scenarios/bin/query-cluster.py new file mode 100755 index 00000000..0cac7ac3 --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/query-cluster.py @@ -0,0 +1,37 @@ +#! /usr/bin/env python + +import requests +import sys +import urllib + +from requests.auth import HTTPBasicAuth + +if len(sys.argv) != 4: + print "usage: query-cluster onos-node name cluster-number" + sys.exit(1) + +node = sys.argv[1] +name = sys.argv[2] +cluster = sys.argv[3] + +topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/' + + cluster, + auth=HTTPBasicAuth('onos', 'rocks')) + +if topoRequest.status_code != 200: + print topoRequest.text + sys.exit(1) + +topoJson = topoRequest.json() + +print "@stc " + name + "Id=" + str(topoJson["id"]) +print "@stc " + name + "DeviceCount=" + str(topoJson["deviceCount"]) +print "@stc " + name + "LinkCount=" + str(topoJson["linkCount"]) +print "@stc " + name + "Root=" + topoJson["root"] + +sys.exit(0) + + + + + diff --git a/framework/src/onos/tools/test/scenarios/bin/query-topo.py b/framework/src/onos/tools/test/scenarios/bin/query-topo.py new file mode 100755 index 00000000..9b81b4ee --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/query-topo.py @@ -0,0 +1,35 @@ +#! /usr/bin/env python + +import requests +import sys +import urllib + +from requests.auth import HTTPBasicAuth + +if len(sys.argv) != 3: + print "usage: query-topo onos-node name" + sys.exit(1) + +node = sys.argv[1] +name = sys.argv[2] + +topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/', + auth=HTTPBasicAuth('onos', 'rocks')) + +if topoRequest.status_code != 200: + print topoRequest.text + sys.exit(1) + +topoJson = topoRequest.json() + +print "@stc " + name + "Time=" + str(topoJson["time"]) +print "@stc " + name + "Devices=" + str(topoJson["devices"]) +print "@stc " + name + "Links=" + str(topoJson["links"]) +print "@stc " + name + "Clusters=" + str(topoJson["clusters"]) + +sys.exit(0) + + + + + diff --git a/framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py b/framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py new file mode 100755 index 00000000..be834b9b --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/bin/verify-topo-devices.py @@ -0,0 +1,51 @@ +#! /usr/bin/env python + +import requests +import sys +import urllib + +from requests.auth import HTTPBasicAuth + +if len(sys.argv) != 5: + print "usage: verify-topo-links onos-node cluster-id first-index last-index" + sys.exit(1) + +node = sys.argv[1] +cluster = sys.argv[2] +first = int(sys.argv[3]) +last = int(sys.argv[4]) + +found = 0 + +topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/' + + cluster + + "/devices", + auth=HTTPBasicAuth('onos', 'rocks')) + +if topoRequest.status_code != 200: + print topoRequest.text + sys.exit(1) + +topoJson = topoRequest.json() + +for deviceIndex in range(first, last+1): + lookingFor = "of:" + format(deviceIndex, '016x') + print lookingFor + for arrayIndex in range(0, len(topoJson["devices"])): + device = topoJson["devices"][arrayIndex] + if device == lookingFor: + found = found + 1 + print "Match found for " + device + break + + +if found == last - first: + sys.exit(0) + +print "Found " + str(found) + " matches, need " + str(last - first) +sys.exit(2) + + + + + diff --git a/framework/src/onos/tools/test/scenarios/net-link-down-up.xml b/framework/src/onos/tools/test/scenarios/net-link-down-up.xml index 8bcbfa7f..eb4727bd 100644 --- a/framework/src/onos/tools/test/scenarios/net-link-down-up.xml +++ b/framework/src/onos/tools/test/scenarios/net-link-down-up.xml @@ -20,7 +20,9 @@ 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 s7 down --expect ."/> - <step name="Ping-2" requires="~Link-1-Down" + <step name="Ping-2-Prep" requires="~Link-1-Down" + exec="onos-mininet sendAndExpect h1 ping -c5 h4 --expect ."/> + <step name="Ping-2" requires="~Ping-2-Prep" 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 s5 down --expect ."/> @@ -28,11 +30,15 @@ exec="onos-mininet sendAndExpect h1 ping -c1 -w1 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" + <step name="Ping-4-Prep" requires="~Link-1-Up" + exec="onos-mininet sendAndExpect h1 ping -c5 h4 --expect ."/> + <step name="Ping-4" requires="~Ping-4-Prep" 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" + <step name="Ping-5-Prep" requires="~Link-2-Up" + exec="onos-mininet sendAndExpect h1 ping -c5 h4 --expect ."/> + <step name="Ping-5" requires="~Ping-5-Prep" exec="onos-mininet sendAndExpect h1 ping -c1 h4 --expect \ 0% packet loss"/> </group> -</scenario>
\ No newline at end of file +</scenario> diff --git a/framework/src/onos/tools/test/scenarios/net-pingall.xml b/framework/src/onos/tools/test/scenarios/net-pingall.xml index 8968e0dc..87c13227 100644 --- a/framework/src/onos/tools/test/scenarios/net-pingall.xml +++ b/framework/src/onos/tools/test/scenarios/net-pingall.xml @@ -23,7 +23,7 @@ <!-- TODO: take this out when initial pingall sweep is 100% --> <step name="Initial-Ping-All" requires="Check-Apps" - exec="onos-mininet sendAndExpect py net.pingAll(1) --expect 600 received"/> + exec="onos-mininet sendAndExpect py net.pingAll(1) --expect received"/> <step name="Ping-All-And-Verify" requires="Check-Apps,Initial-Ping-All" exec="onos-mininet sendAndExpect py net.pingAll(1) --expect 600/600 received"/> @@ -34,4 +34,4 @@ <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 +</scenario> diff --git a/framework/src/onos/tools/test/scenarios/net-rest.xml b/framework/src/onos/tools/test/scenarios/net-rest.xml index fc7b1d08..ab7804df 100644 --- a/framework/src/onos/tools/test/scenarios/net-rest.xml +++ b/framework/src/onos/tools/test/scenarios/net-rest.xml @@ -101,10 +101,10 @@ <!-- Check that the intents can be fetched via the REST API --> <step name="Net-REST.Validate-Intent-XY-Installed" requires="Net-REST.Create-Intent-YX" - exec="curl -f -uonos:rocks ${xyLocation}"/> + exec="curl-with-retry ${xyLocation}"/> <step name="Net-REST.Validate-Intent-YX-Installed" requires="^" - exec="curl -f -uonos:rocks ${yxLocation}"/> + exec="curl-with-retry ${yxLocation}"/> <!-- Use REST API to query flows created by the intents --> <step name="Net-REST.Validate-Intent-XY-Flow-Installed" @@ -120,7 +120,7 @@ <step name="Net-REST.Validate-YX-Flow-State" requires="^" exec="test '${dev4outFlowState}' == 'ADDED' -o '${dev4outFlowState}' == 'PENDING_ADD'"/> <step name="Net-REST.Validate-YX-Flow-Port" requires="^" - exec="test '${dev4outFlowPort}' == '3'"/> + exec="test ${dev4outFlowPort} -ge 1 -a ${dev4outFlowPort} -le 5"/> <!-- Check that connectivity was established --> <step name="Net-REST.Ping-XY" requires="Net-REST.Create-Intent-XY,Net-REST.Create-Intent-YX" @@ -139,22 +139,23 @@ exec="curl -f -X DELETE -uonos:rocks ${xyLocation}"/> <step name="Net-REST.Delete-Intent-YX" requires="^" exec="curl -f -X DELETE -uonos:rocks ${yxLocation}"/> + <step name="Net-REST.Allow-Intents-To-Purge" + exec="onos-check-intent ${OC1} xy INSTALLED" env="!" + requires="Net-REST.Delete-Intent-XY,Net-REST.Delete-Intent-YX"/> <!-- Use REST API to be sure that flows are no longer installed --> - <step name="Net-REST.Validate-XY-Flows-Removed" requires="Net-REST.Delete-Intent-XY" + <step name="Net-REST.Validate-XY-Flows-Removed" requires="Net-REST.Allow-Intents-To-Purge" exec="find-flow.py ${OC1} dev1out of:0000000000000001" env="!"/> - <step name="Net-REST.Validate-YX-Flows-Removed" requires="Net-REST.Delete-Intent-YX" + <step name="Net-REST.Validate-YX-Flows-Removed" requires="Net-REST.Allow-Intents-To-Purge" exec="find-flow.py ${OC1} dev4out of:0000000000000004" env="!"/> <!-- Check that the deleted intents no longer appear in the REST API --> - <step name="Net-REST.Allow-Intents-To-Purge" requires="Net-REST.Delete-Intent-XY" - exec="sleep 1"/> <step name="Net-REST.Validate-Intent-XY-Removed" requires="Net-REST.Allow-Intents-To-Purge" - exec="curl -f -uonos:rocks ${xyLocation}" env="!"/> + exec="curl-with-retry ${xyLocation}" env="!"/> <step name="Net-REST.Validate-Intent-YX-Removed" requires="Net-REST.Allow-Intents-To-Purge" - exec="curl -f -uonos:rocks ${yxLocation}" env="!"/> + exec="curl-with-retry ${yxLocation}" env="!"/> </group> </scenario> diff --git a/framework/src/onos/tools/test/scenarios/net-setup.xml b/framework/src/onos/tools/test/scenarios/net-setup.xml index e179ec5a..13252d0f 100644 --- a/framework/src/onos/tools/test/scenarios/net-setup.xml +++ b/framework/src/onos/tools/test/scenarios/net-setup.xml @@ -17,9 +17,9 @@ <!-- TODO: parametrize this via recipes --> <group name="Net-Setup"> <step name="Push-Topos" exec="onos-push-topos ${OCN}"/> - <step name="Stop-Mininet-If-Needed" env="~" exec="onos-mininet stop"/> - <step name="Wipe-Out-Data-Before" exec="onos-wipe-out"/> + <step name="Stop-Mininet-If-Needed" env="~" exec="onos-mininet stop"/> + <step name="Wipe-Out-Data-Before" exec="onos-wipe-out" requires="^"/> <step name="Initial-Summary-Check" requires="~Wipe-Out-Data-Before" exec="onos-check-summary ${OC1} [0-9]* 0 0 0"/> @@ -43,4 +43,4 @@ <step name="Check-Flows" requires="~Pause-For-Masters,~Check-Summary" exec="onos-check-flows ${OC1}"/> </group> -</scenario>
\ No newline at end of file +</scenario> diff --git a/framework/src/onos/tools/test/scenarios/net-smoke.xml b/framework/src/onos/tools/test/scenarios/net-smoke.xml index 53a5729c..91131c62 100644 --- a/framework/src/onos/tools/test/scenarios/net-smoke.xml +++ b/framework/src/onos/tools/test/scenarios/net-smoke.xml @@ -35,10 +35,14 @@ <import file="${ONOS_SCENARIOS}/net-create-flows.xml"/> <dependency name="Net-Create-Flows" requires="Net-Setup,P2P-Intent-Connectivity,Net-REST"/> + <import file="${ONOS_SCENARIOS}/net-topo.xml"/> + <dependency name="Net-topo" requires="Net-Setup,Net-Create-Flows"/> + <import file="${ONOS_SCENARIOS}/net-teardown.xml"/> <dependency name="Net-Teardown" requires="~Host-Intent-Connectivity, ~P2P-Intent-Connectivity, ~Net-REST, - ~Net-Create-Flows"/> + ~Net-Create-Flows, + ~Net-topo"/> </group> </scenario> diff --git a/framework/src/onos/tools/test/scenarios/net-topo.xml b/framework/src/onos/tools/test/scenarios/net-topo.xml new file mode 100644 index 00000000..e8e23997 --- /dev/null +++ b/framework/src/onos/tools/test/scenarios/net-topo.xml @@ -0,0 +1,76 @@ +<!-- + ~ 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-topo" + description="Network topology test"> + <!-- TODO: parametrize this via recipes --> + <group name="Net-topo"> + + <!-- Verify the overall topology using the REST API --> + <step name="Net-topo.Query-Topo" + exec="query-topo.py ${OC1} topo"/> + <step name="Net-topo.Verify-Topo-Devices" requires="Net-topo.Query-Topo" + exec="test ${topoDevices} == 25"/> + <step name="Net-topo.Verify-Topo-Links" requires="Net-topo.Query-Topo" + exec="test ${topoLinks} == 140"/> + <step name="Net-topo.Verify-Topo-Clusters" requires="Net-topo.Query-Topo" + exec="test ${topoClusters} == 1"/> + + <!-- Verify the cluster topology using the REST API --> + <step name="Net-topo.Query-Cluster0" + exec="query-cluster.py ${OC1} clusterTopo0 0"/> + <step name="Net-topo.Verify-Cluster0-Id" requires="Net-topo.Query-Cluster0" + exec="test ${clusterTopo0Id} == 0"/> + <step name="Net-topo.Verify-Cluster0-DeviceCount" requires="Net-topo.Query-Cluster0" + exec="test ${clusterTopo0DeviceCount} == 25"/> + <step name="Net-topo.Verify-Cluster0-LinkCount" requires="Net-topo.Query-Cluster0" + exec="test ${clusterTopo0LinkCount} == 140"/> + <step name="Net-topo.Verify-Cluster0-Root" requires="Net-topo.Query-Cluster0" + exec="test '${clusterTopo0Root}' == 'of:000000000000000a'"/> + + <!-- Verify the list of devices for the cluster --> + <step name="Net-topo.Verify-Cluster0-Devices" + exec="verify-topo-devices.py ${OC1} 0 0 24"/> + + <!-- Spot check some known links in the topology --> + <step name="Net-topo.Verify-Cluster0-Link1" + exec="find-link-in-cluster.py ${OC1} link1 0 140 of:000000000000000f 8 of:0000000000000015 3"/> + <step name="Net-topo.Verify-Cluster0-Link2" + exec="find-link-in-cluster.py ${OC1} link2 0 140 of:0000000000000008 3 of:0000000000000005 4"/> + <step name="Net-topo.Verify-Cluster0-Link3" + exec="find-link-in-cluster.py ${OC1} link3 0 140 of:0000000000000011 2 of:0000000000000002 9"/> + <step name="Net-topo.Verify-Cluster0-Link4" + exec="find-link-in-cluster.py ${OC1} link4 0 140 of:000000000000000f 3 of:000000000000000d 10"/> + <step name="Net-topo.Verify-Cluster0-Link5" + exec="find-link-in-cluster.py ${OC1} link5 0 140 of:000000000000000d 13 of:0000000000000010 6"/> + + <!-- Verify the topology infrastructure query --> + <step name="Net-topo.Query-Cluster0-Infra1" + exec="find-topo-infrastructure.py ${OC1} infra1 of:000000000000000f:8"/> + <step name="Net-topo.Verify-Cluster0-Infra1" requires="Net-topo.Query-Cluster0-Infra1" + exec="test '${infra1Infrastructure}' == 'True'"/> + + <step name="Net-topo.Query-Cluster0-Infra2" + exec="find-topo-infrastructure.py ${OC1} infra2 of:000000000000000d:8"/> + <step name="Net-topo.Verify-Cluster0-Infra2" requires="Net-topo.Query-Cluster0-Infra2" + exec="test '${infra2Infrastructure}' == 'True'"/> + + <step name="Net-topo.Query-Cluster0-Infra3" + exec="find-topo-infrastructure.py ${OC1} infra3 of:0000000000000012:8"/> + <step name="Net-topo.Verify-Cluster0-Infra3" requires="Net-topo.Query-Cluster0-Infra3" + exec="test '${infra3Infrastructure}' == 'False'"/> + + </group> +</scenario> diff --git a/framework/src/onos/tools/test/scenarios/prerequisites.xml b/framework/src/onos/tools/test/scenarios/prerequisites.xml index 650aa411..2c541d5b 100644 --- a/framework/src/onos/tools/test/scenarios/prerequisites.xml +++ b/framework/src/onos/tools/test/scenarios/prerequisites.xml @@ -15,7 +15,7 @@ --> <scenario name="prerequisites" description="ONOS test pre-requisites"> <group name="Prerequisites"> - <step name="Check-Environment" exec="test -n ${ONOS_ROOT} -a -n ${ONOS_NIC} -a -n ${OC1}"/> + <step name="Check-Environment" exec="test -n ${ONOS_ROOT} -a -n ${ONOS_NIC} -a -n ${OC1} -a '${ONOS_USE_SSH}' == 'true'"/> <step name="Check-ONOS-Bits" exec="onos-check-bits"/> <parallel var="${OC#}"> |