diff options
Diffstat (limited to 'framework/src/onos/tools/test/scenarios/bin')
6 files changed, 234 insertions, 0 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) + + + + + |