Ray Milkey

Add tests of topology APIs to STC smoke test.

Change-Id: Ie993df1c8a4150a1b4467cc3cffe54eec6f64d43
1 +#! /usr/bin/env python
2 +
3 +import requests
4 +import sys
5 +
6 +from requests.auth import HTTPBasicAuth
7 +
8 +if len(sys.argv) != 9:
9 + print "usage: find-link-in-cluster onos-node name cluster-id expected-length src-device-id src-port dst-device-id dst-port"
10 + sys.exit(1)
11 +
12 +node = sys.argv[1]
13 +name = sys.argv[2]
14 +cluster = sys.argv[3]
15 +length = int(sys.argv[4])
16 +srcDeviceId = sys.argv[5]
17 +srcPort = sys.argv[6]
18 +dstDeviceId = sys.argv[7]
19 +dstPort = sys.argv[8]
20 +
21 +
22 +linksRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/'
23 + + cluster + '/links',
24 + auth=HTTPBasicAuth('onos', 'rocks'))
25 +
26 +if linksRequest.status_code != 200:
27 + print linksRequest.text
28 + sys.exit(1)
29 +
30 +linksJson = linksRequest.json()
31 +linksLength = len(linksJson["links"])
32 +
33 +if linksLength != length:
34 + print "Expected length {} but got {}".format(length, linksLength)
35 + sys.exit(1)
36 +
37 +for link in linksJson["links"]:
38 + if srcDeviceId == link["src"]["device"] and srcPort == link["src"]["port"]:
39 + if dstDeviceId == link["dst"]["device"] and dstPort == link["dst"]["port"]:
40 + print "@stc " + name + "SrcDevice=" + link["src"]["device"]
41 + print "@stc " + name + "SrcPort=" + link["src"]["port"]
42 + print "@stc " + name + "DstDevice=" + link["dst"]["device"]
43 + print "@stc " + name + "DstPort=" + link["dst"]["port"]
44 + print "@stc " + name + "Type=" + link["type"]
45 + print "@stc " + name + "State=" + link["state"]
46 + sys.exit(0)
47 +
48 +print "Could not find link from {}:{} to {}:{}"\
49 + .format(srcDeviceId, srcPort, dstDeviceId, dstPort)
50 +sys.exit(1)
51 +
52 +
53 +
54 +
1 +#! /usr/bin/env python
2 +
3 +import requests
4 +import sys
5 +import urllib
6 +
7 +from requests.auth import HTTPBasicAuth
8 +
9 +if len(sys.argv) != 4:
10 + print "usage: find-topo-infrastructure onos-node name connect-point"
11 + sys.exit(1)
12 +
13 +node = sys.argv[1]
14 +name = sys.argv[2]
15 +id = sys.argv[3]
16 +
17 +infrastructureRequest = requests.get('http://' + node + ':8181/onos/v1/topology/infrastructure/' +
18 + urllib.quote_plus(id),
19 + auth=HTTPBasicAuth('onos', 'rocks'))
20 +
21 +if infrastructureRequest.status_code != 200:
22 + print infrastructureRequest.text
23 + sys.exit(1)
24 +
25 +infrastructureJson = infrastructureRequest.json()
26 +
27 +print "@stc " + name + "Infrastructure=" + str(infrastructureJson["infrastructure"])
28 +
29 +sys.exit(0)
30 +
31 +
32 +
33 +
34 +
1 +#! /usr/bin/env python
2 +
3 +import requests
4 +import sys
5 +import urllib
6 +
7 +from requests.auth import HTTPBasicAuth
8 +
9 +if len(sys.argv) != 4:
10 + print "usage: query-cluster onos-node name cluster-number"
11 + sys.exit(1)
12 +
13 +node = sys.argv[1]
14 +name = sys.argv[2]
15 +cluster = sys.argv[3]
16 +
17 +topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/'
18 + + cluster,
19 + auth=HTTPBasicAuth('onos', 'rocks'))
20 +
21 +if topoRequest.status_code != 200:
22 + print topoRequest.text
23 + sys.exit(1)
24 +
25 +topoJson = topoRequest.json()
26 +
27 +print "@stc " + name + "Id=" + str(topoJson["id"])
28 +print "@stc " + name + "DeviceCount=" + str(topoJson["deviceCount"])
29 +print "@stc " + name + "LinkCount=" + str(topoJson["linkCount"])
30 +print "@stc " + name + "Root=" + topoJson["root"]
31 +
32 +sys.exit(0)
33 +
34 +
35 +
36 +
37 +
1 +#! /usr/bin/env python
2 +
3 +import requests
4 +import sys
5 +import urllib
6 +
7 +from requests.auth import HTTPBasicAuth
8 +
9 +if len(sys.argv) != 3:
10 + print "usage: query-topo onos-node name"
11 + sys.exit(1)
12 +
13 +node = sys.argv[1]
14 +name = sys.argv[2]
15 +
16 +topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/',
17 + auth=HTTPBasicAuth('onos', 'rocks'))
18 +
19 +if topoRequest.status_code != 200:
20 + print topoRequest.text
21 + sys.exit(1)
22 +
23 +topoJson = topoRequest.json()
24 +
25 +print "@stc " + name + "Time=" + str(topoJson["time"])
26 +print "@stc " + name + "Devices=" + str(topoJson["devices"])
27 +print "@stc " + name + "Links=" + str(topoJson["links"])
28 +print "@stc " + name + "Clusters=" + str(topoJson["clusters"])
29 +
30 +sys.exit(0)
31 +
32 +
33 +
34 +
35 +
1 +#! /usr/bin/env python
2 +
3 +import requests
4 +import sys
5 +import urllib
6 +
7 +from requests.auth import HTTPBasicAuth
8 +
9 +if len(sys.argv) != 5:
10 + print "usage: verify-topo-links onos-node cluster-id first-index last-index"
11 + sys.exit(1)
12 +
13 +node = sys.argv[1]
14 +cluster = sys.argv[2]
15 +first = int(sys.argv[3])
16 +last = int(sys.argv[4])
17 +
18 +found = 0
19 +
20 +topoRequest = requests.get('http://' + node + ':8181/onos/v1/topology/clusters/'
21 + + cluster
22 + + "/devices",
23 + auth=HTTPBasicAuth('onos', 'rocks'))
24 +
25 +if topoRequest.status_code != 200:
26 + print topoRequest.text
27 + sys.exit(1)
28 +
29 +topoJson = topoRequest.json()
30 +
31 +for deviceIndex in range(first, last+1):
32 + lookingFor = "of:" + format(deviceIndex, '016x')
33 + print lookingFor
34 + for arrayIndex in range(0, len(topoJson["devices"])):
35 + device = topoJson["devices"][arrayIndex]
36 + if device == lookingFor:
37 + found = found + 1
38 + print "Match found for " + device
39 + break
40 +
41 +
42 +if found == last - first:
43 + sys.exit(0)
44 +
45 +print "Found " + str(found) + " matches, need " + str(last - first)
46 +sys.exit(2)
47 +
48 +
49 +
50 +
51 +
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
35 <import file="${ONOS_SCENARIOS}/net-create-flows.xml"/> 35 <import file="${ONOS_SCENARIOS}/net-create-flows.xml"/>
36 <dependency name="Net-Create-Flows" requires="Net-Setup,P2P-Intent-Connectivity,Net-REST"/> 36 <dependency name="Net-Create-Flows" requires="Net-Setup,P2P-Intent-Connectivity,Net-REST"/>
37 37
38 + <import file="${ONOS_SCENARIOS}/net-topo.xml"/>
39 + <dependency name="Net-topo" requires="Net-Setup,Net-Create-Flows"/>
40 +
38 <import file="${ONOS_SCENARIOS}/net-teardown.xml"/> 41 <import file="${ONOS_SCENARIOS}/net-teardown.xml"/>
39 <dependency name="Net-Teardown" requires="~Host-Intent-Connectivity, 42 <dependency name="Net-Teardown" requires="~Host-Intent-Connectivity,
40 ~P2P-Intent-Connectivity, 43 ~P2P-Intent-Connectivity,
......
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="net-topo"
17 + description="Network topology test">
18 + <!-- TODO: parametrize this via recipes -->
19 + <group name="Net-topo">
20 +
21 + <!-- Verify the overall topology using the REST API -->
22 + <step name="Net-topo.Query-Topo"
23 + exec="query-topo.py ${OC1} topo"/>
24 + <step name="Net-topo.Verify-Topo-Devices" requires="Net-topo.Query-Topo"
25 + exec="test ${topoDevices} == 25"/>
26 + <step name="Net-topo.Verify-Topo-Links" requires="Net-topo.Query-Topo"
27 + exec="test ${topoLinks} == 140"/>
28 + <step name="Net-topo.Verify-Topo-Clusters" requires="Net-topo.Query-Topo"
29 + exec="test ${topoClusters} == 1"/>
30 +
31 + <!-- Verify the cluster topology using the REST API -->
32 + <step name="Net-topo.Query-Cluster0"
33 + exec="query-cluster.py ${OC1} clusterTopo0 0"/>
34 + <step name="Net-topo.Verify-Cluster0-Id" requires="Net-topo.Query-Cluster0"
35 + exec="test ${clusterTopo0Id} == 0"/>
36 + <step name="Net-topo.Verify-Cluster0-DeviceCount" requires="Net-topo.Query-Cluster0"
37 + exec="test ${clusterTopo0DeviceCount} == 25"/>
38 + <step name="Net-topo.Verify-Cluster0-LinkCount" requires="Net-topo.Query-Cluster0"
39 + exec="test ${clusterTopo0LinkCount} == 140"/>
40 + <step name="Net-topo.Verify-Cluster0-Root" requires="Net-topo.Query-Cluster0"
41 + exec="test '${clusterTopo0Root}' == 'of:000000000000000a'"/>
42 +
43 + <!-- Verify the list of devices for the cluster -->
44 + <step name="Net-topo.Verify-Cluster0-Devices"
45 + exec="verify-topo-devices.py ${OC1} 0 0 24"/>
46 +
47 + <!-- Spot check some known links in the topology -->
48 + <step name="Net-topo.Verify-Cluster0-Link1"
49 + exec="find-link-in-cluster.py ${OC1} link1 0 140 of:000000000000000f 8 of:0000000000000015 3"/>
50 + <step name="Net-topo.Verify-Cluster0-Link2"
51 + exec="find-link-in-cluster.py ${OC1} link2 0 140 of:0000000000000008 3 of:0000000000000005 4"/>
52 + <step name="Net-topo.Verify-Cluster0-Link3"
53 + exec="find-link-in-cluster.py ${OC1} link3 0 140 of:0000000000000011 2 of:0000000000000002 9"/>
54 + <step name="Net-topo.Verify-Cluster0-Link4"
55 + exec="find-link-in-cluster.py ${OC1} link4 0 140 of:000000000000000f 3 of:000000000000000d 10"/>
56 + <step name="Net-topo.Verify-Cluster0-Link5"
57 + exec="find-link-in-cluster.py ${OC1} link5 0 140 of:000000000000000d 13 of:0000000000000010 6"/>
58 +
59 + <!-- Verify the topology infrastructure query -->
60 + <step name="Net-topo.Query-Cluster0-Infra1"
61 + exec="find-topo-infrastructure.py ${OC1} infra1 of:000000000000000f:8"/>
62 + <step name="Net-topo.Verify-Cluster0-Infra1" requires="Net-topo.Query-Cluster0-Infra1"
63 + exec="test '${infra1Infrastructure}' == 'True'"/>
64 +
65 + <step name="Net-topo.Query-Cluster0-Infra2"
66 + exec="find-topo-infrastructure.py ${OC1} infra2 of:000000000000000d:8"/>
67 + <step name="Net-topo.Verify-Cluster0-Infra2" requires="Net-topo.Query-Cluster0-Infra2"
68 + exec="test '${infra2Infrastructure}' == 'True'"/>
69 +
70 + <step name="Net-topo.Query-Cluster0-Infra3"
71 + exec="find-topo-infrastructure.py ${OC1} infra3 of:0000000000000012:8"/>
72 + <step name="Net-topo.Verify-Cluster0-Infra3" requires="Net-topo.Query-Cluster0-Infra3"
73 + exec="test '${infra3Infrastructure}' == 'False'"/>
74 +
75 + </group>
76 +</scenario>