Committed by
Gerrit Code Review
STC scenario for testing posting and removal of configs
Change-Id: I5395d6b42a52ba29063eb9ee139dcfb659247614
Showing
7 changed files
with
224 additions
and
1 deletions
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) < 3: | ||
9 | + print "usage: find-dhcp-netcfg onos-node name1=value1 ..." | ||
10 | + sys.exit(1) | ||
11 | + | ||
12 | +node = sys.argv[1] | ||
13 | + | ||
14 | +cfgRequest = requests.get('http://' + node + ':8181/onos/v1/network/configuration', | ||
15 | + auth=HTTPBasicAuth('onos', 'rocks')) | ||
16 | + | ||
17 | +if cfgRequest.status_code != 200: | ||
18 | + print cfgRequest.text | ||
19 | + sys.exit(1) | ||
20 | + | ||
21 | +cfgJson = cfgRequest.json() | ||
22 | +appFound = False | ||
23 | + | ||
24 | + | ||
25 | +for index in range(2, len(sys.argv)): | ||
26 | + pair = sys.argv[index].split("=") | ||
27 | + for app in cfgJson["apps"]: | ||
28 | + if app == "org.onosproject.dhcp": | ||
29 | + dhcp = cfgJson["apps"][app]["dhcp"] | ||
30 | + appFound = True | ||
31 | + | ||
32 | + name = pair[0] | ||
33 | + value = pair[1] | ||
34 | + | ||
35 | + if dhcp[name] != value: | ||
36 | + print name + " differs: expected " + value + " but found " + dhcp[name] | ||
37 | + print cfgJson | ||
38 | + sys.exit(1) | ||
39 | + | ||
40 | +if appFound: | ||
41 | + sys.exit(0) | ||
42 | + | ||
43 | +print "DHCP app not found" | ||
44 | +print cfgJson | ||
45 | +sys.exit(2) | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | + |
tools/test/scenarios/bin/delete-netcfg.py
0 → 100755
1 | +#! /usr/bin/env python | ||
2 | + | ||
3 | +import requests | ||
4 | + | ||
5 | +from requests.auth import HTTPBasicAuth | ||
6 | +import sys | ||
7 | + | ||
8 | + | ||
9 | + | ||
10 | +if len(sys.argv) != 3: | ||
11 | + print "usage: delete-netcfg onos-node config-name" | ||
12 | + sys.exit(1) | ||
13 | + | ||
14 | +node = sys.argv[1] | ||
15 | +configName = sys.argv[2] | ||
16 | + | ||
17 | +intentRequest = requests.delete('http://' + node + ':8181/onos/v1/network/configuration/' + configName, | ||
18 | + auth=HTTPBasicAuth('onos', 'rocks')) | ||
19 | + | ||
20 | +if intentRequest.status_code != 204: | ||
21 | + print intentRequest.text | ||
22 | + sys.exit(1) | ||
23 | + | ||
24 | +sys.exit(0) | ||
25 | + | ||
26 | + | ||
27 | + |
tools/test/scenarios/bin/post-netcfg.py
0 → 100755
1 | +#! /usr/bin/env python | ||
2 | + | ||
3 | +import requests | ||
4 | + | ||
5 | +from requests.auth import HTTPBasicAuth | ||
6 | +import sys | ||
7 | + | ||
8 | +if len(sys.argv) != 3: | ||
9 | + print "usage: post-netcfg onos-node json-file-name" | ||
10 | + sys.exit(1) | ||
11 | + | ||
12 | +node = sys.argv[1] | ||
13 | +configFileName = sys.argv[2] | ||
14 | + | ||
15 | +jsonFile = open(configFileName, 'rb') | ||
16 | +configJson = jsonFile.read() | ||
17 | + | ||
18 | +request = requests.post('http://' + node + ':8181/onos/v1/network/configuration', | ||
19 | + auth=HTTPBasicAuth('onos', 'rocks'), | ||
20 | + data=configJson) | ||
21 | + | ||
22 | +if request.status_code != 200: | ||
23 | + print request.text | ||
24 | + sys.exit(1) | ||
25 | + | ||
26 | +sys.exit(0) | ||
27 | + | ||
28 | + | ||
29 | + |
1 | +{ | ||
2 | + "apps": { | ||
3 | + "org.onosproject.dhcp" : { | ||
4 | + "dhcp" : { | ||
5 | + "ip": "10.1.11.50", | ||
6 | + "mac": "ca:fe:ca:fe:ca:fe", | ||
7 | + "subnet": "255.255.252.0", | ||
8 | + "broadcast": "10.1.11.255", | ||
9 | + "router": "10.1.8.1", | ||
10 | + "domain": "8.8.8.8", | ||
11 | + "ttl": "1", | ||
12 | + "lease": "2", | ||
13 | + "renew": "3", | ||
14 | + "rebind": "4", | ||
15 | + "delay": "5", | ||
16 | + "timeout": "6", | ||
17 | + "startip": "10.1.11.51", | ||
18 | + "endip": "10.1.11.100" | ||
19 | + } | ||
20 | + } | ||
21 | + } | ||
22 | +} |
1 | +{ | ||
2 | + "apps": { | ||
3 | + "org.onosproject.dhcp" : { | ||
4 | + "dhcp" : { | ||
5 | + "ip": "10.1.11.50", | ||
6 | + "mac": "ca:fe:ca:fe:ca:fe", | ||
7 | + "subnet": "255.255.252.0", | ||
8 | + "broadcast": "10.1.11.255", | ||
9 | + "router": "10.1.8.1", | ||
10 | + "domain": "8.8.8.8", | ||
11 | + "ttl": "21", | ||
12 | + "lease": "22", | ||
13 | + "renew": "23", | ||
14 | + "rebind": "24", | ||
15 | + "delay": "25", | ||
16 | + "timeout": "26", | ||
17 | + "startip": "10.1.11.51", | ||
18 | + "endip": "10.1.11.100" | ||
19 | + } | ||
20 | + } | ||
21 | + } | ||
22 | +} |
tools/test/scenarios/netcfg.xml
0 → 100644
1 | +<!-- | ||
2 | + ~ Copyright 2016-present 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="netcfg" | ||
17 | + description="Network configuration REST API test"> | ||
18 | + | ||
19 | + <group name="Netcfg"> | ||
20 | + | ||
21 | + <!-- Activate the DHCP app --> | ||
22 | + <step name="Netcfg.Activate-Dhcp" | ||
23 | + exec="onos ${OC1} app activate org.onosproject.dhcp"/> | ||
24 | + | ||
25 | + <!-- Upload the first set of config changes --> | ||
26 | + <step name="Netcfg.Post-1" requires="^" | ||
27 | + exec="post-netcfg.py ${OC1} ${ONOS_SCENARIOS}/netcfg-test/dhcp-cfg1.json"/> | ||
28 | + | ||
29 | + <group name="Query1" requires="Netcfg.Post-1"> | ||
30 | + <parallel var="${OC#}" starts="Netcfg.Query-1-${#}"> | ||
31 | + <!-- Check that the values made it into the config for the DHCP server --> | ||
32 | + <step name="Netcfg.QueryDhcp-1-${#}" exec="check-dhcp-netcfg.py ${OC#} ttl=1 lease=2 renew=3 rebind=4 delay=5 timeout=6"/> | ||
33 | + </parallel> | ||
34 | + </group> | ||
35 | + | ||
36 | + <!-- Upload the second set of config changes --> | ||
37 | + <step name="Netcfg.Post-2" requires="Query1" | ||
38 | + exec="post-netcfg.py ${OC1} ${ONOS_SCENARIOS}/netcfg-test/dhcp-cfg2.json"/> | ||
39 | + | ||
40 | + <!-- Check that the values made it into the config for the DHCP server --> | ||
41 | + <group name="Query2" requires="Netcfg.Post-2"> | ||
42 | + <parallel var="${OC#}" starts="Netcfg.Query-2-${#}"> | ||
43 | + <!-- Check that the values made it into the config for the DHCP server --> | ||
44 | + <step name="Netcfg.QueryDhcp-2-${#}" exec="check-dhcp-netcfg.py ${OC#} ttl=21 lease=22 renew=23 rebind=24 delay=25 timeout=26"/> | ||
45 | + </parallel> | ||
46 | + </group> | ||
47 | + | ||
48 | + | ||
49 | + <!-- Delete the DHCP server config --> | ||
50 | + <step name="Netcfg.Delete" requires="Query2" | ||
51 | + exec="delete-netcfg.py ${OC1} apps/org.onosproject.dhcp/dhcp"/> | ||
52 | + | ||
53 | + <!-- Check that the config for the DHCP server is no longer there --> | ||
54 | + <group name="Query3" requires="Netcfg.Delete"> | ||
55 | + <parallel var="${OC#}" starts="Netcfg.Query-3-${#}"> | ||
56 | + <!-- Check that the values were deleted for the config for the DHCP server --> | ||
57 | + <step name="Netcfg.QueryDhcp-31-${#}" env="!" exec="check-dhcp-netcfg.py ${OC#} ttl=21"/> | ||
58 | + <step name="Netcfg.QueryDhcp-32-${#}" env="!" exec="check-dhcp-netcfg.py ${OC#} lease=22"/> | ||
59 | + <step name="Netcfg.QueryDhcp-33-${#}" env="!" exec="check-dhcp-netcfg.py ${OC#} renew=23"/> | ||
60 | + <step name="Netcfg.QueryDhcp-34-${#}" env="!" exec="check-dhcp-netcfg.py ${OC#} rebind=24"/> | ||
61 | + <step name="Netcfg.QueryDhcp-35-${#}" env="!" exec="check-dhcp-netcfg.py ${OC#} delay=25"/> | ||
62 | + <step name="Netcfg.QueryDhcp-36-${#}" env="!" exec="check-dhcp-netcfg.py ${OC#} timeout=26"/> | ||
63 | + </parallel> | ||
64 | + </group> | ||
65 | + | ||
66 | + <!-- Deactivate the DHCP app --> | ||
67 | + <step name="Netcfg.Deactivate-Dhcp" requires="Query3" | ||
68 | + exec="onos ${OC1} app deactivate org.onosproject.dhcp"/> | ||
69 | + | ||
70 | + </group> | ||
71 | +</scenario> |
... | @@ -34,6 +34,9 @@ | ... | @@ -34,6 +34,9 @@ |
34 | <import file="${ONOS_SCENARIOS}/drivers-test.xml"/> | 34 | <import file="${ONOS_SCENARIOS}/drivers-test.xml"/> |
35 | <dependency name="Drivers-Test" requires="Setup,Net-Smoke,Archetypes"/> | 35 | <dependency name="Drivers-Test" requires="Setup,Net-Smoke,Archetypes"/> |
36 | 36 | ||
37 | + <import file="${ONOS_SCENARIOS}/netcfg.xml"/> | ||
38 | + <dependency name="Netcfg" requires="Setup"/> | ||
39 | + | ||
37 | <import file="${ONOS_SCENARIOS}/wrapup.xml"/> | 40 | <import file="${ONOS_SCENARIOS}/wrapup.xml"/> |
38 | - <dependency name="Wrapup" requires="~Archetypes,~Setup,~Net-Smoke,~Drivers-Test,~MetaAppReactivated"/> | 41 | + <dependency name="Wrapup" requires="~Archetypes,~Setup,~Net-Smoke,~Drivers-Test,~MetaAppReactivated,~Netcfg"/> |
39 | </scenario> | 42 | </scenario> | ... | ... |
-
Please register or login to post a comment