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