| 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 |
| 37 | |
| 38 | from emuvim.test.api_base_openstack import ApiBaseOpenStack |
| 39 | |
| 40 | |
| 41 | class testRestApi(ApiBaseOpenStack): |
| 42 | """ |
| 43 | Tests to check the REST API endpoints of the emulator. |
| 44 | """ |
| 45 | |
| 46 | def setUp(self): |
| 47 | # create network |
| 48 | self.createNet(nswitches=3, ndatacenter=2, nhosts=2, ndockers=0, autolinkswitches=True) |
| 49 | |
| 50 | # setup links |
| 51 | self.net.addLink(self.dc[0], self.h[0]) |
| 52 | self.net.addLink(self.h[1], self.dc[1]) |
| 53 | self.net.addLink(self.dc[0], self.dc[1]) |
| 54 | |
| 55 | # start api |
| 56 | self.startApi() |
| 57 | |
| 58 | # start Mininet network |
| 59 | self.startNet() |
| 60 | |
| 61 | @unittest.skip("temporarily disabled") |
| 62 | def testChainingDummy(self): |
| 63 | print('->>>>>>> test Chaining 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_chaining.json")).read() |
| 69 | url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" |
| 70 | requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), headers=headers) |
| 71 | |
| 72 | |
| 73 | print('->>>>>>> test Chaining Versions ->>>>>>>>>>>>>>>') |
| 74 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 75 | url = "http://0.0.0.0:4000/" |
| 76 | listapiversionstackresponse = requests.get(url, headers=headers) |
| 77 | self.assertEqual(listapiversionstackresponse.status_code, 200) |
| 78 | self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"][0]["id"], "v1") |
| 79 | print(" ") |
| 80 | |
| 81 | print('->>>>>>> test Chaining List ->>>>>>>>>>>>>>>') |
| 82 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 83 | url = "http://0.0.0.0:4000/v1/chain/list" |
| 84 | chainlistresponse = requests.get(url, headers=headers) |
| 85 | self.assertEqual(chainlistresponse.status_code, 200) |
| 86 | self.assertEqual(json.loads(chainlistresponse.content)["chains"], []) |
| 87 | print(" ") |
| 88 | |
| 89 | print('->>>>>>> test Loadbalancing List ->>>>>>>>>>>>>>>') |
| 90 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 91 | url = "http://0.0.0.0:4000/v1/lb/list" |
| 92 | lblistresponse = requests.get(url, headers=headers) |
| 93 | self.assertEqual(lblistresponse.status_code, 200) |
| 94 | self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"], []) |
| 95 | print(" ") |
| 96 | |
| 97 | testchain = "dc0_s1_firewall1/fire-out-0/dc0_s1_iperf1/iper-in-0" |
| 98 | print('->>>>>>> test Chain VNF Interfaces ->>>>>>>>>>>>>>>') |
| 99 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 100 | url = "http://0.0.0.0:4000/v1/chain/%s" %(testchain) |
| 101 | chainvnfresponse = requests.put(url) |
| 102 | self.assertEqual(chainvnfresponse.status_code, 200) |
| 103 | self.assertGreaterEqual(json.loads(chainvnfresponse.content)["cookie"], 0) |
| 104 | print(" ") |
| 105 | |
| 106 | print('->>>>>>> test Chaining List ->>>>>>>>>>>>>>>') |
| 107 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 108 | url = "http://0.0.0.0:4000/v1/chain/list" |
| 109 | chainlistresponse = requests.get(url, headers=headers) |
| 110 | self.assertEqual(chainlistresponse.status_code, 200) |
| 111 | self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["dst_vnf"], "dc0_s1_firewall1") |
| 112 | self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["dst_intf"], "fire-out-0") |
| 113 | self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["src_vnf"], "dc0_s1_iperf1") |
| 114 | self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["src_intf"], "iper-in-0") |
| 115 | print(" ") |
| 116 | |
| 117 | print('->>>>>>> test Chain VNF Delete Chain ->>>>>>>>>>>>>>>') |
| 118 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 119 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 120 | deletechainvnfresponse = requests.delete(url) |
| 121 | self.assertEqual(deletechainvnfresponse.status_code, 200) |
| 122 | self.assertEqual(deletechainvnfresponse.content, "true") |
| 123 | print(" ") |
| 124 | |
| 125 | print('->>>>>>> test Chaining List If Empty Again ->>>>>>>>>>>>>>>') |
| 126 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 127 | url = "http://0.0.0.0:4000/v1/chain/list" |
| 128 | chainlistresponse = requests.get(url, headers=headers) |
| 129 | self.assertEqual(chainlistresponse.status_code, 200) |
| 130 | self.assertEqual(json.loads(chainlistresponse.content)["chains"], []) |
| 131 | print(" ") |
| 132 | |
| 133 | testchain = "dc0_s1_firewall1/fire-out-0/dc0_s1_iperf1/iper-in-0" |
| 134 | print('->>>>>>> test Stack Chain VNF Interfaces ->>>>>>>>>>>>>>>') |
| 135 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 136 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 137 | stackchainvnfresponse = requests.post(url, data=json.dumps(json.loads('{"path":["dc1.s1", "s1","s2","s3","s1","dc1.s1"]}')), headers=headers) |
| 138 | self.assertEqual(stackchainvnfresponse.status_code, 200) |
| 139 | print (stackchainvnfresponse.content) |
| 140 | self.assertGreaterEqual(json.loads(stackchainvnfresponse.content)["cookie"], 0) |
| 141 | print(" ") |
| 142 | |
| 143 | |
| 144 | print('->>>>>>> test Stack Chaining List ->>>>>>>>>>>>>>>') |
| 145 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 146 | url = "http://0.0.0.0:4000/v1/chain/list" |
| 147 | chainlistresponse = requests.get(url, headers=headers) |
| 148 | self.assertEqual(chainlistresponse.status_code, 200) |
| 149 | print (chainlistresponse.content) |
| 150 | self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["dst_vnf"], "dc0_s1_firewall1") |
| 151 | self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["dst_intf"], "fire-out-0") |
| 152 | self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["src_vnf"], "dc0_s1_iperf1") |
| 153 | self.assertEqual(json.loads(chainlistresponse.content)["chains"][0]["src_intf"], "iper-in-0") |
| 154 | self.assertItemsEqual(json.loads(chainlistresponse.content)["chains"][0]["path"],['dc1.s1', 's1', 's2', 's3', 's1', 'dc1.s1']) |
| 155 | print(" ") |
| 156 | |
| 157 | print('->>>>>>> test Chain VNF Delete Chain ->>>>>>>>>>>>>>>') |
| 158 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 159 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 160 | deletechainvnfresponse = requests.delete(url) |
| 161 | self.assertEqual(deletechainvnfresponse.status_code, 200) |
| 162 | self.assertEqual(deletechainvnfresponse.content, "true") |
| 163 | print(" ") |
| 164 | |
| 165 | print('->>>>>>> test Chaining List If Empty Again ->>>>>>>>>>>>>>>') |
| 166 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 167 | url = "http://0.0.0.0:4000/v1/chain/list" |
| 168 | chainlistresponse = requests.get(url, headers=headers) |
| 169 | self.assertEqual(chainlistresponse.status_code, 200) |
| 170 | self.assertEqual(json.loads(chainlistresponse.content)["chains"], []) |
| 171 | print(" ") |
| 172 | |
| 173 | |
| 174 | testchain = "dc0_s1_firewall1/non-existing-interface/dc0_s1_iperf1/iper-in-0" |
| 175 | print('->>>>>>> test Chain VNF Interfaces ->>>>>>>>>>>>>>>') |
| 176 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 177 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 178 | chainvnfresponse = requests.put(url) |
| 179 | self.assertEqual(chainvnfresponse.status_code, 501) |
| 180 | print(" ") |
| 181 | |
| 182 | testchain = "dc0_s1_firewall1/fire-out-0/dc0_s1_iperf1/non-existing-interface" |
| 183 | print('->>>>>>> test Chain VNF Interfaces ->>>>>>>>>>>>>>>') |
| 184 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 185 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 186 | chainvnfresponse = requests.put(url) |
| 187 | self.assertEqual(chainvnfresponse.status_code, 501) |
| 188 | print(" ") |
| 189 | |
| 190 | testchain = "dc0_s1_firewall1/non-existing-interface/dc0_s1_iperf1/iper-in-0" |
| 191 | print('->>>>>>> test Chain VNF Delete Chain ->>>>>>>>>>>>>>>') |
| 192 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 193 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 194 | deletechainvnfresponse = requests.delete(url) |
| 195 | self.assertEqual(deletechainvnfresponse.status_code, 501) |
| 196 | print(" ") |
| 197 | |
| 198 | testchain = "dc0_s1_firewall1/fire-out-0/dc0_s1_iperf1/non-existing-interface" |
| 199 | print('->>>>>>> test Chain VNF Delete Chain ->>>>>>>>>>>>>>>') |
| 200 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 201 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 202 | deletechainvnfresponse = requests.delete(url) |
| 203 | self.assertEqual(deletechainvnfresponse.status_code, 501) |
| 204 | print(" ") |
| 205 | |
| 206 | testchain = "non-existent-dc/s1/firewall1/firewall1:cp03:output/dc0/s1/iperf1/iperf1:cp02:input" |
| 207 | print('->>>>>>> test Chain VNF Non-Existing DC ->>>>>>>>>>>>>>>') |
| 208 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 209 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 210 | chainvnfresponse = requests.put(url) |
| 211 | self.assertEqual(chainvnfresponse.status_code, 500) |
| 212 | print(" ") |
| 213 | |
| 214 | |
| 215 | testchain = "dc0/s1/firewall1/non-existent:cp03:output/dc0/s1/iperf1/iperf1:cp02:input" |
| 216 | print('->>>>>>> test Chain VNF Non-Existing Interfaces ->>>>>>>>>>>>>>>') |
| 217 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 218 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 219 | chainvnfresponse = requests.put(url) |
| 220 | self.assertEqual(chainvnfresponse.status_code, 500) |
| 221 | print(" ") |
| 222 | |
| 223 | testchain = "dc0/s1/firewall1/firewall1:cp03:output/dc0/s1/iperf1/non-existent:cp02:input" |
| 224 | print('->>>>>>> test Chain VNF Non-Existing Interfaces ->>>>>>>>>>>>>>>') |
| 225 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 226 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 227 | chainvnfresponse = requests.put(url) |
| 228 | self.assertEqual(chainvnfresponse.status_code, 500) |
| 229 | print(" ") |
| 230 | |
| 231 | testchain = "dc0/s1/firewall1/firewall1:cp03:output/dc0/s1/iperf1/iperf1:cp02:input" |
| 232 | print('->>>>>>> test Chain VNF Interfaces ->>>>>>>>>>>>>>>') |
| 233 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 234 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 235 | chainvnfresponse = requests.put(url) |
| 236 | print (chainvnfresponse.content) |
| 237 | self.assertEqual(chainvnfresponse.status_code, 200) |
| 238 | self.assertGreaterEqual(json.loads(chainvnfresponse.content)["cookie"], 0) |
| 239 | print(" ") |
| 240 | |
| 241 | print('->>>>>>> test Chain VNF Delete Chain ->>>>>>>>>>>>>>>') |
| 242 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 243 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 244 | deletechainvnfresponse = requests.delete(url) |
| 245 | self.assertEqual(deletechainvnfresponse.status_code, 200) |
| 246 | self.assertEqual(deletechainvnfresponse.content, "true") |
| 247 | print(" ") |
| 248 | |
| 249 | print('->>>>>>> test Chaining List If Empty Again ->>>>>>>>>>>>>>>') |
| 250 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 251 | url = "http://0.0.0.0:4000/v1/chain/list" |
| 252 | chainlistresponse = requests.get(url, headers=headers) |
| 253 | self.assertEqual(chainlistresponse.status_code, 200) |
| 254 | self.assertEqual(json.loads(chainlistresponse.content)["chains"], []) |
| 255 | print(" ") |
| 256 | |
| 257 | testchain = "dc0/s1/firewall1/firewall1:cp03:output/dc0/s1/iperf1/iperf1:cp02:input" |
| 258 | print('->>>>>>> test Stack Chain VNF Interfaces ->>>>>>>>>>>>>>>') |
| 259 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 260 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 261 | stackchainvnfresponse = requests.post(url, data=json.dumps( |
| 262 | json.loads('{"path":["dc1.s1", "s1","s2","s3","s1","dc1.s1"]}')), headers=headers) |
| 263 | self.assertEqual(stackchainvnfresponse.status_code, 200) |
| 264 | print (stackchainvnfresponse.content) |
| 265 | self.assertGreaterEqual(json.loads(stackchainvnfresponse.content)["cookie"], 0) |
| 266 | print(" ") |
| 267 | |
| 268 | testchain = "dc0/s1/firewall1/firewall1:cp03:output/dc0/s1/iperf1/iperf1:cp02:input" |
| 269 | print('->>>>>>> test Stack Chain VNF Interfaces ->>>>>>>>>>>>>>>') |
| 270 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 271 | url = "http://0.0.0.0:4000/v1/chain/%s" % (testchain) |
| 272 | stackchainvnfresponse = requests.delete(url, headers=headers) |
| 273 | self.assertEqual(stackchainvnfresponse.status_code, 200) |
| 274 | print(" ") |
| 275 | |
| 276 | |
| 277 | print('->>>>>>> test Loadbalancing ->>>>>>>>>>>>>>>') |
| 278 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 279 | url = "http://0.0.0.0:4000/v1/lb/dc0/s1/firewall1/firewall1:cp03:output" |
| 280 | lblistresponse = requests.post(url, data=json.dumps( |
| 281 | {"dst_vnf_interfaces":[{"pop":"dc0","stack":"s1","server":"iperf1","port":"iperf1:cp02:input"}]}) |
| 282 | , headers=headers) |
| 283 | print (lblistresponse.content) |
| 284 | self.assertEqual(lblistresponse.status_code, 200) |
| 285 | self.assertIn("dc0_s1_firewall1:fire-out-0", lblistresponse.content) |
| 286 | print(" ") |
| 287 | |
| 288 | print('->>>>>>> test Loadbalancing List ->>>>>>>>>>>>>>>') |
| 289 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 290 | url = "http://0.0.0.0:4000/v1/lb/list" |
| 291 | lblistresponse = requests.get(url, headers=headers) |
| 292 | self.assertEqual(lblistresponse.status_code, 200) |
| 293 | print (lblistresponse.content ) |
| 294 | self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["paths"][0]["dst_vnf"], "dc0_s1_iperf1") |
| 295 | self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["paths"][0]["dst_intf"], "iper-in-0") |
| 296 | self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["src_vnf"], "dc0_s1_firewall1") |
| 297 | self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["src_intf"],"fire-out-0") |
| 298 | print(" ") |
| 299 | |
| 300 | print('->>>>>>> test delete Loadbalancing ->>>>>>>>>>>>>>>') |
| 301 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 302 | url = "http://0.0.0.0:4000/v1/lb/dc0/s1/firewall1/firewall1:cp03:output" |
| 303 | lbdeleteresponse = requests.delete(url, headers=headers) |
| 304 | print (lbdeleteresponse.content) |
| 305 | self.assertEqual(lbdeleteresponse.status_code, 200) |
| 306 | print(" ") |
| 307 | |
| 308 | print('->>>>>>> testFloatingLoadbalancer ->>>>>>>>>>>>>>>') |
| 309 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 310 | url = "http://0.0.0.0:4000/v1/lb/dc0/floating/bla/blubb" |
| 311 | lblistresponse = requests.post(url, data=json.dumps( |
| 312 | {"dst_vnf_interfaces":[{"pop":"dc0","stack":"s1","server":"iperf1","port":"iperf1:cp02:input"}]}) |
| 313 | , headers=headers) |
| 314 | print (lblistresponse.content) |
| 315 | self.assertEqual(lblistresponse.status_code, 200) |
| 316 | resp = json.loads(lblistresponse.content) |
| 317 | self.assertIsNotNone(resp.get('cookie')) |
| 318 | self.assertIsNotNone(resp.get('floating_ip')) |
| 319 | cookie = resp.get('cookie') |
| 320 | print(" ") |
| 321 | |
| 322 | print('->>>>>>> testDeleteFloatingLoadbalancer ->>>>>>>>>>>>>>>') |
| 323 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 324 | url = "http://0.0.0.0:4000/v1/lb/dc0/floating/%s/blubb" % cookie |
| 325 | lblistresponse = requests.delete(url, headers=headers) |
| 326 | print (lblistresponse.content) |
| 327 | self.assertEqual(lblistresponse.status_code, 200) |
| 328 | print(" ") |
| 329 | |
| 330 | print('->>>>>>> testLoadbalancingCustomPath ->>>>>>>>>>>>>>>') |
| 331 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 332 | url = "http://0.0.0.0:4000/v1/lb/dc0_s1_firewall1/fire-out-0" |
| 333 | lblistresponse = requests.post(url, data=json.dumps( |
| 334 | {"dst_vnf_interfaces":{"dc0_s1_iperf1":"iper-in-0"}, |
| 335 | "path": {"dc0_s1_iperf1": {"iper-in-0": ["dc1.s1", "s1","s2","s3","s1","dc1.s1"]}}}), headers=headers) |
| 336 | print (lblistresponse.content) |
| 337 | self.assertEqual(lblistresponse.status_code, 200) |
| 338 | self.assertIn("dc0_s1_firewall1:fire-out-0", lblistresponse.content) |
| 339 | print(" ") |
| 340 | |
| 341 | print('->>>>>>> testLoadbalancingListCustomPath ->>>>>>>>>>>>>>>') |
| 342 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 343 | url = "http://0.0.0.0:4000/v1/lb/list" |
| 344 | lblistresponse = requests.get(url, headers=headers) |
| 345 | self.assertEqual(lblistresponse.status_code, 200) |
| 346 | print (lblistresponse.content ) |
| 347 | self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["paths"][0]["dst_vnf"], "dc0_s1_iperf1") |
| 348 | self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["paths"][0]["dst_intf"], "iper-in-0") |
| 349 | self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["paths"][0]["path"], |
| 350 | ["dc1.s1", "s1","s2","s3","s1","dc1.s1"] ) |
| 351 | self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["src_vnf"], "dc0_s1_firewall1") |
| 352 | self.assertEqual(json.loads(lblistresponse.content)["loadbalancers"][0]["src_intf"],"fire-out-0") |
| 353 | print(" ") |
| 354 | |
| 355 | |
| 356 | print('->>>>>>> test Delete Loadbalancing ->>>>>>>>>>>>>>>') |
| 357 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 358 | url = "http://0.0.0.0:4000/v1/lb/dc0_s1_firewall1/fire-out-0" |
| 359 | lblistresponse = requests.delete(url, headers=headers) |
| 360 | self.assertEqual(lblistresponse.status_code, 200) |
| 361 | print(" ") |
| 362 | |
| 363 | print('->>>>>>> test Query Topology ->>>>>>>>>>>>>>>') |
| 364 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 365 | url = "http://0.0.0.0:4000/v1/topo" |
| 366 | topolistresponse = requests.get(url, headers=headers) |
| 367 | print(topolistresponse.content) |
| 368 | self.assertEqual(topolistresponse.status_code, 200) |
| 369 | print(" ") |
| 370 | |
| 371 | |
| 372 | |
| 373 | def testMonitoringDummy(self): |
| 374 | print('->>>>>>> test Monitoring Dummy Class->>>>>>>>>>>>>>>') |
| 375 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 376 | print(" ") |
| 377 | |
| 378 | headers = {'Content-type': 'application/json'} |
| 379 | test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() |
| 380 | url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" |
| 381 | requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)),headers=headers) |
| 382 | |
| 383 | |
| 384 | print('->>>>>>> test Monitoring List Versions ->>>>>>>>>>>>>>>') |
| 385 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 386 | url = "http://0.0.0.0:3000/" |
| 387 | listapiversionstackresponse = requests.get(url, headers=headers) |
| 388 | self.assertEqual(listapiversionstackresponse.status_code, 200) |
| 389 | self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"][0]["id"], "v1") |
| 390 | print(" ") |
| 391 | |
| 392 | print('->>>>>>> test Monitor VNF ->>>>>>>>>>>>>>>') |
| 393 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 394 | url = "http://0.0.0.0:3000/v1/monitor/dc0_s1_firewall1" |
| 395 | listmonitoringvnfresponse = requests.get(url, headers=headers) |
| 396 | self.assertEqual(listmonitoringvnfresponse.status_code, 200) |
| 397 | self.assertGreaterEqual(json.loads(listmonitoringvnfresponse.content)["MEM_%"], 0) |
| 398 | print(" ") |
| 399 | |
| 400 | print('->>>>>>> test Monitor VNF Abs Without Mininet Name ->>>>>>>>>>>>>>>') |
| 401 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 402 | url = "http://0.0.0.0:3000/v1/monitor/abs/dc0_s1_firewall1" |
| 403 | listmonitoringvnfabsresponse = requests.get(url, headers=headers) |
| 404 | self.assertEqual(listmonitoringvnfabsresponse.status_code, 200) |
| 405 | self.assertGreaterEqual(json.loads(listmonitoringvnfabsresponse.content)["MEM_%"], 0) |
| 406 | print(" ") |
| 407 | |
| 408 | print('->>>>>>> test Monitor VNF Abs Without Mininet Name ->>>>>>>>>>>>>>>') |
| 409 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 410 | url = "http://0.0.0.0:3000/v1/monitor/abs/mn.dc0_s1_firewall1" |
| 411 | listmonitoringvnfabsmnresponse = requests.get(url, headers=headers) |
| 412 | self.assertEqual(listmonitoringvnfabsmnresponse.status_code, 200) |
| 413 | self.assertGreaterEqual(json.loads(listmonitoringvnfabsmnresponse.content)["MEM_%"], 0) |
| 414 | print(" ") |
| 415 | |
| 416 | print('->>>>>>> test Monitor VNF Abs With Non-Existing VNF ->>>>>>>>>>>>>>>') |
| 417 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 418 | url = "http://0.0.0.0:3000/v1/monitor/abs/mn.dc0_s1_non_existing" |
| 419 | listmonitoringvnfabsnonexistingresponse = requests.get(url, headers=headers) |
| 420 | self.assertEqual(listmonitoringvnfabsnonexistingresponse.status_code, 500) |
| 421 | print(" ") |
| 422 | |
| 423 | print('->>>>>>> test Monitor VNF DC Stack ->>>>>>>>>>>>>>>') |
| 424 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 425 | url = "http://0.0.0.0:3000/v1/monitor/dc0/s1/firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" |
| 426 | listmonitoringvnfdcstackresponse = requests.get(url, headers=headers) |
| 427 | print(listmonitoringvnfdcstackresponse.content) |
| 428 | self.assertEqual(listmonitoringvnfdcstackresponse.status_code, 200) |
| 429 | self.assertGreaterEqual(json.loads(listmonitoringvnfdcstackresponse.content)["MEM_%"], 0) |
| 430 | print(" ") |
| 431 | |
| 432 | print('->>>>>>> test Monitor VNF DC Stack ->>>>>>>>>>>>>>>') |
| 433 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 434 | url = "http://0.0.0.0:3000/v1/monitor/dc0/s1/firewall1:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest" |
| 435 | listmonitoringvnfdcstackresponse = requests.get(url, headers=headers) |
| 436 | self.assertEqual(listmonitoringvnfdcstackresponse.status_code, 200) |
| 437 | self.assertGreaterEqual(json.loads(listmonitoringvnfdcstackresponse.content)["MEM_%"], 0) |
| 438 | print(" ") |
| 439 | |
| 440 | print('->>>>>>> test Monitor VNF DC Stack With Non-Existing Name ->>>>>>>>>>>>>>>') |
| 441 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 442 | url = "http://0.0.0.0:3000/v1/monitor/dc0/s1/non_existing" |
| 443 | listmonitoringvnfdcstackwithnonexistingnameresponse = requests.get(url, headers=headers) |
| 444 | |
| 445 | self.assertEqual(listmonitoringvnfdcstackwithnonexistingnameresponse.status_code, 500) |
| 446 | print(" ") |
| 447 | |
| 448 | print('->>>>>>> test Monitor VNF DC Stack With Non-Existing DC ->>>>>>>>>>>>>>>') |
| 449 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 450 | url = "http://0.0.0.0:3000/v1/monitor/non_exisintg0/s1/firewall1" |
| 451 | listmonitoringvnfdcstackwithnonexistingdcresponse = requests.get(url, headers=headers) |
| 452 | self.assertEqual(listmonitoringvnfdcstackwithnonexistingdcresponse.status_code, 500) |
| 453 | print(" ") |
| 454 | |
| 455 | print('->>>>>>> test Monitor VNF DC Stack With Non-Existing Stack ->>>>>>>>>>>>>>>') |
| 456 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 457 | url = "http://0.0.0.0:3000/v1/monitor/dc0/non_existing_stack/firewall1" |
| 458 | listmonitoringvnfdcstackwithnonexistingstackresponse = requests.get(url, headers=headers) |
| 459 | self.assertEqual(listmonitoringvnfdcstackwithnonexistingstackresponse.status_code, 500) |
| 460 | print(" ") |
| 461 | |
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | def testNovaDummy(self): |
| 467 | print('->>>>>>> test Nova Dummy Class->>>>>>>>>>>>>>>') |
| 468 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 469 | print(" ") |
| 470 | |
| 471 | headers = {'Content-type': 'application/json'} |
| 472 | test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() |
| 473 | url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" |
| 474 | requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), |
| 475 | headers=headers) |
| 476 | |
| 477 | print('->>>>>>> test Nova List Versions ->>>>>>>>>>>>>>>') |
| 478 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 479 | url = "http://0.0.0.0:8774/" |
| 480 | listapiversionnovaresponse = requests.get(url, headers=headers) |
| 481 | self.assertEqual(listapiversionnovaresponse.status_code, 200) |
| 482 | self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["id"], "v2.1") |
| 483 | self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["status"], "CURRENT") |
| 484 | self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["version"], "2.38") |
| 485 | self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["min_version"], "2.1") |
| 486 | self.assertEqual(json.loads(listapiversionnovaresponse.content)["versions"][0]["updated"], "2013-07-23T11:33:21Z") |
| 487 | print(" ") |
| 488 | |
| 489 | print('->>>>>>> test Nova Version Show ->>>>>>>>>>>>>>>') |
| 490 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 491 | url = "http://0.0.0.0:8774/v2.1/id_bla" |
| 492 | listapiversion21novaresponse = requests.get(url, headers=headers) |
| 493 | self.assertEqual(listapiversion21novaresponse.status_code, 200) |
| 494 | self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["id"], "v2.1") |
| 495 | self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["status"], "CURRENT") |
| 496 | self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["version"], "2.38") |
| 497 | self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["min_version"], "2.1") |
| 498 | self.assertEqual(json.loads(listapiversion21novaresponse.content)["version"]["updated"], "2013-07-23T11:33:21Z") |
| 499 | print(" ") |
| 500 | |
| 501 | print('->>>>>>> test Nova Version List Server APIs ->>>>>>>>>>>>>>>') |
| 502 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 503 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers" |
| 504 | listserverapisnovaresponse = requests.get(url, headers=headers) |
| 505 | self.assertEqual(listserverapisnovaresponse.status_code, 200) |
| 506 | self.assertNotEqual(json.loads(listserverapisnovaresponse.content)["servers"][0]["name"], "") |
| 507 | print(" ") |
| 508 | |
| 509 | print('->>>>>>> test Nova Delete Server APIs ->>>>>>>>>>>>>>>') |
| 510 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 511 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers/%s" % (json.loads(listserverapisnovaresponse.content)["servers"][0]["id"]) |
| 512 | deleteserverapisnovaresponse = requests.delete(url, headers=headers) |
| 513 | self.assertEqual(deleteserverapisnovaresponse.status_code, 204) |
| 514 | print(" ") |
| 515 | |
| 516 | print('->>>>>>> test Nova Delete Non-Existing Server APIs ->>>>>>>>>>>>>>>') |
| 517 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 518 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers/non-existing-ix" |
| 519 | deleteserverapisnovaresponse = requests.delete(url, headers=headers) |
| 520 | self.assertEqual(deleteserverapisnovaresponse.status_code, 404) |
| 521 | print(" ") |
| 522 | |
| 523 | |
| 524 | print('->>>>>>> testNovaVersionListServerAPIs_withPortInformation ->>>>>>>>>>>>>>>') |
| 525 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 526 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers/andPorts" |
| 527 | listserverapisnovaresponse = requests.get(url, headers=headers) |
| 528 | self.assertEqual(listserverapisnovaresponse.status_code, 200) |
| 529 | self.assertNotEqual(json.loads(listserverapisnovaresponse.content)["servers"][0]["name"], "") |
| 530 | print(" ") |
| 531 | |
| 532 | print('->>>>>>> test Nova List Flavors ->>>>>>>>>>>>>>>') |
| 533 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 534 | url = "http://0.0.0.0:8774/v2.1/id_bla/flavors" |
| 535 | listflavorsresponse = requests.get(url, headers=headers) |
| 536 | self.assertEqual(listflavorsresponse.status_code, 200) |
| 537 | self.assertIn(json.loads(listflavorsresponse.content)["flavors"][0]["name"], ["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 538 | self.assertIn(json.loads(listflavorsresponse.content)["flavors"][1]["name"], ["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 539 | self.assertIn(json.loads(listflavorsresponse.content)["flavors"][2]["name"], ["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 540 | print(" ") |
| 541 | |
| 542 | print('->>>>>>> testNovaAddFlavors ->>>>>>>>>>>>>>>') |
| 543 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 544 | url = "http://0.0.0.0:8774/v2.1/id_bla/flavors" |
| 545 | addflavorsresponse = requests.post(url, |
| 546 | data='{"flavor":{"name": "testFlavor", "vcpus": "test_vcpus", "ram": 1024, "disk": 10}}', |
| 547 | headers=headers) |
| 548 | self.assertEqual(addflavorsresponse.status_code, 200) |
| 549 | self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["id"]) |
| 550 | self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["links"][0]['href']) |
| 551 | print(" ") |
| 552 | |
| 553 | print('->>>>>>> test Nova List Flavors Detail ->>>>>>>>>>>>>>>') |
| 554 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 555 | url = "http://0.0.0.0:8774/v2.1/id_bla/flavors/detail" |
| 556 | listflavorsdetailresponse = requests.get(url, headers=headers) |
| 557 | self.assertEqual(listflavorsdetailresponse.status_code, 200) |
| 558 | self.assertIn(json.loads(listflavorsdetailresponse.content)["flavors"][0]["name"],["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 559 | self.assertIn(json.loads(listflavorsdetailresponse.content)["flavors"][1]["name"],["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 560 | self.assertIn(json.loads(listflavorsdetailresponse.content)["flavors"][2]["name"],["m1.nano", "m1.tiny", "m1.micro", "m1.small"]) |
| 561 | print(" ") |
| 562 | |
| 563 | print('->>>>>>> testNovaAddFlavors ->>>>>>>>>>>>>>>') |
| 564 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 565 | url = "http://0.0.0.0:8774/v2.1/id_bla/flavors/detail" |
| 566 | addflavorsresponse = requests.post(url, |
| 567 | data='{"flavor":{"name": "testFlavor", "vcpus": "test_vcpus", "ram": 1024, "disk": 10}}', |
| 568 | headers=headers) |
| 569 | self.assertEqual(addflavorsresponse.status_code, 200) |
| 570 | self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["id"]) |
| 571 | self.assertIsNotNone(json.loads(addflavorsresponse.content)["flavor"]["links"][0]['href']) |
| 572 | print(" ") |
| 573 | |
| 574 | print('->>>>>>> test Nova List Flavor By Id ->>>>>>>>>>>>>>>') |
| 575 | |
| 576 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 577 | url = "http://0.0.0.0:8774/v2.1/id_bla/flavors/%s" % (json.loads(listflavorsdetailresponse.content)["flavors"][0]["name"]) |
| 578 | listflavorsbyidresponse = requests.get(url, headers=headers) |
| 579 | self.assertEqual(listflavorsbyidresponse.status_code, 200) |
| 580 | self.assertEqual(json.loads(listflavorsbyidresponse.content)["flavor"]["id"], json.loads(listflavorsdetailresponse.content)["flavors"][0]["id"]) |
| 581 | print(" ") |
| 582 | |
| 583 | print('->>>>>>> test Nova List Images ->>>>>>>>>>>>>>>') |
| 584 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 585 | url = "http://0.0.0.0:8774/v2.1/id_bla/images" |
| 586 | listimagesresponse = requests.get(url, headers=headers) |
| 587 | self.assertEqual(listimagesresponse.status_code, 200) |
| 588 | print(listimagesresponse.content) |
| 589 | # deactivated: highly depends on the environment in which the tests are executed. one cannot make such an assumption. |
| 590 | #self.assertIn(json.loads(listimagesresponse.content)["images"][0]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 591 | #self.assertIn(json.loads(listimagesresponse.content)["images"][1]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 592 | #self.assertIn(json.loads(listimagesresponse.content)["images"][2]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 593 | print(" ") |
| 594 | |
| 595 | print('->>>>>>> test Nova List Images Details ->>>>>>>>>>>>>>>') |
| 596 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 597 | url = "http://0.0.0.0:8774/v2.1/id_bla/images/detail" |
| 598 | listimagesdetailsresponse = requests.get(url, headers=headers) |
| 599 | self.assertEqual(listimagesdetailsresponse.status_code, 200) |
| 600 | # deactivated: highly depends on the environment in which the tests are executed. one cannot make such an assumption. |
| 601 | #self.assertIn(json.loads(listimagesdetailsresponse.content)["images"][0]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 602 | #self.assertIn(json.loads(listimagesdetailsresponse.content)["images"][1]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 603 | #self.assertIn(json.loads(listimagesdetailsresponse.content)["images"][2]["name"],["google/cadvisor:latest", "ubuntu:trusty", "prom/pushgateway:latest"]) |
| 604 | self.assertEqual(json.loads(listimagesdetailsresponse.content)["images"][0]["metadata"]["architecture"],"x86_64") |
| 605 | print(" ") |
| 606 | |
| 607 | print('->>>>>>> test Nova List Image By Id ->>>>>>>>>>>>>>>') |
| 608 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 609 | url = "http://0.0.0.0:8774/v2.1/id_bla/images/%s" % (json.loads(listimagesdetailsresponse.content)["images"][0]["id"]) |
| 610 | listimagebyidresponse = requests.get(url, headers=headers) |
| 611 | self.assertEqual(listimagebyidresponse.status_code, 200) |
| 612 | self.assertEqual(json.loads(listimagebyidresponse.content)["image"]["id"],json.loads(listimagesdetailsresponse.content)["images"][0]["id"]) |
| 613 | print(" ") |
| 614 | |
| 615 | print('->>>>>>> test Nova List Image By Non-Existend Id ->>>>>>>>>>>>>>>') |
| 616 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 617 | url = "http://0.0.0.0:8774/v2.1/id_bla/images/non_existing_id" |
| 618 | listimagebynonexistingidresponse = requests.get(url, headers=headers) |
| 619 | self.assertEqual(listimagebynonexistingidresponse.status_code, 404) |
| 620 | print(" ") |
| 621 | |
| 622 | #find ubuntu id |
| 623 | for image in json.loads(listimagesresponse.content)["images"]: |
| 624 | if image["name"] == "ubuntu:trusty": |
| 625 | ubuntu_image_id = image["id"] |
| 626 | |
| 627 | |
| 628 | |
| 629 | print('->>>>>>> test Nova Create Server Instance ->>>>>>>>>>>>>>>') |
| 630 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 631 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers" |
| 632 | data = '{"server": {"name": "X", "flavorRef": "%s", "imageRef":"%s"}}' % (json.loads(listflavorsresponse.content)["flavors"][0]["id"], ubuntu_image_id) |
| 633 | createserverinstance = requests.post(url, data=data, headers=headers) |
| 634 | self.assertEqual(createserverinstance.status_code, 200) |
| 635 | self.assertEqual(json.loads(createserverinstance.content)["server"]["image"]["id"], ubuntu_image_id) |
| 636 | print(" ") |
| 637 | |
| 638 | print('->>>>>>> test Nova Create Server Instance With Already Existing Name ->>>>>>>>>>>>>>>') |
| 639 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 640 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers" |
| 641 | data = '{"server": {"name": "X", "flavorRef": "%s", "imageRef":"%s"}}' % (json.loads(listflavorsresponse.content)["flavors"][0]["id"], ubuntu_image_id) |
| 642 | createserverinstance = requests.post(url, data=data, headers=headers) |
| 643 | self.assertEqual(createserverinstance.status_code, 409) |
| 644 | print(" ") |
| 645 | |
| 646 | print('->>>>>>> test Nova Version List Server APIs Detailed ->>>>>>>>>>>>>>>') |
| 647 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 648 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers/detail" |
| 649 | listserverapisdetailedresponse = requests.get(url, headers=headers) |
| 650 | self.assertEqual(listserverapisdetailedresponse.status_code, 200) |
| 651 | self.assertEqual(json.loads(listserverapisdetailedresponse.content)["servers"][0]["status"], "ACTIVE") |
| 652 | print(" ") |
| 653 | |
| 654 | print('->>>>>>> test Nova Show Server Details ->>>>>>>>>>>>>>>') |
| 655 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 656 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers/%s" % (json.loads(listserverapisdetailedresponse.content)["servers"][0]["id"]) |
| 657 | listserverdetailsresponse = requests.get(url, headers=headers) |
| 658 | self.assertEqual(listserverdetailsresponse.status_code, 200) |
| 659 | self.assertEqual(json.loads(listserverdetailsresponse.content)["server"]["flavor"]["links"][0]["rel"], "bookmark") |
| 660 | print(" ") |
| 661 | |
| 662 | print('->>>>>>> test Nova Show Non-Existing Server Details ->>>>>>>>>>>>>>>') |
| 663 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 664 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers/non_existing_server_id" |
| 665 | listnonexistingserverdetailsresponse = requests.get(url, headers=headers) |
| 666 | self.assertEqual(listnonexistingserverdetailsresponse.status_code, 404) |
| 667 | print(" ") |
| 668 | |
| 669 | |
| 670 | |
| 671 | def testNeutronDummy(self): |
| 672 | print('->>>>>>> test Neutron Dummy Class->>>>>>>>>>>>>>>') |
| 673 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 674 | print(" ") |
| 675 | |
| 676 | headers = {'Content-type': 'application/json'} |
| 677 | test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() |
| 678 | url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" |
| 679 | requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), headers=headers) |
| 680 | # test_heatapi_keystone_get_token = open("test_heatapi_keystone_get_token.json").read() |
| 681 | |
| 682 | print('->>>>>>> test Neutron List Versions ->>>>>>>>>>>>>>>') |
| 683 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 684 | url = "http://0.0.0.0:9696/" |
| 685 | listapiversionstackresponse = requests.get(url, headers=headers) |
| 686 | self.assertEqual(listapiversionstackresponse.status_code, 200) |
| 687 | self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"][0]["id"], "v2.0") |
| 688 | print(" ") |
| 689 | |
| 690 | print('->>>>>>> test Neutron Show API v2.0 ->>>>>>>>>>>>>>>') |
| 691 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 692 | url = "http://0.0.0.0:9696/v2.0" |
| 693 | listapiversionv20response = requests.get(url, headers=headers) |
| 694 | self.assertEqual(listapiversionv20response.status_code, 200) |
| 695 | self.assertEqual(json.loads(listapiversionv20response.content)["resources"][0]["name"], "subnet") |
| 696 | self.assertEqual(json.loads(listapiversionv20response.content)["resources"][1]["name"], "network") |
| 697 | self.assertEqual(json.loads(listapiversionv20response.content)["resources"][2]["name"], "ports") |
| 698 | print(" ") |
| 699 | |
| 700 | print('->>>>>>> test Neutron List Networks ->>>>>>>>>>>>>>>') |
| 701 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 702 | url = "http://0.0.0.0:9696/v2.0/networks" |
| 703 | listnetworksesponse1 = requests.get(url, headers=headers) |
| 704 | self.assertEqual(listnetworksesponse1.status_code, 200) |
| 705 | self.assertEqual(json.loads(listnetworksesponse1.content)["networks"][0]["status"], "ACTIVE") |
| 706 | listNetworksId = json.loads(listnetworksesponse1.content)["networks"][0]["id"] |
| 707 | listNetworksName = json.loads(listnetworksesponse1.content)["networks"][0]["name"] |
| 708 | listNetworksId2 = json.loads(listnetworksesponse1.content)["networks"][1]["id"] |
| 709 | print(" ") |
| 710 | |
| 711 | print('->>>>>>> test Neutron List Non-Existing Networks ->>>>>>>>>>>>>>>') |
| 712 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 713 | url = "http://0.0.0.0:9696/v2.0/networks?name=non_existent_network_name" |
| 714 | listnetworksesponse2 = requests.get(url,headers=headers) |
| 715 | self.assertEqual(listnetworksesponse2.status_code, 404) |
| 716 | print(" ") |
| 717 | |
| 718 | print('->>>>>>> test Neutron List Networks By Name ->>>>>>>>>>>>>>>') |
| 719 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 720 | url = "http://0.0.0.0:9696/v2.0/networks?name=" + listNetworksName #tcpdump-vnf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest |
| 721 | listnetworksesponse3 = requests.get(url, headers=headers) |
| 722 | self.assertEqual(listnetworksesponse3.status_code, 200) |
| 723 | self.assertEqual(json.loads(listnetworksesponse3.content)["networks"][0]["name"], listNetworksName) |
| 724 | print(" ") |
| 725 | |
| 726 | print('->>>>>>> test Neutron List Networks By Id ->>>>>>>>>>>>>>>') |
| 727 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 728 | url = "http://0.0.0.0:9696/v2.0/networks?id=" + listNetworksId # tcpdump-vnf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest |
| 729 | listnetworksesponse4 = requests.get(url, headers=headers) |
| 730 | self.assertEqual(listnetworksesponse4.status_code, 200) |
| 731 | self.assertEqual(json.loads(listnetworksesponse4.content)["networks"][0]["id"], listNetworksId) |
| 732 | print(" ") |
| 733 | |
| 734 | print('->>>>>>> test Neutron List Networks By Multiple Ids ->>>>>>>>>>>>>>>') |
| 735 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 736 | url = "http://0.0.0.0:9696/v2.0/networks?id=" + listNetworksId + "&id="+ listNetworksId2 # tcpdump-vnf:input:net:9df6a98f-9e11-4cb7-b3c0-InAdUnitTest |
| 737 | listnetworksesponse5 = requests.get(url, headers=headers) |
| 738 | self.assertEqual(listnetworksesponse5.status_code, 200) |
| 739 | self.assertEqual(json.loads(listnetworksesponse5.content)["networks"][0]["id"], listNetworksId) |
| 740 | self.assertEqual(json.loads(listnetworksesponse5.content)["networks"][1]["id"], listNetworksId2) |
| 741 | print(" ") |
| 742 | |
| 743 | print('->>>>>>> test Neutron Show Network ->>>>>>>>>>>>>>>') |
| 744 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 745 | url = "http://0.0.0.0:9696/v2.0/networks/"+listNetworksId |
| 746 | shownetworksesponse = requests.get(url, headers=headers) |
| 747 | self.assertEqual(shownetworksesponse.status_code, 200) |
| 748 | self.assertEqual(json.loads(shownetworksesponse.content)["network"]["status"], "ACTIVE") |
| 749 | print(" ") |
| 750 | |
| 751 | print('->>>>>>> test Neutron Show Network Non-ExistendNetwork ->>>>>>>>>>>>>>>') |
| 752 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 753 | url = "http://0.0.0.0:9696/v2.0/networks/non_existent_network_id" |
| 754 | shownetworksesponse2 = requests.get(url, headers=headers) |
| 755 | self.assertEqual(shownetworksesponse2.status_code, 404) |
| 756 | print(" ") |
| 757 | |
| 758 | print('->>>>>>> test Neutron Create Network ->>>>>>>>>>>>>>>') |
| 759 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 760 | url = "http://0.0.0.0:9696/v2.0/networks" |
| 761 | createnetworkresponse = requests.post(url, data='{"network": {"name": "sample_network","admin_state_up": true}}', headers=headers) |
| 762 | self.assertEqual(createnetworkresponse.status_code, 201) |
| 763 | self.assertEqual(json.loads(createnetworkresponse.content)["network"]["status"], "ACTIVE") |
| 764 | print(" ") |
| 765 | |
| 766 | print('->>>>>>> test Neutron Create Network With Existing Name ->>>>>>>>>>>>>>>') |
| 767 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 768 | url = "http://0.0.0.0:9696/v2.0/networks" |
| 769 | createnetworkresponsefailure = requests.post(url,data='{"network": {"name": "sample_network","admin_state_up": true}}',headers=headers) |
| 770 | self.assertEqual(createnetworkresponsefailure.status_code, 400) |
| 771 | print(" ") |
| 772 | |
| 773 | print('->>>>>>> test Neutron Update Network ->>>>>>>>>>>>>>>') |
| 774 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 775 | url = "http://0.0.0.0:9696/v2.0/networks/%s" % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 776 | updatenetworkresponse = requests.put(url, data='{"network": {"status": "ACTIVE", "admin_state_up":true, "tenant_id":"abcd123", "name": "sample_network_new_name", "shared":false}}' , headers=headers) |
| 777 | self.assertEqual(updatenetworkresponse.status_code, 200) |
| 778 | self.assertEqual(json.loads(updatenetworkresponse.content)["network"]["name"], "sample_network_new_name") |
| 779 | self.assertEqual(json.loads(updatenetworkresponse.content)["network"]["tenant_id"], "abcd123") |
| 780 | print(" ") |
| 781 | |
| 782 | print('->>>>>>> test Neutron Update Non-Existing Network ->>>>>>>>>>>>>>>') |
| 783 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 784 | url = "http://0.0.0.0:9696/v2.0/networks/non-existing-name123" |
| 785 | updatenetworkresponse = requests.put(url, data='{"network": {"name": "sample_network_new_name"}}', headers=headers) |
| 786 | self.assertEqual(updatenetworkresponse.status_code, 404) |
| 787 | print(" ") |
| 788 | |
| 789 | print('->>>>>>> test Neutron List Subnets ->>>>>>>>>>>>>>>') |
| 790 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 791 | url = "http://0.0.0.0:9696/v2.0/subnets" |
| 792 | listsubnetsresponse = requests.get(url, headers=headers) |
| 793 | listSubnetName = json.loads(listsubnetsresponse.content)["subnets"][0]["name"] |
| 794 | listSubnetId = json.loads(listsubnetsresponse.content)["subnets"][0]["id"] |
| 795 | listSubnetId2 = json.loads(listsubnetsresponse.content)["subnets"][1]["id"] |
| 796 | self.assertEqual(listsubnetsresponse.status_code, 200) |
| 797 | self.assertNotIn('None', listSubnetName) |
| 798 | print(" ") |
| 799 | |
| 800 | print('->>>>>>> test Neutron List Subnets By Name ->>>>>>>>>>>>>>>') |
| 801 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 802 | url = "http://0.0.0.0:9696/v2.0/subnets?name="+listSubnetName |
| 803 | listsubnetByNameresponse = requests.get(url, headers=headers) |
| 804 | self.assertEqual(listsubnetByNameresponse.status_code, 200) |
| 805 | self.assertNotIn('None', json.loads(listsubnetByNameresponse.content)["subnets"][0]["name"]) |
| 806 | print(" ") |
| 807 | |
| 808 | print('->>>>>>> test Neutron List Subnets By Id ->>>>>>>>>>>>>>>') |
| 809 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 810 | url = "http://0.0.0.0:9696/v2.0/subnets?id=" + listSubnetId |
| 811 | listsubnetsbyidresponse = requests.get(url, headers=headers) |
| 812 | self.assertEqual(listsubnetsbyidresponse.status_code, 200) |
| 813 | self.assertNotIn("None", json.loads(listsubnetsbyidresponse.content)["subnets"][0]["name"]) |
| 814 | print(" ") |
| 815 | |
| 816 | print('->>>>>>> test Neutron List Subnets By Multiple Id ->>>>>>>>>>>>>>>') |
| 817 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 818 | url = "http://0.0.0.0:9696/v2.0/subnets?id=" + listSubnetId +"&id="+listSubnetId2 |
| 819 | listsubnetsbymultipleidsresponse = requests.get(url, headers=headers) |
| 820 | self.assertEqual(listsubnetsbymultipleidsresponse.status_code, 200) |
| 821 | self.assertNotIn("None", json.loads(listsubnetsbymultipleidsresponse.content)["subnets"][0]["name"]) |
| 822 | print(" ") |
| 823 | |
| 824 | |
| 825 | |
| 826 | print('->>>>>>> test Neutron Show Subnet->>>>>>>>>>>>>>>') |
| 827 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 828 | url = "http://0.0.0.0:9696/v2.0/subnets/%s" % (json.loads(listsubnetsresponse.content)["subnets"][0]["id"]) |
| 829 | showsubnetsresponse = requests.get(url, headers=headers) |
| 830 | self.assertEqual(showsubnetsresponse.status_code, 200) |
| 831 | self.assertNotIn("None", json.loads(showsubnetsresponse.content)["subnet"]["name"]) |
| 832 | print(" ") |
| 833 | |
| 834 | print('->>>>>>> test Neutron Show Non-Existing Subnet->>>>>>>>>>>>>>>') |
| 835 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 836 | url = "http://0.0.0.0:9696/v2.0/subnets/non-existing-id123" |
| 837 | showsubnetsresponse = requests.get(url, headers=headers) |
| 838 | self.assertEqual(showsubnetsresponse.status_code, 404) |
| 839 | print(" ") |
| 840 | |
| 841 | |
| 842 | print('->>>>>>> test Neutron Create Subnet ->>>>>>>>>>>>>>>') |
| 843 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 844 | url = "http://0.0.0.0:9696/v2.0/subnets" |
| 845 | createsubnetdata = '{"subnet": {"name": "new_subnet", "network_id": "%s","ip_version": 4,"cidr": "10.0.0.1/24"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 846 | createsubnetresponse = requests.post(url, data=createsubnetdata, headers=headers) |
| 847 | self.assertEqual(createsubnetresponse.status_code, 201) |
| 848 | self.assertEqual(json.loads(createsubnetresponse.content)["subnet"]["name"], "new_subnet") |
| 849 | print(" ") |
| 850 | |
| 851 | print('->>>>>>> test Neutron Create Second Subnet ->>>>>>>>>>>>>>>') |
| 852 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 853 | url = "http://0.0.0.0:9696/v2.0/subnets" |
| 854 | createsubnetdata = '{"subnet": {"name": "new_subnet", "network_id": "%s","ip_version": 4,"cidr": "10.0.0.1/24"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 855 | createsubnetfailureresponse = requests.post(url, data=createsubnetdata, headers=headers) |
| 856 | self.assertEqual(createsubnetfailureresponse.status_code, 409) |
| 857 | print(" ") |
| 858 | |
| 859 | print('->>>>>>> test Neutron Update Subnet ->>>>>>>>>>>>>>>') |
| 860 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 861 | url = "http://0.0.0.0:9696/v2.0/subnets/%s" % (json.loads(createsubnetresponse.content)["subnet"]["id"]) |
| 862 | 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} }' |
| 863 | updatesubnetresponse = requests.put(url, data=updatesubnetdata, headers=headers) |
| 864 | self.assertEqual(updatesubnetresponse.status_code, 200) |
| 865 | self.assertEqual(json.loads(updatesubnetresponse.content)["subnet"]["name"], "new_subnet_new_name") |
| 866 | print(" ") |
| 867 | |
| 868 | print('->>>>>>> test Neutron Update Non-Existing Subnet ->>>>>>>>>>>>>>>') |
| 869 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 870 | url = "http://0.0.0.0:9696/v2.0/subnets/non-existing-subnet-12345" |
| 871 | updatenonexistingsubnetdata = '{"subnet": {"name": "new_subnet_new_name"} }' |
| 872 | updatenonexistingsubnetresponse = requests.put(url, data=updatenonexistingsubnetdata, headers=headers) |
| 873 | self.assertEqual(updatenonexistingsubnetresponse.status_code, 404) |
| 874 | print(" ") |
| 875 | |
| 876 | |
| 877 | |
| 878 | print('->>>>>>> test Neutron List Ports ->>>>>>>>>>>>>>>') |
| 879 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 880 | url = "http://0.0.0.0:9696/v2.0/ports" |
| 881 | listportsesponse = requests.get(url, headers=headers) |
| 882 | self.assertEqual(listportsesponse.status_code, 200) |
| 883 | self.assertEqual(json.loads(listportsesponse.content)["ports"][0]["status"], "ACTIVE") |
| 884 | listPortsName = json.loads(listportsesponse.content)["ports"][0]["name"] |
| 885 | listPortsId1 = json.loads(listportsesponse.content)["ports"][0]["id"] |
| 886 | listPortsId2 = json.loads(listportsesponse.content)["ports"][1]["id"] |
| 887 | print(" ") |
| 888 | |
| 889 | print('->>>>>>> test Neutron List Ports By Name ->>>>>>>>>>>>>>>') |
| 890 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 891 | url = "http://0.0.0.0:9696/v2.0/ports?name=" + listPortsName |
| 892 | listportsbynameesponse = requests.get(url, headers=headers) |
| 893 | self.assertEqual(listportsbynameesponse.status_code, 200) |
| 894 | self.assertEqual(json.loads(listportsbynameesponse.content)["ports"][0]["name"], listPortsName) |
| 895 | print(" ") |
| 896 | |
| 897 | print('->>>>>>> test Neutron List Ports By Id ->>>>>>>>>>>>>>>') |
| 898 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 899 | url = "http://0.0.0.0:9696/v2.0/ports?id=" + listPortsId1 |
| 900 | listportsbyidesponse = requests.get(url, headers=headers) |
| 901 | self.assertEqual(listportsbyidesponse.status_code, 200) |
| 902 | self.assertEqual(json.loads(listportsbyidesponse.content)["ports"][0]["id"], listPortsId1) |
| 903 | print(" ") |
| 904 | |
| 905 | print('->>>>>>> test Neutron List Ports By Multiple Ids ->>>>>>>>>>>>>>>') |
| 906 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 907 | url = "http://0.0.0.0:9696/v2.0/ports?id=" + listPortsId1 +"&id="+listPortsId2 |
| 908 | listportsbymultipleidsesponse = requests.get(url, headers=headers) |
| 909 | self.assertEqual(listportsbymultipleidsesponse.status_code, 200) |
| 910 | self.assertEqual(json.loads(listportsbymultipleidsesponse.content)["ports"][0]["id"], listPortsId1) |
| 911 | print(" ") |
| 912 | |
| 913 | print('->>>>>>> test Neutron List Non-Existing Ports ->>>>>>>>>>>>>>>') |
| 914 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 915 | url = "http://0.0.0.0:9696/v2.0/ports?id=non-existing-port-id" |
| 916 | listportsbynonexistingidsesponse = requests.get(url, headers=headers) |
| 917 | self.assertEqual(listportsbynonexistingidsesponse.status_code, 404) |
| 918 | print(" ") |
| 919 | |
| 920 | print('->>>>>>> test Neutron Show Port ->>>>>>>>>>>>>>>') |
| 921 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 922 | url = "http://0.0.0.0:9696/v2.0/ports/%s" % (json.loads(listportsesponse.content)["ports"][0]["id"]) |
| 923 | showportresponse = requests.get(url, headers=headers) |
| 924 | self.assertEqual(showportresponse.status_code, 200) |
| 925 | self.assertEqual(json.loads(showportresponse.content)["port"]["status"], "ACTIVE") |
| 926 | print(" ") |
| 927 | |
| 928 | print('->>>>>>> test Neutron Show Non-Existing Port ->>>>>>>>>>>>>>>') |
| 929 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 930 | url = "http://0.0.0.0:9696/v2.0/ports/non-existing-portid123" |
| 931 | shownonexistingportresponse = requests.get(url, headers=headers) |
| 932 | self.assertEqual(shownonexistingportresponse.status_code, 404) |
| 933 | print(" ") |
| 934 | |
| 935 | print('->>>>>>> test Neutron Create Port In Non-Existing Network ->>>>>>>>>>>>>>>') |
| 936 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 937 | url = "http://0.0.0.0:9696/v2.0/ports" |
| 938 | createnonexistingportdata = '{"port": {"name": "new_port", "network_id": "non-existing-id"} }' |
| 939 | createnonexistingnetworkportresponse = requests.post(url, data=createnonexistingportdata, headers=headers) |
| 940 | self.assertEqual(createnonexistingnetworkportresponse.status_code, 404) |
| 941 | print(" ") |
| 942 | |
| 943 | print('->>>>>>> test Neutron Create Port ->>>>>>>>>>>>>>>') |
| 944 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 945 | url = "http://0.0.0.0:9696/v2.0/ports" |
| 946 | 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"]) |
| 947 | createportresponse = requests.post(url, data=createportdata, headers=headers) |
| 948 | self.assertEqual(createportresponse.status_code, 201) |
| 949 | print (createportresponse.content) |
| 950 | self.assertEqual(json.loads(createportresponse.content)["port"]["name"], "new_port") |
| 951 | print(" ") |
| 952 | |
| 953 | print('->>>>>>> test Neutron Create Port With Existing Name ->>>>>>>>>>>>>>>') |
| 954 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 955 | url = "http://0.0.0.0:9696/v2.0/ports" |
| 956 | createportwithexistingnamedata = '{"port": {"name": "new_port", "network_id": "%s"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 957 | createportwithexistingnameresponse = requests.post(url, data=createportwithexistingnamedata, headers=headers) |
| 958 | self.assertEqual(createportwithexistingnameresponse.status_code, 500) |
| 959 | print(" ") |
| 960 | |
| 961 | print('->>>>>>> test Neutron Create Port Without Name ->>>>>>>>>>>>>>>') |
| 962 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 963 | url = "http://0.0.0.0:9696/v2.0/ports" |
| 964 | createportdatawithoutname = '{"port": {"network_id": "%s"} }' % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 965 | createportwithoutnameresponse = requests.post(url, data=createportdatawithoutname, headers=headers) |
| 966 | self.assertEqual(createportwithoutnameresponse.status_code, 201) |
| 967 | self.assertIn("port:cp", json.loads(createportwithoutnameresponse.content)["port"]["name"]) |
| 968 | print(" ") |
| 969 | |
| 970 | print('->>>>>>> test Neutron Update Port ->>>>>>>>>>>>>>>') |
| 971 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 972 | print(json.loads(createportresponse.content)["port"]["name"]) |
| 973 | url = "http://0.0.0.0:9696/v2.0/ports/%s" % (json.loads(createportresponse.content)["port"]["name"]) |
| 974 | 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"} }' |
| 975 | updateportresponse = requests.put(url, data=updateportdata, headers=headers) |
| 976 | self.assertEqual(updateportresponse.status_code, 200) |
| 977 | self.assertEqual(json.loads(updateportresponse.content)["port"]["name"], "new_port_new_name") |
| 978 | print(" ") |
| 979 | |
| 980 | print('->>>>>>> test Neutron Update Non-Existing Port ->>>>>>>>>>>>>>>') |
| 981 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 982 | url = "http://0.0.0.0:9696/v2.0/ports/non-existing-port-ip" |
| 983 | updatenonexistingportdata = '{"port": {"name": "new_port_new_name"} }' |
| 984 | updatenonexistingportresponse = requests.put(url, data=updatenonexistingportdata, headers=headers) |
| 985 | self.assertEqual(updatenonexistingportresponse.status_code, 404) |
| 986 | print(" ") |
| 987 | |
| 988 | print('->>>>>>> test Neutron Delete Port ->>>>>>>>>>>>>>>') |
| 989 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 990 | righturl = "http://0.0.0.0:9696/v2.0/ports/%s" % (json.loads(createportresponse.content)["port"]["id"]) |
| 991 | deleterightportresponse = requests.delete(righturl, headers=headers) |
| 992 | self.assertEqual(deleterightportresponse.status_code, 204) |
| 993 | print(" ") |
| 994 | |
| 995 | |
| 996 | print('->>>>>>> test Neutron Delete Non-Existing Port ->>>>>>>>>>>>>>>') |
| 997 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 998 | wrongurl = "http://0.0.0.0:9696/v2.0/ports/unknownid" |
| 999 | deletewrongportresponse = requests.delete(wrongurl, headers=headers) |
| 1000 | self.assertEqual(deletewrongportresponse.status_code, 404) |
| 1001 | print(" ") |
| 1002 | |
| 1003 | print('->>>>>>> test Neutron Delete Subnet ->>>>>>>>>>>>>>>') |
| 1004 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1005 | wrongurl = "http://0.0.0.0:9696/v2.0/subnets/unknownid" |
| 1006 | righturl = "http://0.0.0.0:9696/v2.0/subnets/%s" % (json.loads(updatesubnetresponse.content)["subnet"]["id"]) |
| 1007 | deletewrongsubnetresponse = requests.delete(wrongurl, headers=headers) |
| 1008 | deleterightsubnetresponse = requests.delete(righturl, headers=headers) |
| 1009 | self.assertEqual(deletewrongsubnetresponse.status_code, 404) |
| 1010 | self.assertEqual(deleterightsubnetresponse.status_code, 204) |
| 1011 | print(" ") |
| 1012 | |
| 1013 | print('->>>>>>> test Neutron Delete Network ->>>>>>>>>>>>>>>') |
| 1014 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1015 | righturl = "http://0.0.0.0:9696/v2.0/networks/%s" % (json.loads(createnetworkresponse.content)["network"]["id"]) |
| 1016 | deleterightnetworkresponse = requests.delete(righturl, headers=headers) |
| 1017 | self.assertEqual(deleterightnetworkresponse.status_code, 204) |
| 1018 | print(" ") |
| 1019 | |
| 1020 | print('->>>>>>> test Neutron Delete Non-Existing Network ->>>>>>>>>>>>>>>') |
| 1021 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1022 | wrongurl = "http://0.0.0.0:9696/v2.0/networks/unknownid" |
| 1023 | deletewrongnetworkresponse = requests.delete(wrongurl, headers=headers) |
| 1024 | self.assertEqual(deletewrongnetworkresponse.status_code, 404) |
| 1025 | print(" ") |
| 1026 | |
| 1027 | def testKeystomeDummy(self): |
| 1028 | print('->>>>>>> test Keystone Dummy Class->>>>>>>>>>>>>>>') |
| 1029 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1030 | print(" ") |
| 1031 | |
| 1032 | headers = {'Content-type': 'application/json'} |
| 1033 | test_heatapi_keystone_get_token = open(os.path.join(os.path.dirname(__file__), "test_heatapi_keystone_get_token.json")).read() |
| 1034 | |
| 1035 | print('->>>>>>> test Keystone List Versions ->>>>>>>>>>>>>>>') |
| 1036 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1037 | url = "http://0.0.0.0:5000/" |
| 1038 | listapiversionstackresponse = requests.get(url, headers=headers) |
| 1039 | self.assertEqual(listapiversionstackresponse.status_code, 200) |
| 1040 | self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"]["values"][0]["id"], "v2.0") |
| 1041 | print(" ") |
| 1042 | |
| 1043 | print('->>>>>>> test Keystone Show ApiV2 ->>>>>>>>>>>>>>>') |
| 1044 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1045 | url = "http://0.0.0.0:5000/v2.0" |
| 1046 | showapiversionstackresponse = requests.get(url, headers=headers) |
| 1047 | self.assertEqual(showapiversionstackresponse.status_code, 200) |
| 1048 | self.assertEqual(json.loads(showapiversionstackresponse.content)["version"]["id"], "v2.0") |
| 1049 | print(" ") |
| 1050 | |
| 1051 | print('->>>>>>> test Keystone Get Token ->>>>>>>>>>>>>>>') |
| 1052 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1053 | url = "http://0.0.0.0:5000/v2.0/tokens" |
| 1054 | gettokenstackresponse = requests.post(url, data=json.dumps(json.loads(test_heatapi_keystone_get_token)), headers=headers) |
| 1055 | self.assertEqual(gettokenstackresponse.status_code, 200) |
| 1056 | self.assertEqual(json.loads(gettokenstackresponse.content)["access"]["user"]["name"], "tenantName") |
| 1057 | print(" ") |
| 1058 | |
| 1059 | |
| 1060 | def testHeatDummy(self): |
| 1061 | print('->>>>>>> test Heat Dummy Class->>>>>>>>>>>>>>>') |
| 1062 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1063 | print(" ") |
| 1064 | |
| 1065 | headers = {'Content-type': 'application/json'} |
| 1066 | test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_create_stack.json")).read() |
| 1067 | test_heatapi_template_update_stack = open(os.path.join(os.path.dirname(__file__), "test_heatapi_template_update_stack.json")).read() |
| 1068 | |
| 1069 | print('->>>>>>> test Heat List API Versions Stack ->>>>>>>>>>>>>>>') |
| 1070 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1071 | url = "http://0.0.0.0:8004/" |
| 1072 | listapiversionstackresponse = requests.get(url, headers=headers) |
| 1073 | self.assertEqual(listapiversionstackresponse.status_code, 200) |
| 1074 | self.assertEqual(json.loads(listapiversionstackresponse.content)["versions"][0]["id"], "v1.0") |
| 1075 | print(" ") |
| 1076 | |
| 1077 | print('->>>>>>> test Create Stack ->>>>>>>>>>>>>>>') |
| 1078 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1079 | url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" |
| 1080 | createstackresponse = requests.post(url, data=json.dumps(json.loads(test_heatapi_template_create_stack)), headers=headers) |
| 1081 | self.assertEqual(createstackresponse.status_code, 201) |
| 1082 | self.assertNotEqual(json.loads(createstackresponse.content)["stack"]["id"], "") |
| 1083 | print(" ") |
| 1084 | |
| 1085 | print('->>>>>>> test Create Stack With Existing Name ->>>>>>>>>>>>>>>') |
| 1086 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1087 | url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" |
| 1088 | createstackwithexistingnameresponse = requests.post(url, data='{"stack_name" : "s1"}', headers=headers) |
| 1089 | self.assertEqual(createstackwithexistingnameresponse.status_code, 409) |
| 1090 | print(" ") |
| 1091 | |
| 1092 | print('->>>>>>> test Create Stack With Unsupported Version ->>>>>>>>>>>>>>>') |
| 1093 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1094 | url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" |
| 1095 | createstackwitheunsupportedversionresponse = requests.post(url, data='{"stack_name" : "stackname123", "template" : {"heat_template_version": "2015-04-29"}}', headers=headers) |
| 1096 | self.assertEqual(createstackwitheunsupportedversionresponse.status_code, 400) |
| 1097 | print(" ") |
| 1098 | |
| 1099 | |
| 1100 | print('->>>>>>> test List Stack ->>>>>>>>>>>>>>>') |
| 1101 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1102 | url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" |
| 1103 | liststackresponse = requests.get(url, headers=headers) |
| 1104 | self.assertEqual(liststackresponse.status_code, 200) |
| 1105 | self.assertEqual(json.loads(liststackresponse.content)["stacks"][0]["stack_status"], "CREATE_COMPLETE") |
| 1106 | print(" ") |
| 1107 | |
| 1108 | |
| 1109 | print('->>>>>>> test Show Stack ->>>>>>>>>>>>>>>') |
| 1110 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1111 | url = "http://0.0.0.0:8004/v1/tenantabc123showStack/stacks/%s"% json.loads(createstackresponse.content)['stack']['id'] |
| 1112 | liststackdetailsresponse = requests.get(url, headers=headers) |
| 1113 | self.assertEqual(liststackdetailsresponse.status_code, 200) |
| 1114 | self.assertEqual(json.loads(liststackdetailsresponse.content)["stack"]["stack_status"], "CREATE_COMPLETE") |
| 1115 | print(" ") |
| 1116 | |
| 1117 | print('->>>>>>> test Show Non-Exisitng Stack ->>>>>>>>>>>>>>>') |
| 1118 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1119 | url = "http://0.0.0.0:8004/v1/tenantabc123showStack/stacks/non_exisitng_id123" |
| 1120 | listnonexistingstackdetailsresponse = requests.get(url, headers=headers) |
| 1121 | self.assertEqual(listnonexistingstackdetailsresponse.status_code, 404) |
| 1122 | print(" ") |
| 1123 | |
| 1124 | print('->>>>>>> test Update Stack ->>>>>>>>>>>>>>>') |
| 1125 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1126 | url = "http://0.0.0.0:8004/v1/tenantabc123updateStack/stacks/%s"% json.loads(createstackresponse.content)['stack']['id'] |
| 1127 | updatestackresponse = requests.put(url, data=json.dumps(json.loads(test_heatapi_template_update_stack)), |
| 1128 | headers=headers) |
| 1129 | self.assertEqual(updatestackresponse.status_code, 202) |
| 1130 | liststackdetailsresponse = requests.get(url, headers=headers) |
| 1131 | self.assertEqual(json.loads(liststackdetailsresponse.content)["stack"]["stack_status"], "UPDATE_COMPLETE") |
| 1132 | print(" ") |
| 1133 | |
| 1134 | print('->>>>>>> test Update Non-Existing Stack ->>>>>>>>>>>>>>>') |
| 1135 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1136 | url = "http://0.0.0.0:8004/v1/tenantabc123updateStack/stacks/non_existing_id_1234" |
| 1137 | updatenonexistingstackresponse = requests.put(url, data={"non": "sense"}, headers=headers) |
| 1138 | self.assertEqual(updatenonexistingstackresponse.status_code, 404) |
| 1139 | print(" ") |
| 1140 | |
| 1141 | print('->>>>>>> test Delete Stack ->>>>>>>>>>>>>>>') |
| 1142 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1143 | url = "http://0.0.0.0:8004/v1/tenantabc123showStack/stacks/%s" % \ |
| 1144 | json.loads(createstackresponse.content)['stack']['id'] |
| 1145 | deletestackdetailsresponse = requests.delete(url, headers=headers) |
| 1146 | self.assertEqual(deletestackdetailsresponse.status_code, 204) |
| 1147 | print(" ") |
| 1148 | |
| 1149 | |
| 1150 | def test_CombinedTesting(self): |
| 1151 | print('->>>>>>> test Combinded tests->>>>>>>>>>>>>>>') |
| 1152 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1153 | print(" ") |
| 1154 | |
| 1155 | headers = {'Content-type': 'application/json'} |
| 1156 | test_heatapi_template_create_stack = open(os.path.join(os.path.dirname(__file__), |
| 1157 | "test_heatapi_template_create_stack.json")).read() |
| 1158 | test_heatapi_template_update_stack = open(os.path.join(os.path.dirname(__file__), |
| 1159 | "test_heatapi_template_update_stack.json")).read() |
| 1160 | |
| 1161 | print('->>>>>>> test Combined Create Stack ->>>>>>>>>>>>>>>') |
| 1162 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1163 | url = "http://0.0.0.0:8004/v1/tenantabc123/stacks" |
| 1164 | createstackresponse = requests.post(url, |
| 1165 | data=json.dumps(json.loads(test_heatapi_template_create_stack)), |
| 1166 | headers=headers) |
| 1167 | self.assertEqual(createstackresponse.status_code, 201) |
| 1168 | self.assertNotEqual(json.loads(createstackresponse.content)["stack"]["id"], "") |
| 1169 | print(" ") |
| 1170 | |
| 1171 | print('->>>>>>> test Combined Neutron List Ports ->>>>>>>>>>>>>>>') |
| 1172 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1173 | url = "http://0.0.0.0:9696/v2.0/ports" |
| 1174 | listportsesponse = requests.get(url, headers=headers) |
| 1175 | self.assertEqual(listportsesponse.status_code, 200) |
| 1176 | self.assertEqual(len(json.loads(listportsesponse.content)["ports"]), 9) |
| 1177 | for port in json.loads(listportsesponse.content)["ports"]: |
| 1178 | self.assertEqual(len(str(port['fixed_ips'][0]['subnet_id'])), 36) |
| 1179 | print(" ") |
| 1180 | |
| 1181 | print('->>>>>>> test Combined Neutron List Networks ->>>>>>>>>>>>>>>') |
| 1182 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1183 | url = "http://0.0.0.0:9696/v2.0/networks" |
| 1184 | listnetworksesponse = requests.get(url, headers=headers) |
| 1185 | self.assertEqual(listnetworksesponse.status_code, 200) |
| 1186 | self.assertEqual(len(json.loads(listnetworksesponse.content)["networks"]), 10) |
| 1187 | for net in json.loads(listnetworksesponse.content)["networks"]: |
| 1188 | self.assertEqual(len(str(net['subnets'][0])), 36) |
| 1189 | print(" ") |
| 1190 | |
| 1191 | print('->>>>>>> test Combined Update Stack ->>>>>>>>>>>>>>>') |
| 1192 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1193 | url = "http://0.0.0.0:8004/v1/tenantabc123updateStack/stacks/%s"% \ |
| 1194 | json.loads(createstackresponse.content)['stack']['id'] |
| 1195 | updatestackresponse = requests.put(url, |
| 1196 | data=json.dumps(json.loads(test_heatapi_template_update_stack)), |
| 1197 | headers=headers) |
| 1198 | self.assertEqual(updatestackresponse.status_code, 202) |
| 1199 | liststackdetailsresponse = requests.get(url, headers=headers) |
| 1200 | self.assertEqual(json.loads(liststackdetailsresponse.content)["stack"]["stack_status"], "UPDATE_COMPLETE") |
| 1201 | print(" ") |
| 1202 | |
| 1203 | print('->>>>>>> test Combined Neutron List Ports ->>>>>>>>>>>>>>>') |
| 1204 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1205 | url = "http://0.0.0.0:9696/v2.0/ports" |
| 1206 | listportsesponse = requests.get(url, headers=headers) |
| 1207 | self.assertEqual(listportsesponse.status_code, 200) |
| 1208 | self.assertEqual(len(json.loads(listportsesponse.content)["ports"]), 18) |
| 1209 | for port in json.loads(listportsesponse.content)["ports"]: |
| 1210 | self.assertEqual(len(str(port['fixed_ips'][0]['subnet_id'])), 36) |
| 1211 | print(" ") |
| 1212 | |
| 1213 | print('->>>>>>> test Combined Neutron List Networks ->>>>>>>>>>>>>>>') |
| 1214 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1215 | url = "http://0.0.0.0:9696/v2.0/networks" |
| 1216 | listnetworksesponse = requests.get(url, headers=headers) |
| 1217 | self.assertEqual(listnetworksesponse.status_code, 200) |
| 1218 | self.assertEqual(len(json.loads(listnetworksesponse.content)["networks"]), 14) |
| 1219 | for net in json.loads(listnetworksesponse.content)["networks"]: |
| 1220 | self.assertEqual(len(str(net['subnets'][0])), 36) |
| 1221 | print(" ") |
| 1222 | |
| 1223 | |
| 1224 | # workflow create floating ip and assign it to a server |
| 1225 | |
| 1226 | print('->>>>>>> CombinedNeutronCreateFloatingIP ->>>>>>>>>>>>>>>') |
| 1227 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1228 | url = "http://0.0.0.0:9696/v2.0/floatingips" |
| 1229 | createflip = requests.post(url, headers=headers, |
| 1230 | data='{"floatingip":{"floating_network_id":"default"}}') |
| 1231 | self.assertEqual(createflip.status_code, 200) |
| 1232 | self.assertIsNotNone(json.loads(createflip.content)["floatingip"].get("port_id")) |
| 1233 | port_id = json.loads(createflip.content)["floatingip"].get("port_id") |
| 1234 | print(" ") |
| 1235 | |
| 1236 | print('->>>>>>> CombinedNovaGetServer ->>>>>>>>>>>>>>>') |
| 1237 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1238 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers/detail" |
| 1239 | listserverapisdetailedresponse = requests.get(url, headers=headers) |
| 1240 | self.assertEqual(listserverapisdetailedresponse.status_code, 200) |
| 1241 | self.assertEqual(json.loads(listserverapisdetailedresponse.content)["servers"][0]["status"], "ACTIVE") |
| 1242 | server_id = json.loads(listserverapisdetailedresponse.content)["servers"][0]["id"] |
| 1243 | print(" ") |
| 1244 | |
| 1245 | print('->>>>>>> CombinedNovaAssignInterface ->>>>>>>>>>>>>>>') |
| 1246 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1247 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers/%s/os-interface" % server_id |
| 1248 | assign = requests.post(url, headers=headers, |
| 1249 | data='{"interfaceAttachment":{"net_id": "default"}}') |
| 1250 | self.assertEqual(assign.status_code, 202) |
| 1251 | self.assertIsNotNone(json.loads(assign.content)["interfaceAttachment"].get("port_id")) |
| 1252 | port_id = json.loads(assign.content)["interfaceAttachment"].get("port_id") |
| 1253 | print(" ") |
| 1254 | |
| 1255 | print('->>>>>>> CombinedNovaDeleteInterface ->>>>>>>>>>>>>>>') |
| 1256 | print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>') |
| 1257 | url = "http://0.0.0.0:8774/v2.1/id_bla/servers/%s/os-interface/%s" % (server_id, port_id) |
| 1258 | getintfs = requests.delete(url, headers=headers) |
| 1259 | self.assertEqual(getintfs.status_code, 202) |
| 1260 | print(" ") |
| 1261 | |
| 1262 | |
| 1263 | if __name__ == '__main__': |
| 1264 | unittest.main() |