| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 1 | """ |
| 2 | Copyright (c) 2015 SONATA-NFV |
| 3 | ALL RIGHTS RESERVED. |
| 4 | |
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | you may not use this file except in compliance with the License. |
| 7 | You may obtain a copy of the License at |
| 8 | |
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | Unless required by applicable law or agreed to in writing, software |
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | See the License for the specific language governing permissions and |
| 15 | limitations under the License. |
| 16 | |
| 17 | Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION] |
| 18 | nor the names of its contributors may be used to endorse or promote |
| 19 | products derived from this software without specific prior written |
| 20 | permission. |
| 21 | |
| 22 | This work has been performed in the framework of the SONATA project, |
| 23 | funded by the European Commission under Grant number 671517 through |
| 24 | the Horizon 2020 and 5G-PPP programmes. The authors would like to |
| 25 | acknowledge the contributions of their colleagues of the SONATA |
| 26 | partner consortium (www.sonata-nfv.eu). |
| 27 | """ |
| 28 | |
| 29 | """ |
| 30 | Test suite to automatically test emulator REST API endpoints. |
| 31 | """ |
| 32 | |
| 33 | import os |
| 34 | import unittest |
| 35 | import requests |
| 36 | import simplejson as json |
| peusterm | 861bad7 | 2017-05-18 14:55:27 +0200 | [diff] [blame] | 37 | import time |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 38 | |
| 39 | from emuvim.test.api_base_openstack import ApiBaseOpenStack |
| 40 | |
| 41 | |
| 42 | class testRestApi(ApiBaseOpenStack): |
| 43 | """ |
| 44 | Tests to check the REST API endpoints of the emulator. |
| 45 | """ |
| 46 | |
| 47 | def setUp(self): |
| 48 | # create network |
| 49 | self.createNet(nswitches=3, ndatacenter=2, nhosts=2, ndockers=0, autolinkswitches=True) |
| 50 | |
| 51 | # setup links |
| 52 | self.net.addLink(self.dc[0], self.h[0]) |
| 53 | self.net.addLink(self.h[1], self.dc[1]) |
| 54 | self.net.addLink(self.dc[0], self.dc[1]) |
| 55 | |
| 56 | # start api |
| 57 | self.startApi() |
| 58 | |
| 59 | # start Mininet network |
| 60 | self.startNet() |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 61 | |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 62 | def testNovaDummy(self): |
| 63 | print('->>>>>>> test Nova Dummy Class->>>>>>>>>>>>>>>') |
| 64 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 65 | print(" ") |
| 66 | |
| 67 | headers = {'Content-type': 'application/json'} |
| 68 | test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 69 | url = "http://0.0.0.0:18004/v1/tenantabc123/stacks" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 70 | requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), |
| 71 | headers=headers) |
| 72 | |
| 73 | print('->>>>>>> test Nova List Versions ->>>>>>>>>>>>>>>') |
| 74 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 75 | url = "http://0.0.0.0:18774/" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 76 | listapiversionnovaresponse = requests.get(url, headers=headers) |
| 77 | self.assertEqual(listapiversionnovaresponse.status_code, 200) |
| 78 | self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["id"], "v2.1") |
| 79 | self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["status"], "CURRENT") |
| 80 | self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["version"], "2.38") |
| 81 | self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["min_version"], "2.1") |
| 82 | self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["updated"], "2013-07-23T11:33:21Z") |
| 83 | print(" ") |
| 84 | |
| 85 | print('->>>>>>> test Nova Version Show ->>>>>>>>>>>>>>>') |
| 86 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 87 | url = "http://0.0.0.0:18774/v2.1/id_bla" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 88 | listapiversion21novaresponse = requests.get(url, headers=headers) |
| 89 | self.assertEqual(listapiversion21novaresponse.status_code, 200) |
| 90 | self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["id"], "v2.1") |
| 91 | self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["status"], "CURRENT") |
| 92 | self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["version"], "2.38") |
| 93 | self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["min_version"], "2.1") |
| 94 | self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["updated"], "2013-07-23T11:33:21Z") |
| 95 | print(" ") |
| 96 | |
| 97 | print('->>>>>>> test Nova Version List Server APIs ->>>>>>>>>>>>>>>') |
| 98 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 99 | url = "http://0.0.0.0:18774/v2.1/id_bla/servers" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 100 | listserverapisnovaresponse = requests.get(url, headers=headers) |
| 101 | self.assertEqual(listserverapisnovaresponse.status_code, 200) |
| 102 | self.assertNotEqual(json.loads(listserverapisnovaresponse.content)["servers"][0]["name"], "") |
| 103 | print(" ") |
| 104 | |
| 105 | print('->>>>>>> test Nova Delete Server APIs ->>>>>>>>>>>>>>>') |
| 106 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 107 | url = "http://0.0.0.0:18774/v2.1/id_bla/servers/%s" % (json.loads(listserverapisnovaresponse.content)["servers"][0]["id"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 108 | deleteserverapisnovaresponse = requests.delete(url, headers=headers) |
| 109 | self.assertEqual(deleteserverapisnovaresponse.status_code, 204) |
| 110 | print(" ") |
| 111 | |
| 112 | print('->>>>>>> test Nova Delete Non-Existing Server APIs ->>>>>>>>>>>>>>>') |
| 113 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 114 | url = "http://0.0.0.0:18774/v2.1/id_bla/servers/non-existing-ix" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 115 | deleteserverapisnovaresponse = requests.delete(url, headers=headers) |
| 116 | self.assertEqual(deleteserverapisnovaresponse.status_code, 404) |
| 117 | print(" ") |
| 118 | |
| 119 | |
| 120 | print('->>>>>>> testNovaVersionListServerAPIs_withPortInformation ->>>>>>>>>>>>>>>') |
| 121 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 122 | url = "http://0.0.0.0:18774/v2.1/id_bla/servers/andPorts" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 123 | listserverapisnovaresponse = requests.get(url, headers=headers) |
| 124 | self.assertEqual(listserverapisnovaresponse.status_code, 200) |
| 125 | self.assertNotEqual(json.loads(listserverapisnovaresponse.content)["servers"][0]["name"], "") |
| 126 | print(" ") |
| 127 | |
| 128 | print('->>>>>>> test Nova List Flavors ->>>>>>>>>>>>>>>') |
| 129 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 130 | url = "http://0.0.0.0:18774/v2.1/id_bla/flavors" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 131 | listflavorsresponse = requests.get(url, headers=headers) |
| 132 | self.assertEqual(listflavorsresponse.status_code, 200) |
| 133 | self.assertIn(json.loads(listflavorsresponse.content)["flavors"][0]["name"], ["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 134 | self.assertIn(json.loads(listflavorsresponse.content)["flavors"][1]["name"], ["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 135 | self.assertIn(json.loads(listflavorsresponse.content)["flavors"][2]["name"], ["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 136 | print(" ") |
| 137 | |
| 138 | print('->>>>>>> testNovaAddFlavors ->>>>>>>>>>>>>>>') |
| 139 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 140 | url = "http://0.0.0.0:18774/v2.1/id_bla/flavors" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 141 | addflavorsresponse = requests.post(url, |
| 142 | data='{"flavor":{"name": "testFlavor", "vcpus": "test_vcpus", "ram": 1024, "disk": 10}}', |
| 143 | headers=headers) |
| 144 | self.assertEqual(addflavorsresponse.status_code, 200) |
| 145 | self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["id"]) |
| 146 | self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["links"][0]['href']) |
| 147 | print(" ") |
| 148 | |
| 149 | print('->>>>>>> test Nova List Flavors Detail ->>>>>>>>>>>>>>>') |
| 150 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 151 | url = "http://0.0.0.0:18774/v2.1/id_bla/flavors/detail" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 152 | listflavorsdetailresponse = requests.get(url, headers=headers) |
| 153 | self.assertEqual(listflavorsdetailresponse.status_code, 200) |
| 154 | self.assertIn(json.loads(listflavorsdetailresponse.content)["flavors"][0]["name"],["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 155 | self.assertIn(json.loads(listflavorsdetailresponse.content)["flavors"][1]["name"],["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 156 | self.assertIn(json.loads(listflavorsdetailresponse.content)["flavors"][2]["name"],["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 157 | print(" ") |
| 158 | |
| 159 | print('->>>>>>> testNovaAddFlavors ->>>>>>>>>>>>>>>') |
| 160 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 161 | url = "http://0.0.0.0:18774/v2.1/id_bla/flavors/detail" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 162 | addflavorsresponse = requests.post(url, |
| 163 | data='{"flavor":{"name": "testFlavor", "vcpus": "test_vcpus", "ram": 1024, "disk": 10}}', |
| 164 | headers=headers) |
| 165 | self.assertEqual(addflavorsresponse.status_code, 200) |
| 166 | self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["id"]) |
| 167 | self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["links"][0]['href']) |
| 168 | print(" ") |
| 169 | |
| 170 | print('->>>>>>> test Nova List Flavor By Id ->>>>>>>>>>>>>>>') |
| 171 | |
| 172 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 173 | url = "http://0.0.0.0:18774/v2.1/id_bla/flavors/%s" % (json.loads(listflavorsdetailresponse.content)["flavors"][0]["name"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 174 | listflavorsbyidresponse = requests.get(url, headers=headers) |
| 175 | self.assertEqual(listflavorsbyidresponse.status_code, 200) |
| 176 | self.assertEqual(json.loads(listflavorsbyidresponse.content)["flavor"]["id"], json.loads(listflavorsdetailresponse.content)["flavors"][0]["id"]) |
| 177 | print(" ") |
| 178 | |
| 179 | print('->>>>>>> test Nova List Images ->>>>>>>>>>>>>>>') |
| 180 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 181 | url = "http://0.0.0.0:18774/v2.1/id_bla/images" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 182 | listimagesresponse = requests.get(url, headers=headers) |
| 183 | self.assertEqual(listimagesresponse.status_code, 200) |
| 184 | print(listimagesresponse.content) |
| 185 | # deactivated: highly depends on the environment in which the tests are executed. one cannot make such an assumption. |
| 186 | #self.assertIn(json.loads(listimagesresponse.content)["images"][0]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 187 | #self.assertIn(json.loads(listimagesresponse.content)["images"][1]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 188 | #self.assertIn(json.loads(listimagesresponse.content)["images"][2]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 189 | print(" ") |
| 190 | |
| 191 | print('->>>>>>> test Nova List Images Details ->>>>>>>>>>>>>>>') |
| 192 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 193 | url = "http://0.0.0.0:18774/v2.1/id_bla/images/detail" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 194 | listimagesdetailsresponse = requests.get(url, headers=headers) |
| 195 | self.assertEqual(listimagesdetailsresponse.status_code, 200) |
| 196 | # deactivated: highly depends on the environment in which the tests are executed. one cannot make such an assumption. |
| 197 | #self.assertIn(json.loads(listimagesdetailsresponse.content)["images"][0]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 198 | #self.assertIn(json.loads(listimagesdetailsresponse.content)["images"][1]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 199 | #self.assertIn(json.loads(listimagesdetailsresponse.content)["images"][2]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 200 | self.assertEqual(json.loads(listimagesdetailsresponse.content)["images"][0]["metadata"]["architecture"],"x86_64") |
| 201 | print(" ") |
| 202 | |
| 203 | print('->>>>>>> test Nova List Image By Id ->>>>>>>>>>>>>>>') |
| 204 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 205 | url = "http://0.0.0.0:18774/v2.1/id_bla/images/%s" % (json.loads(listimagesdetailsresponse.content)["images"][0]["id"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 206 | listimagebyidresponse = requests.get(url, headers=headers) |
| 207 | self.assertEqual(listimagebyidresponse.status_code, 200) |
| 208 | self.assertEqual(json.loads(listimagebyidresponse.content)["image"]["id"],json.loads(listimagesdetailsresponse.content)["images"][0]["id"]) |
| 209 | print(" ") |
| 210 | |
| 211 | print('->>>>>>> test Nova List Image By Non-Existend Id ->>>>>>>>>>>>>>>') |
| 212 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 213 | url = "http://0.0.0.0:18774/v2.1/id_bla/images/non_existing_id" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 214 | listimagebynonexistingidresponse = requests.get(url, headers=headers) |
| 215 | self.assertEqual(listimagebynonexistingidresponse.status_code, 404) |
| 216 | print(" ") |
| 217 | |
| 218 | #find ubuntu id |
| 219 | for image in json.loads(listimagesresponse.content)["images"]: |
| 220 | if image["name"] == "ubuntu:trusty": |
| 221 | ubuntu_image_id = image["id"] |
| 222 | |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 223 | print('->>>>>>> test Nova Create Server Instance ->>>>>>>>>>>>>>>') |
| 224 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 225 | url = "http://0.0.0.0:18774/v2.1/id_bla/servers" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 226 | data = '{"server": {"name": "X", "flavorRef": "%s", "imageRef":"%s"}}' % (json.loads(listflavorsresponse.content)["flavors"][0]["id"], ubuntu_image_id) |
| 227 | createserverinstance = requests.post(url, data=data, headers=headers) |
| 228 | self.assertEqual(createserverinstance.status_code, 200) |
| 229 | self.assertEqual(json.loads(createserverinstance.content)["server"]["image"]["id"], ubuntu_image_id) |
| 230 | print(" ") |
| 231 | |
| 232 | print('->>>>>>> test Nova Create Server Instance With Already Existing Name ->>>>>>>>>>>>>>>') |
| 233 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 234 | url = "http://0.0.0.0:18774/v2.1/id_bla/servers" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 235 | data = '{"server": {"name": "X", "flavorRef": "%s", "imageRef":"%s"}}' % (json.loads(listflavorsresponse.content)["flavors"][0]["id"], ubuntu_image_id) |
| 236 | createserverinstance = requests.post(url, data=data, headers=headers) |
| 237 | self.assertEqual(createserverinstance.status_code, 409) |
| 238 | print(" ") |
| 239 | |
| 240 | print('->>>>>>> test Nova Version List Server APIs Detailed ->>>>>>>>>>>>>>>') |
| 241 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 242 | url = "http://0.0.0.0:18774/v2.1/id_bla/servers/detail" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 243 | listserverapisdetailedresponse = requests.get(url, headers=headers) |
| 244 | self.assertEqual(listserverapisdetailedresponse.status_code, 200) |
| 245 | self.assertEqual(json.loads(listserverapisdetailedresponse.content)["servers"][0]["status"], "ACTIVE") |
| 246 | print(" ") |
| 247 | |
| 248 | print('->>>>>>> test Nova Show Server Details ->>>>>>>>>>>>>>>') |
| 249 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 250 | url = "http://0.0.0.0:18774/v2.1/id_bla/servers/%s" % (json.loads(listserverapisdetailedresponse.content)["servers"][0]["id"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 251 | listserverdetailsresponse = requests.get(url, headers=headers) |
| 252 | self.assertEqual(listserverdetailsresponse.status_code, 200) |
| 253 | self.assertEqual(json.loads(listserverdetailsresponse.content)["server"]["flavor"]["links"][0]["rel"], "bookmark") |
| 254 | print(" ") |
| 255 | |
| 256 | print('->>>>>>> test Nova Show Non-Existing Server Details ->>>>>>>>>>>>>>>') |
| 257 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 258 | url = "http://0.0.0.0:18774/v2.1/id_bla/servers/non_existing_server_id" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 259 | listnonexistingserverdetailsresponse = requests.get(url, headers=headers) |
| 260 | self.assertEqual(listnonexistingserverdetailsresponse.status_code, 404) |
| 261 | print(" ") |
| 262 | |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 263 | def testNeutronDummy(self): |
| 264 | print('->>>>>>> test Neutron Dummy Class->>>>>>>>>>>>>>>') |
| 265 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 266 | print(" ") |
| 267 | |
| 268 | headers = {'Content-type': 'application/json'} |
| 269 | test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 270 | url = "http://0.0.0.0:18004/v1/tenantabc123/stacks" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 271 | requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), headers=headers) |
| 272 | # test_heatapi_keystone_get_token = open("test_heatapi_keystone_get_token.json").read() |
| 273 | |
| 274 | print('->>>>>>> test Neutron List Versions ->>>>>>>>>>>>>>>') |
| 275 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 276 | url = "http://0.0.0.0:19696/" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 277 | listapiversionstackresponse = requests.get(url, headers=headers) |
| 278 | self.assertEqual(listapiversionstackresponse.status_code, 200) |
| 279 | self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"][0]["id"], "v2.0") |
| 280 | print(" ") |
| 281 | |
| 282 | print('->>>>>>> test Neutron Show API v2.0 ->>>>>>>>>>>>>>>') |
| 283 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 284 | url = "http://0.0.0.0:19696/v2.0" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 285 | listapiversionv20response = requests.get(url, headers=headers) |
| 286 | self.assertEqual(listapiversionv20response.status_code, 200) |
| 287 | self.assertEqual(json.loads(listapiversionv20response.content)["resources"][0]["name"], "subnet") |
| 288 | self.assertEqual(json.loads(listapiversionv20response.content)["resources"][1]["name"], "network") |
| 289 | self.assertEqual(json.loads(listapiversionv20response.content)["resources"][2]["name"], "ports") |
| 290 | print(" ") |
| 291 | |
| 292 | print('->>>>>>> test Neutron List Networks ->>>>>>>>>>>>>>>') |
| 293 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 294 | url = "http://0.0.0.0:19696/v2.0/networks" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 295 | listnetworksesponse1 = requests.get(url, headers=headers) |
| 296 | self.assertEqual(listnetworksesponse1.status_code, 200) |
| 297 | self.assertEqual(json.loads(listnetworksesponse1.content)["networks"][0]["status"], "ACTIVE") |
| 298 | listNetworksId = json.loads(listnetworksesponse1.content)["networks"][0]["id"] |
| 299 | listNetworksName = json.loads(listnetworksesponse1.content)["networks"][0]["name"] |
| 300 | listNetworksId2 = json.loads(listnetworksesponse1.content)["networks"][1]["id"] |
| 301 | print(" ") |
| 302 | |
| 303 | print('->>>>>>> test Neutron List Non-Existing Networks ->>>>>>>>>>>>>>>') |
| 304 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 305 | url = "http://0.0.0.0:19696/v2.0/networks?name=non_existent_network_name" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 306 | listnetworksesponse2 = requests.get(url,headers=headers) |
| 307 | self.assertEqual(listnetworksesponse2.status_code, 404) |
| 308 | print(" ") |
| 309 | |
| 310 | print('->>>>>>> test Neutron List Networks By Name ->>>>>>>>>>>>>>>') |
| 311 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 312 | url = "http://0.0.0.0:19696/v2.0/networks?name=" + listNetworksName #tcpdump-vnf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 313 | listnetworksesponse3 = requests.get(url, headers=headers) |
| 314 | self.assertEqual(listnetworksesponse3.status_code, 200) |
| 315 | self.assertEqual(json.loads(listnetworksesponse3.content)["networks"][0]["name"], listNetworksName) |
| 316 | print(" ") |
| 317 | |
| 318 | print('->>>>>>> test Neutron List Networks By Id ->>>>>>>>>>>>>>>') |
| 319 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 320 | url = "http://0.0.0.0:19696/v2.0/networks?id=" + listNetworksId # tcpdump-vnf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 321 | listnetworksesponse4 = requests.get(url, headers=headers) |
| 322 | self.assertEqual(listnetworksesponse4.status_code, 200) |
| 323 | self.assertEqual(json.loads(listnetworksesponse4.content)["networks"][0]["id"], listNetworksId) |
| 324 | print(" ") |
| 325 | |
| 326 | print('->>>>>>> test Neutron List Networks By Multiple Ids ->>>>>>>>>>>>>>>') |
| 327 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 328 | url = "http://0.0.0.0:19696/v2.0/networks?id=" + listNetworksId + "&id="+ listNetworksId2 # tcpdump-vnf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 329 | listnetworksesponse5 = requests.get(url, headers=headers) |
| 330 | self.assertEqual(listnetworksesponse5.status_code, 200) |
| 331 | self.assertEqual(json.loads(listnetworksesponse5.content)["networks"][0]["id"], listNetworksId) |
| 332 | self.assertEqual(json.loads(listnetworksesponse5.content)["networks"][1]["id"], listNetworksId2) |
| 333 | print(" ") |
| 334 | |
| 335 | print('->>>>>>> test Neutron Show Network ->>>>>>>>>>>>>>>') |
| 336 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 337 | url = "http://0.0.0.0:19696/v2.0/networks/"+listNetworksId |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 338 | shownetworksesponse = requests.get(url, headers=headers) |
| 339 | self.assertEqual(shownetworksesponse.status_code, 200) |
| 340 | self.assertEqual(json.loads(shownetworksesponse.content)["network"]["status"], "ACTIVE") |
| 341 | print(" ") |
| 342 | |
| 343 | print('->>>>>>> test Neutron Show Network Non-ExistendNetwork ->>>>>>>>>>>>>>>') |
| 344 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 345 | url = "http://0.0.0.0:19696/v2.0/networks/non_existent_network_id" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 346 | shownetworksesponse2 = requests.get(url, headers=headers) |
| 347 | self.assertEqual(shownetworksesponse2.status_code, 404) |
| 348 | print(" ") |
| 349 | |
| 350 | print('->>>>>>> test Neutron Create Network ->>>>>>>>>>>>>>>') |
| 351 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 352 | url = "http://0.0.0.0:19696/v2.0/networks" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 353 | createnetworkresponse = requests.post(url, data='{"network": {"name": "sample_network","admin_state_up": true}}', headers=headers) |
| 354 | self.assertEqual(createnetworkresponse.status_code, 201) |
| 355 | self.assertEqual(json.loads(createnetworkresponse.content)["network"]["status"], "ACTIVE") |
| 356 | print(" ") |
| 357 | |
| 358 | print('->>>>>>> test Neutron Create Network With Existing Name ->>>>>>>>>>>>>>>') |
| 359 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 360 | url = "http://0.0.0.0:19696/v2.0/networks" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 361 | createnetworkresponsefailure = requests.post(url,data='{"network": {"name": "sample_network","admin_state_up": true}}',headers=headers) |
| 362 | self.assertEqual(createnetworkresponsefailure.status_code, 400) |
| 363 | print(" ") |
| 364 | |
| 365 | print('->>>>>>> test Neutron Update Network ->>>>>>>>>>>>>>>') |
| 366 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 367 | url = "http://0.0.0.0:19696/v2.0/networks/%s" % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 368 | updatenetworkresponse = requests.put(url, data='{"network": {"status": "ACTIVE", "admin_state_up":true, "tenant_id":"abcd123", "name": "sample_network_new_name", "shared":false}}' , headers=headers) |
| 369 | self.assertEqual(updatenetworkresponse.status_code, 200) |
| 370 | self.assertEqual(json.loads(updatenetworkresponse.content)["network"]["name"], "sample_network_new_name") |
| 371 | self.assertEqual(json.loads(updatenetworkresponse.content)["network"]["tenant_id"], "abcd123") |
| 372 | print(" ") |
| 373 | |
| 374 | print('->>>>>>> test Neutron Update Non-Existing Network ->>>>>>>>>>>>>>>') |
| 375 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 376 | url = "http://0.0.0.0:19696/v2.0/networks/non-existing-name123" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 377 | updatenetworkresponse = requests.put(url, data='{"network": {"name": "sample_network_new_name"}}', headers=headers) |
| 378 | self.assertEqual(updatenetworkresponse.status_code, 404) |
| 379 | print(" ") |
| 380 | |
| 381 | print('->>>>>>> test Neutron List Subnets ->>>>>>>>>>>>>>>') |
| 382 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 383 | url = "http://0.0.0.0:19696/v2.0/subnets" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 384 | listsubnetsresponse = requests.get(url, headers=headers) |
| 385 | listSubnetName = json.loads(listsubnetsresponse.content)["subnets"][0]["name"] |
| 386 | listSubnetId = json.loads(listsubnetsresponse.content)["subnets"][0]["id"] |
| 387 | listSubnetId2 = json.loads(listsubnetsresponse.content)["subnets"][1]["id"] |
| 388 | self.assertEqual(listsubnetsresponse.status_code, 200) |
| 389 | self.assertNotIn('None', listSubnetName) |
| 390 | print(" ") |
| 391 | |
| 392 | print('->>>>>>> test Neutron List Subnets By Name ->>>>>>>>>>>>>>>') |
| 393 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 394 | url = "http://0.0.0.0:19696/v2.0/subnets?name="+listSubnetName |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 395 | listsubnetByNameresponse = requests.get(url, headers=headers) |
| 396 | self.assertEqual(listsubnetByNameresponse.status_code, 200) |
| 397 | self.assertNotIn('None', json.loads(listsubnetByNameresponse.content)["subnets"][0]["name"]) |
| 398 | print(" ") |
| 399 | |
| 400 | print('->>>>>>> test Neutron List Subnets By Id ->>>>>>>>>>>>>>>') |
| 401 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 402 | url = "http://0.0.0.0:19696/v2.0/subnets?id=" + listSubnetId |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 403 | listsubnetsbyidresponse = requests.get(url, headers=headers) |
| 404 | self.assertEqual(listsubnetsbyidresponse.status_code, 200) |
| 405 | self.assertNotIn("None", json.loads(listsubnetsbyidresponse.content)["subnets"][0]["name"]) |
| 406 | print(" ") |
| 407 | |
| 408 | print('->>>>>>> test Neutron List Subnets By Multiple Id ->>>>>>>>>>>>>>>') |
| 409 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 410 | url = "http://0.0.0.0:19696/v2.0/subnets?id=" + listSubnetId +"&id="+listSubnetId2 |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 411 | listsubnetsbymultipleidsresponse = requests.get(url, headers=headers) |
| 412 | self.assertEqual(listsubnetsbymultipleidsresponse.status_code, 200) |
| 413 | self.assertNotIn("None", json.loads(listsubnetsbymultipleidsresponse.content)["subnets"][0]["name"]) |
| 414 | print(" ") |
| 415 | |
| 416 | |
| 417 | |
| 418 | print('->>>>>>> test Neutron Show Subnet->>>>>>>>>>>>>>>') |
| 419 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 420 | url = "http://0.0.0.0:19696/v2.0/subnets/%s" % (json.loads(listsubnetsresponse.content)["subnets"][0]["id"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 421 | showsubnetsresponse = requests.get(url, headers=headers) |
| 422 | self.assertEqual(showsubnetsresponse.status_code, 200) |
| 423 | self.assertNotIn("None", json.loads(showsubnetsresponse.content)["subnet"]["name"]) |
| 424 | print(" ") |
| 425 | |
| 426 | print('->>>>>>> test Neutron Show Non-Existing Subnet->>>>>>>>>>>>>>>') |
| 427 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 428 | url = "http://0.0.0.0:19696/v2.0/subnets/non-existing-id123" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 429 | showsubnetsresponse = requests.get(url, headers=headers) |
| 430 | self.assertEqual(showsubnetsresponse.status_code, 404) |
| 431 | print(" ") |
| 432 | |
| 433 | |
| 434 | print('->>>>>>> test Neutron Create Subnet ->>>>>>>>>>>>>>>') |
| 435 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 436 | url = "http://0.0.0.0:19696/v2.0/subnets" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 437 | createsubnetdata = '{"subnet": {"name": "new_subnet", "network_id": "%s","ip_version": 4,"cidr": "10.0.0.1/24"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 438 | createsubnetresponse = requests.post(url, data=createsubnetdata, headers=headers) |
| 439 | self.assertEqual(createsubnetresponse.status_code, 201) |
| 440 | self.assertEqual(json.loads(createsubnetresponse.content)["subnet"]["name"], "new_subnet") |
| 441 | print(" ") |
| 442 | |
| 443 | print('->>>>>>> test Neutron Create Second Subnet ->>>>>>>>>>>>>>>') |
| 444 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 445 | url = "http://0.0.0.0:19696/v2.0/subnets" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 446 | createsubnetdata = '{"subnet": {"name": "new_subnet", "network_id": "%s","ip_version": 4,"cidr": "10.0.0.1/24"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 447 | createsubnetfailureresponse = requests.post(url, data=createsubnetdata, headers=headers) |
| 448 | self.assertEqual(createsubnetfailureresponse.status_code, 409) |
| 449 | print(" ") |
| 450 | |
| 451 | print('->>>>>>> test Neutron Update Subnet ->>>>>>>>>>>>>>>') |
| 452 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 453 | url = "http://0.0.0.0:19696/v2.0/subnets/%s" % (json.loads(createsubnetresponse.content)["subnet"]["id"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 454 | updatesubnetdata = '{"subnet": {"name": "new_subnet_new_name", "network_id":"some_id", "tenant_id":"new_tenant_id", "allocation_pools":"change_me", "gateway_ip":"192.168.1.120", "ip_version":4, "cidr":"10.0.0.1/24", "id":"some_new_id", "enable_dhcp":true} }' |
| 455 | updatesubnetresponse = requests.put(url, data=updatesubnetdata, headers=headers) |
| 456 | self.assertEqual(updatesubnetresponse.status_code, 200) |
| 457 | self.assertEqual(json.loads(updatesubnetresponse.content)["subnet"]["name"], "new_subnet_new_name") |
| 458 | print(" ") |
| 459 | |
| 460 | print('->>>>>>> test Neutron Update Non-Existing Subnet ->>>>>>>>>>>>>>>') |
| 461 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 462 | url = "http://0.0.0.0:19696/v2.0/subnets/non-existing-subnet-12345" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 463 | updatenonexistingsubnetdata = '{"subnet": {"name": "new_subnet_new_name"} }' |
| 464 | updatenonexistingsubnetresponse = requests.put(url, data=updatenonexistingsubnetdata, headers=headers) |
| 465 | self.assertEqual(updatenonexistingsubnetresponse.status_code, 404) |
| 466 | print(" ") |
| 467 | |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 468 | print('->>>>>>> test Neutron List Ports ->>>>>>>>>>>>>>>') |
| 469 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 470 | url = "http://0.0.0.0:19696/v2.0/ports" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 471 | listportsesponse = requests.get(url, headers=headers) |
| 472 | self.assertEqual(listportsesponse.status_code, 200) |
| 473 | self.assertEqual(json.loads(listportsesponse.content)["ports"][0]["status"], "ACTIVE") |
| 474 | listPortsName = json.loads(listportsesponse.content)["ports"][0]["name"] |
| 475 | listPortsId1 = json.loads(listportsesponse.content)["ports"][0]["id"] |
| 476 | listPortsId2 = json.loads(listportsesponse.content)["ports"][1]["id"] |
| 477 | print(" ") |
| 478 | |
| 479 | print('->>>>>>> test Neutron List Ports By Name ->>>>>>>>>>>>>>>') |
| 480 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 481 | url = "http://0.0.0.0:19696/v2.0/ports?name=" + listPortsName |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 482 | listportsbynameesponse = requests.get(url, headers=headers) |
| 483 | self.assertEqual(listportsbynameesponse.status_code, 200) |
| 484 | self.assertEqual(json.loads(listportsbynameesponse.content)["ports"][0]["name"], listPortsName) |
| 485 | print(" ") |
| 486 | |
| 487 | print('->>>>>>> test Neutron List Ports By Id ->>>>>>>>>>>>>>>') |
| 488 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 489 | url = "http://0.0.0.0:19696/v2.0/ports?id=" + listPortsId1 |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 490 | listportsbyidesponse = requests.get(url, headers=headers) |
| 491 | self.assertEqual(listportsbyidesponse.status_code, 200) |
| 492 | self.assertEqual(json.loads(listportsbyidesponse.content)["ports"][0]["id"], listPortsId1) |
| 493 | print(" ") |
| 494 | |
| 495 | print('->>>>>>> test Neutron List Ports By Multiple Ids ->>>>>>>>>>>>>>>') |
| 496 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 497 | url = "http://0.0.0.0:19696/v2.0/ports?id=" + listPortsId1 +"&id="+listPortsId2 |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 498 | listportsbymultipleidsesponse = requests.get(url, headers=headers) |
| 499 | self.assertEqual(listportsbymultipleidsesponse.status_code, 200) |
| 500 | self.assertEqual(json.loads(listportsbymultipleidsesponse.content)["ports"][0]["id"], listPortsId1) |
| 501 | print(" ") |
| 502 | |
| 503 | print('->>>>>>> test Neutron List Non-Existing Ports ->>>>>>>>>>>>>>>') |
| 504 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 505 | url = "http://0.0.0.0:19696/v2.0/ports?id=non-existing-port-id" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 506 | listportsbynonexistingidsesponse = requests.get(url, headers=headers) |
| 507 | self.assertEqual(listportsbynonexistingidsesponse.status_code, 404) |
| 508 | print(" ") |
| 509 | |
| 510 | print('->>>>>>> test Neutron Show Port ->>>>>>>>>>>>>>>') |
| 511 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 512 | url = "http://0.0.0.0:19696/v2.0/ports/%s" % (json.loads(listportsesponse.content)["ports"][0]["id"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 513 | showportresponse = requests.get(url, headers=headers) |
| 514 | self.assertEqual(showportresponse.status_code, 200) |
| 515 | self.assertEqual(json.loads(showportresponse.content)["port"]["status"], "ACTIVE") |
| 516 | print(" ") |
| 517 | |
| 518 | print('->>>>>>> test Neutron Show Non-Existing Port ->>>>>>>>>>>>>>>') |
| 519 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 520 | url = "http://0.0.0.0:19696/v2.0/ports/non-existing-portid123" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 521 | shownonexistingportresponse = requests.get(url, headers=headers) |
| 522 | self.assertEqual(shownonexistingportresponse.status_code, 404) |
| 523 | print(" ") |
| 524 | |
| 525 | print('->>>>>>> test Neutron Create Port In Non-Existing Network ->>>>>>>>>>>>>>>') |
| 526 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 527 | url = "http://0.0.0.0:19696/v2.0/ports" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 528 | createnonexistingportdata = '{"port": {"name": "new_port", "network_id": "non-existing-id"} }' |
| 529 | createnonexistingnetworkportresponse = requests.post(url, data=createnonexistingportdata, headers=headers) |
| 530 | self.assertEqual(createnonexistingnetworkportresponse.status_code, 404) |
| 531 | print(" ") |
| 532 | |
| 533 | print('->>>>>>> test Neutron Create Port ->>>>>>>>>>>>>>>') |
| 534 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 535 | url = "http://0.0.0.0:19696/v2.0/ports" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 536 | createportdata = '{"port": {"name": "new_port", "network_id": "%s", "admin_state_up":true, "device_id":"device_id123", "device_owner":"device_owner123", "fixed_ips":"change_me","id":"new_id1234", "mac_address":"12:34:56:78:90", "status":"change_me", "tenant_id":"tenant_id123"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 537 | createportresponse = requests.post(url, data=createportdata, headers=headers) |
| 538 | self.assertEqual(createportresponse.status_code, 201) |
| 539 | print (createportresponse.content) |
| 540 | self.assertEqual(json.loads(createportresponse.content)["port"]["name"], "new_port") |
| 541 | print(" ") |
| 542 | |
| 543 | print('->>>>>>> test Neutron Create Port With Existing Name ->>>>>>>>>>>>>>>') |
| 544 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 545 | url = "http://0.0.0.0:19696/v2.0/ports" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 546 | createportwithexistingnamedata = '{"port": {"name": "new_port", "network_id": "%s"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 547 | createportwithexistingnameresponse = requests.post(url, data=createportwithexistingnamedata, headers=headers) |
| 548 | self.assertEqual(createportwithexistingnameresponse.status_code, 500) |
| 549 | print(" ") |
| 550 | |
| 551 | print('->>>>>>> test Neutron Create Port Without Name ->>>>>>>>>>>>>>>') |
| 552 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 553 | url = "http://0.0.0.0:19696/v2.0/ports" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 554 | createportdatawithoutname = '{"port": {"network_id": "%s"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 555 | createportwithoutnameresponse = requests.post(url, data=createportdatawithoutname, headers=headers) |
| 556 | self.assertEqual(createportwithoutnameresponse.status_code, 201) |
| 557 | self.assertIn("port:cp", json.loads(createportwithoutnameresponse.content)["port"]["name"]) |
| 558 | print(" ") |
| 559 | |
| 560 | print('->>>>>>> test Neutron Update Port ->>>>>>>>>>>>>>>') |
| 561 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 562 | print(json.loads(createportresponse.content)["port"]["name"]) |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 563 | url = "http://0.0.0.0:19696/v2.0/ports/%s" % (json.loads(createportresponse.content)["port"]["name"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 564 | updateportdata = '{"port": {"name": "new_port_new_name", "admin_state_up":true, "device_id":"device_id123", "device_owner":"device_owner123", "fixed_ips":"change_me","mac_address":"12:34:56:78:90", "status":"change_me", "tenant_id":"tenant_id123", "network_id":"network_id123"} }' |
| 565 | updateportresponse = requests.put(url, data=updateportdata, headers=headers) |
| 566 | self.assertEqual(updateportresponse.status_code, 200) |
| 567 | self.assertEqual(json.loads(updateportresponse.content)["port"]["name"], "new_port_new_name") |
| 568 | print(" ") |
| 569 | |
| 570 | print('->>>>>>> test Neutron Update Non-Existing Port ->>>>>>>>>>>>>>>') |
| 571 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 572 | url = "http://0.0.0.0:19696/v2.0/ports/non-existing-port-ip" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 573 | updatenonexistingportdata = '{"port": {"name": "new_port_new_name"} }' |
| 574 | updatenonexistingportresponse = requests.put(url, data=updatenonexistingportdata, headers=headers) |
| 575 | self.assertEqual(updatenonexistingportresponse.status_code, 404) |
| 576 | print(" ") |
| 577 | |
| 578 | print('->>>>>>> test Neutron Delete Port ->>>>>>>>>>>>>>>') |
| 579 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 580 | righturl = "http://0.0.0.0:19696/v2.0/ports/%s" % (json.loads(createportresponse.content)["port"]["id"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 581 | deleterightportresponse = requests.delete(righturl, headers=headers) |
| 582 | self.assertEqual(deleterightportresponse.status_code, 204) |
| 583 | print(" ") |
| 584 | |
| 585 | |
| 586 | print('->>>>>>> test Neutron Delete Non-Existing Port ->>>>>>>>>>>>>>>') |
| 587 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 588 | wrongurl = "http://0.0.0.0:19696/v2.0/ports/unknownid" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 589 | deletewrongportresponse = requests.delete(wrongurl, headers=headers) |
| 590 | self.assertEqual(deletewrongportresponse.status_code, 404) |
| 591 | print(" ") |
| 592 | |
| 593 | print('->>>>>>> test Neutron Delete Subnet ->>>>>>>>>>>>>>>') |
| 594 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 595 | wrongurl = "http://0.0.0.0:19696/v2.0/subnets/unknownid" |
| 596 | righturl = "http://0.0.0.0:19696/v2.0/subnets/%s" % (json.loads(updatesubnetresponse.content)["subnet"]["id"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 597 | deletewrongsubnetresponse = requests.delete(wrongurl, headers=headers) |
| 598 | deleterightsubnetresponse = requests.delete(righturl, headers=headers) |
| 599 | self.assertEqual(deletewrongsubnetresponse.status_code, 404) |
| 600 | self.assertEqual(deleterightsubnetresponse.status_code, 204) |
| 601 | print(" ") |
| 602 | |
| 603 | print('->>>>>>> test Neutron Delete Network ->>>>>>>>>>>>>>>') |
| 604 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 605 | righturl = "http://0.0.0.0:19696/v2.0/networks/%s" % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 606 | deleterightnetworkresponse = requests.delete(righturl, headers=headers) |
| 607 | self.assertEqual(deleterightnetworkresponse.status_code, 204) |
| 608 | print(" ") |
| 609 | |
| 610 | print('->>>>>>> test Neutron Delete Non-Existing Network ->>>>>>>>>>>>>>>') |
| 611 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 612 | wrongurl = "http://0.0.0.0:19696/v2.0/networks/unknownid" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 613 | deletewrongnetworkresponse = requests.delete(wrongurl, headers=headers) |
| 614 | self.assertEqual(deletewrongnetworkresponse.status_code, 404) |
| 615 | print(" ") |
| 616 | |
| 617 | def testKeystomeDummy(self): |
| 618 | print('->>>>>>> test Keystone Dummy Class->>>>>>>>>>>>>>>') |
| 619 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 620 | print(" ") |
| 621 | |
| 622 | headers = {'Content-type': 'application/json'} |
| 623 | test_heatapi_keystone_get_token = open(os.path.join(os.path.dirname(__file__), "test_heatapi_keystone_get_token.json")).read() |
| 624 | |
| 625 | print('->>>>>>> test Keystone List Versions ->>>>>>>>>>>>>>>') |
| 626 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 627 | url = "http://0.0.0.0:15000/" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 628 | listapiversionstackresponse = requests.get(url, headers=headers) |
| 629 | self.assertEqual(listapiversionstackresponse.status_code, 200) |
| 630 | self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"]["values"][0]["id"], "v2.0") |
| 631 | print(" ") |
| 632 | |
| 633 | print('->>>>>>> test Keystone Show ApiV2 ->>>>>>>>>>>>>>>') |
| 634 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 635 | url = "http://0.0.0.0:15000/v2.0" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 636 | showapiversionstackresponse = requests.get(url, headers=headers) |
| 637 | self.assertEqual(showapiversionstackresponse.status_code, 200) |
| 638 | self.assertEqual(json.loads(showapiversionstackresponse.content)["version"]["id"], "v2.0") |
| 639 | print(" ") |
| 640 | |
| 641 | print('->>>>>>> test Keystone Get Token ->>>>>>>>>>>>>>>') |
| 642 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 643 | url = "http://0.0.0.0:15000/v2.0/tokens" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 644 | gettokenstackresponse = requests.post(url, data=json.dumps(json.loads(test_heatapi_keystone_get_token)), headers=headers) |
| 645 | self.assertEqual(gettokenstackresponse.status_code, 200) |
| 646 | self.assertEqual(json.loads(gettokenstackresponse.content)["access"]["user"]["name"], "tenantName") |
| 647 | print(" ") |
| 648 | |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 649 | def testHeatDummy(self): |
| 650 | print('->>>>>>> test Heat Dummy Class->>>>>>>>>>>>>>>') |
| 651 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 652 | print(" ") |
| 653 | |
| 654 | headers = {'Content-type': 'application/json'} |
| 655 | test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() |
| 656 | test_heatapi_template_update_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_update_stack.json")).read() |
| 657 | |
| 658 | print('->>>>>>> test Heat List API Versions Stack ->>>>>>>>>>>>>>>') |
| 659 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 660 | url = "http://0.0.0.0:18004/" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 661 | listapiversionstackresponse = requests.get(url, headers=headers) |
| 662 | self.assertEqual(listapiversionstackresponse.status_code, 200) |
| 663 | self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"][0]["id"], "v1.0") |
| 664 | print(" ") |
| 665 | |
| 666 | print('->>>>>>> test Create Stack ->>>>>>>>>>>>>>>') |
| 667 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 668 | url = "http://0.0.0.0:18004/v1/tenantabc123/stacks" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 669 | createstackresponse = requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), headers=headers) |
| 670 | self.assertEqual(createstackresponse.status_code, 201) |
| 671 | self.assertNotEqual(json.loads(createstackresponse.content)["stack"]["id"], "") |
| 672 | print(" ") |
| 673 | |
| 674 | print('->>>>>>> test Create Stack With Existing Name ->>>>>>>>>>>>>>>') |
| 675 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 676 | url = "http://0.0.0.0:18004/v1/tenantabc123/stacks" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 677 | createstackwithexistingnameresponse = requests.post(url, data='{"stack_name" : "s1"}', headers=headers) |
| 678 | self.assertEqual(createstackwithexistingnameresponse.status_code, 409) |
| 679 | print(" ") |
| 680 | |
| 681 | print('->>>>>>> test Create Stack With Unsupported Version ->>>>>>>>>>>>>>>') |
| 682 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 683 | url = "http://0.0.0.0:18004/v1/tenantabc123/stacks" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 684 | createstackwitheunsupportedversionresponse = requests.post(url, data='{"stack_name" : "stackname123", "template" : {"heat_template_version": "2015-04-29"}}', headers=headers) |
| 685 | self.assertEqual(createstackwitheunsupportedversionresponse.status_code, 400) |
| 686 | print(" ") |
| 687 | |
| 688 | |
| 689 | print('->>>>>>> test List Stack ->>>>>>>>>>>>>>>') |
| 690 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 691 | url = "http://0.0.0.0:18004/v1/tenantabc123/stacks" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 692 | liststackresponse = requests.get(url, headers=headers) |
| 693 | self.assertEqual(liststackresponse.status_code, 200) |
| 694 | self.assertEqual(json.loads(liststackresponse.content)["stacks"][0]["stack_status"], "CREATE_COMPLETE") |
| 695 | print(" ") |
| 696 | |
| 697 | |
| 698 | print('->>>>>>> test Show Stack ->>>>>>>>>>>>>>>') |
| 699 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 700 | url = "http://0.0.0.0:18004/v1/tenantabc123showStack/stacks/%s"% json.loads(createstackresponse.content)['stack']['id'] |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 701 | liststackdetailsresponse = requests.get(url, headers=headers) |
| 702 | self.assertEqual(liststackdetailsresponse.status_code, 200) |
| 703 | self.assertEqual(json.loads(liststackdetailsresponse.content)["stack"]["stack_status"], "CREATE_COMPLETE") |
| 704 | print(" ") |
| 705 | |
| 706 | print('->>>>>>> test Show Non-Exisitng Stack ->>>>>>>>>>>>>>>') |
| 707 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 708 | url = "http://0.0.0.0:18004/v1/tenantabc123showStack/stacks/non_exisitng_id123" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 709 | listnonexistingstackdetailsresponse = requests.get(url, headers=headers) |
| 710 | self.assertEqual(listnonexistingstackdetailsresponse.status_code, 404) |
| 711 | print(" ") |
| 712 | |
| 713 | print('->>>>>>> test Update Stack ->>>>>>>>>>>>>>>') |
| 714 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 715 | url = "http://0.0.0.0:18004/v1/tenantabc123updateStack/stacks/%s"% json.loads(createstackresponse.content)['stack']['id'] |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 716 | updatestackresponse = requests.put(url, data=json.dumps(json.loads(test_heatapi_template_update_stack)), |
| 717 | headers=headers) |
| 718 | self.assertEqual(updatestackresponse.status_code, 202) |
| 719 | liststackdetailsresponse = requests.get(url, headers=headers) |
| 720 | self.assertEqual(json.loads(liststackdetailsresponse.content)["stack"]["stack_status"], "UPDATE_COMPLETE") |
| 721 | print(" ") |
| 722 | |
| 723 | print('->>>>>>> test Update Non-Existing Stack ->>>>>>>>>>>>>>>') |
| 724 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 725 | url = "http://0.0.0.0:18004/v1/tenantabc123updateStack/stacks/non_existing_id_1234" |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 726 | updatenonexistingstackresponse = requests.put(url, data={"non": "sense"}, headers=headers) |
| 727 | self.assertEqual(updatenonexistingstackresponse.status_code, 404) |
| 728 | print(" ") |
| 729 | |
| 730 | print('->>>>>>> test Delete Stack ->>>>>>>>>>>>>>>') |
| 731 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| peusterm | e22979a | 2017-05-18 13:28:38 +0200 | [diff] [blame] | 732 | url = "http://0.0.0.0:18004/v1/tenantabc123showStack/stacks/%s" % \ |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 733 | json.loads(createstackresponse.content)['stack']['id'] |
| 734 | deletestackdetailsresponse = requests.delete(url, headers=headers) |
| 735 | self.assertEqual(deletestackdetailsresponse.status_code, 204) |
| 736 | print(" ") |
| 737 | |
| splietker | 7b38ee1 | 2017-06-28 17:24:01 +0200 | [diff] [blame] | 738 | def testNeutronSFC(self): |
| 739 | """ |
| 740 | Tests the Neutron Service Function Chaining implementation. As Some functions build up on others, a |
| 741 | complete environment is created here: |
| 742 | |
| 743 | Ports: p1, p2, p3, p4 |
| 744 | Port Pairs: pp1(p1, p2), pp2(p3, p4) |
| 745 | Port Pair Groups: ppg1(pp1, pp2) |
| 746 | Flow Classifiers: fc1 |
| 747 | Port Chain: pc1(ppg1, fc1) |
| 748 | """ |
| 749 | |
| 750 | headers = {'Content-type': 'application/json'} |
| 751 | |
| 752 | print('->>>>>>> Create ports p1 - p4 ->>>>>>>>>>>>>>>') |
| 753 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 754 | # Get network id |
| 755 | network_resp = requests.get("http://0.0.0.0:19696/v2.0/networks?name=default", headers=headers) |
| 756 | self.assertEqual(network_resp.status_code, 200) |
| 757 | network_id = json.loads(network_resp.content)["networks"][0]["id"] |
| 758 | |
| 759 | url = "http://0.0.0.0:19696/v2.0/ports" |
| 760 | port_request = '{"port": {"name": "%s", "network_id": "%s"}}' |
| 761 | p1_resp = requests.post(url, data=port_request % ("p1", network_id), headers=headers) |
| 762 | self.assertEqual(p1_resp.status_code, 201) |
| 763 | p2_resp = requests.post(url, data=port_request % ("p2", network_id), headers=headers) |
| 764 | self.assertEqual(p2_resp.status_code, 201) |
| 765 | p3_resp = requests.post(url, data=port_request % ("p3", network_id), headers=headers) |
| 766 | self.assertEqual(p3_resp.status_code, 201) |
| 767 | p4_resp = requests.post(url, data=port_request % ("p4", network_id), headers=headers) |
| 768 | self.assertEqual(p4_resp.status_code, 201) |
| 769 | |
| 770 | p1_id = json.loads(p1_resp.content)["port"]["id"] |
| 771 | p2_id = json.loads(p2_resp.content)["port"]["id"] |
| 772 | p3_id = json.loads(p3_resp.content)["port"]["id"] |
| 773 | p4_id = json.loads(p4_resp.content)["port"]["id"] |
| 774 | |
| 775 | print('->>>>>>> test Neutron SFC Port Pair Create ->>>>>>>>>>>>>>>') |
| 776 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 777 | url = "http://0.0.0.0:19696/v2.0/sfc/port_pairs" |
| 778 | pp1_resp = requests.post(url, data='{"port_pair": {"name": "pp1", "ingress": "%s", "egress": "%s"}}' % (p1_id, p2_id), headers=headers) |
| 779 | self.assertEqual(pp1_resp.status_code, 201) |
| 780 | pp2_resp = requests.post(url, data='{"port_pair": {"name": "pp2", "ingress": "%s", "egress": "%s"}}' % (p3_id, p4_id), headers=headers) |
| 781 | self.assertEqual(pp2_resp.status_code, 201) |
| 782 | pp3_resp = requests.post(url, data='{"port_pair": {"name": "pp3", "ingress": "%s", "egress": "%s"}}' % (p3_id, p4_id), headers=headers) |
| 783 | self.assertEqual(pp3_resp.status_code, 201) |
| 784 | |
| 785 | pp1_id = json.loads(pp1_resp.content)["port_pair"]["id"] |
| 786 | pp2_id = json.loads(pp2_resp.content)["port_pair"]["id"] |
| 787 | pp3_id = json.loads(pp3_resp.content)["port_pair"]["id"] |
| 788 | |
| 789 | print('->>>>>>> test Neutron SFC Port Pair Update ->>>>>>>>>>>>>>>') |
| 790 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 791 | url = "http://0.0.0.0:19696/v2.0/sfc/port_pairs/%s" % pp3_id |
| 792 | pp3_update_resp = requests.put(url, data='{"port_pair": {"description": "port_pair_update"}}', headers=headers) |
| 793 | self.assertEqual(pp3_update_resp.status_code, 200) |
| 794 | self.assertEqual(json.loads(pp3_update_resp.content)["port_pair"]["description"], "port_pair_update") |
| 795 | |
| 796 | print('->>>>>>> test Neutron SFC Port Pair Delete ->>>>>>>>>>>>>>>') |
| 797 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 798 | url = "http://0.0.0.0:19696/v2.0/sfc/port_pairs/%s" % pp3_id |
| 799 | pp3_delete_resp = requests.delete(url, headers=headers) |
| 800 | self.assertEqual(pp3_delete_resp.status_code, 204) |
| 801 | |
| 802 | print('->>>>>>> test Neutron SFC Port Pair List ->>>>>>>>>>>>>>>') |
| 803 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 804 | url = "http://0.0.0.0:19696/v2.0/sfc/port_pairs" |
| 805 | pp_list_resp = requests.get(url, headers=headers) |
| 806 | self.assertEqual(pp_list_resp.status_code, 200) |
| 807 | self.assertEqual(len(json.loads(pp_list_resp.content)["port_pairs"]), 2) # only pp1 and pp2 should be left |
| 808 | |
| 809 | print('->>>>>>> test Neutron SFC Port Pair Show ->>>>>>>>>>>>>>>') |
| 810 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 811 | url = "http://0.0.0.0:19696/v2.0/sfc/port_pairs/%s" % pp2_id |
| 812 | pp2_show_resp = requests.get(url, headers=headers) |
| 813 | self.assertEqual(pp2_show_resp.status_code, 200) |
| 814 | self.assertEqual(json.loads(pp2_show_resp.content)["port_pair"]["name"], "pp2") |
| 815 | |
| 816 | |
| 817 | print('->>>>>>> test Neutron SFC Port Pair Group Create ->>>>>>>>>>>>>>>') |
| 818 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 819 | url = "http://0.0.0.0:19696/v2.0/sfc/port_pair_groups" |
| 820 | ppg1_resp = requests.post(url, data='{"port_pair_group": {"name": "ppg1", "port_pairs": ["%s"]}}' % (pp1_id), headers=headers) |
| 821 | self.assertEqual(ppg1_resp.status_code, 201) |
| 822 | ppg2_resp = requests.post(url, data='{"port_pair_group": {"name": "ppg2", "port_pairs": ["%s"]}}' % (pp2_id), headers=headers) |
| 823 | self.assertEqual(ppg2_resp.status_code, 201) |
| 824 | ppg3_resp = requests.post(url, data='{"port_pair_group": {"name": "ppg3", "port_pairs": ["%s"]}}' % (pp2_id), headers=headers) |
| 825 | self.assertEqual(ppg3_resp.status_code, 201) |
| 826 | |
| 827 | ppg1_id = json.loads(ppg1_resp.content)["port_pair_group"]["id"] |
| 828 | ppg2_id = json.loads(ppg2_resp.content)["port_pair_group"]["id"] |
| 829 | ppg3_id = json.loads(ppg3_resp.content)["port_pair_group"]["id"] |
| 830 | |
| 831 | print('->>>>>>> test Neutron SFC Port Pair Group Update ->>>>>>>>>>>>>>>') |
| 832 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 833 | url = "http://0.0.0.0:19696/v2.0/sfc/port_pair_groups/%s" % ppg3_id |
| 834 | ppg3_update_resp = requests.put(url, data='{"port_pair_group": {"description": "port_pair_group_update"}}', headers=headers) |
| 835 | self.assertEqual(ppg3_update_resp.status_code, 200) |
| 836 | self.assertEqual(json.loads(ppg3_update_resp.content)["port_pair_group"]["description"], "port_pair_group_update") |
| 837 | |
| 838 | print('->>>>>>> test Neutron SFC Port Pair Group Delete ->>>>>>>>>>>>>>>') |
| 839 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 840 | url = "http://0.0.0.0:19696/v2.0/sfc/port_pair_groups/%s" % ppg3_id |
| 841 | ppg3_delete_resp = requests.delete(url, headers=headers) |
| 842 | self.assertEqual(ppg3_delete_resp.status_code, 204) |
| 843 | |
| 844 | print('->>>>>>> test Neutron SFC Port Pair Group List ->>>>>>>>>>>>>>>') |
| 845 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 846 | url = "http://0.0.0.0:19696/v2.0/sfc/port_pair_groups" |
| 847 | ppg_list_resp = requests.get(url, headers=headers) |
| 848 | self.assertEqual(ppg_list_resp.status_code, 200) |
| 849 | self.assertEqual(len(json.loads(ppg_list_resp.content)["port_pair_groups"]), 2) # only ppg1 and ppg2 should be left |
| 850 | |
| 851 | print('->>>>>>> test Neutron SFC Port Pair Group Show ->>>>>>>>>>>>>>>') |
| 852 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 853 | url = "http://0.0.0.0:19696/v2.0/sfc/port_pair_groups/%s" % ppg2_id |
| 854 | ppg2_show_resp = requests.get(url, headers=headers) |
| 855 | self.assertEqual(ppg2_show_resp.status_code, 200) |
| 856 | self.assertEqual(json.loads(ppg2_show_resp.content)["port_pair_group"]["name"], "ppg2") |
| 857 | |
| splietker | 7b38ee1 | 2017-06-28 17:24:01 +0200 | [diff] [blame] | 858 | print('->>>>>>> test Neutron SFC Flow Classifier Create ->>>>>>>>>>>>>>>') |
| 859 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 860 | url = "http://0.0.0.0:19696/v2.0/sfc/flow_classifiers" |
| 861 | fc1_resp = requests.post(url, data='{"flow_classifier": {"name": "fc1", "source_port_range_min": 22, "source_port_range_max": 4000}}', headers=headers) |
| 862 | self.assertEqual(fc1_resp.status_code, 201) |
| 863 | fc2_resp = requests.post(url, data='{"flow_classifier": {"name": "fc2", "source_port_range_min": 22, "source_port_range_max": 4000}}', headers=headers) |
| 864 | self.assertEqual(fc2_resp.status_code, 201) |
| 865 | |
| 866 | fc1_id = json.loads(fc1_resp.content)["flow_classifier"]["id"] |
| 867 | fc2_id = json.loads(fc2_resp.content)["flow_classifier"]["id"] |
| 868 | |
| 869 | print('->>>>>>> test Neutron SFC Flow Classifier Update ->>>>>>>>>>>>>>>') |
| 870 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 871 | url = "http://0.0.0.0:19696/v2.0/sfc/flow_classifiers/%s" % fc2_id |
| 872 | fc2_update_resp = requests.put(url, data='{"flow_classifier": {"description": "flow_classifier_update"}}', headers=headers) |
| 873 | self.assertEqual(fc2_update_resp.status_code, 200) |
| 874 | self.assertEqual(json.loads(fc2_update_resp.content)["flow_classifier"]["description"], "flow_classifier_update") |
| 875 | |
| 876 | print('->>>>>>> test Neutron SFC Flow Classifier Delete ->>>>>>>>>>>>>>>') |
| 877 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 878 | url = "http://0.0.0.0:19696/v2.0/sfc/flow_classifiers/%s" % fc2_id |
| 879 | fc2_delete_resp = requests.delete(url, headers=headers) |
| 880 | self.assertEqual(fc2_delete_resp.status_code, 204) |
| 881 | |
| 882 | print('->>>>>>> test Neutron SFC Flow Classifier List ->>>>>>>>>>>>>>>') |
| 883 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 884 | url = "http://0.0.0.0:19696/v2.0/sfc/flow_classifiers" |
| 885 | fc_list_resp = requests.get(url, headers=headers) |
| 886 | self.assertEqual(fc_list_resp.status_code, 200) |
| 887 | self.assertEqual(len(json.loads(fc_list_resp.content)["flow_classifiers"]), 1) # only fc1 |
| 888 | |
| 889 | print('->>>>>>> test Neutron SFC Flow Classifier Show ->>>>>>>>>>>>>>>') |
| 890 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 891 | url = "http://0.0.0.0:19696/v2.0/sfc/flow_classifiers/%s" % fc1_id |
| 892 | fc1_show_resp = requests.get(url, headers=headers) |
| 893 | self.assertEqual(fc1_show_resp.status_code, 200) |
| 894 | self.assertEqual(json.loads(fc1_show_resp.content)["flow_classifier"]["name"], "fc1") |
| 895 | |
| 896 | |
| 897 | print('->>>>>>> test Neutron SFC Port Chain Create ->>>>>>>>>>>>>>>') |
| 898 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 899 | url = "http://0.0.0.0:19696/v2.0/sfc/port_chains" |
| 900 | pc1_resp = requests.post(url, data='{"port_chain": {"name": "pc1", "port_pair_groups": ["%s"], "flow_classifiers": ["%s"]}}' % (ppg1_id, fc1_id), headers=headers) |
| 901 | self.assertEqual(pc1_resp.status_code, 201) |
| 902 | pc2_resp = requests.post(url, data='{"port_chain": {"name": "pc2", "port_pair_groups": ["%s"], "flow_classifiers": ["%s"]}}' % (ppg1_id, fc1_id), headers=headers) |
| 903 | self.assertEqual(pc2_resp.status_code, 201) |
| 904 | |
| 905 | pc1_id = json.loads(pc1_resp.content)["port_chain"]["id"] |
| 906 | pc2_id = json.loads(pc2_resp.content)["port_chain"]["id"] |
| 907 | |
| 908 | print('->>>>>>> test Neutron SFC Port Chain Update ->>>>>>>>>>>>>>>') |
| 909 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 910 | url = "http://0.0.0.0:19696/v2.0/sfc/port_chains/%s" % pc2_id |
| 911 | pc2_update_resp = requests.put(url, data='{"port_chain": {"description": "port_chain_update"}}', headers=headers) |
| 912 | self.assertEqual(pc2_update_resp.status_code, 200) |
| 913 | self.assertEqual(json.loads(pc2_update_resp.content)["port_chain"]["description"], "port_chain_update") |
| 914 | |
| 915 | print('->>>>>>> test Neutron SFC Port Chain Delete ->>>>>>>>>>>>>>>') |
| 916 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 917 | url = "http://0.0.0.0:19696/v2.0/sfc/port_chains/%s" % pc2_id |
| 918 | pc2_delete_resp = requests.delete(url, headers=headers) |
| 919 | self.assertEqual(pc2_delete_resp.status_code, 204) |
| 920 | |
| 921 | print('->>>>>>> test Neutron SFC Port Chain List ->>>>>>>>>>>>>>>') |
| 922 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 923 | url = "http://0.0.0.0:19696/v2.0/sfc/port_chains" |
| 924 | pc_list_resp = requests.get(url, headers=headers) |
| 925 | self.assertEqual(pc_list_resp.status_code, 200) |
| 926 | self.assertEqual(len(json.loads(pc_list_resp.content)["port_chains"]), 1) # only pc1 |
| 927 | |
| 928 | print('->>>>>>> test Neutron SFC Port Chain Show ->>>>>>>>>>>>>>>') |
| 929 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 930 | url = "http://0.0.0.0:19696/v2.0/sfc/port_chains/%s" % pc1_id |
| 931 | pc1_show_resp = requests.get(url, headers=headers) |
| 932 | self.assertEqual(pc1_show_resp.status_code, 200) |
| 933 | self.assertEqual(json.loads(pc1_show_resp.content)["port_chain"]["name"], "pc1") |
| peusterm | f27a592 | 2017-05-17 08:48:54 +0200 | [diff] [blame] | 934 | |
| 935 | if __name__ == '__main__': |
| 936 | unittest.main() |