Browse Source

Add new automation tests for system test cases

* nsxt_manage_networks
* nsxt_public_network_availability
* nsxt_connectivity_diff_networks
* nsxt_batch_instance_creation
* nsxt_manage_secgroups
* nsxt_manage_compute_hosts
* nsxt_different_tenants
* nsxt_same_ip_different_tenants

Change-Id: Ic999acb6982b4820adba2241f6c752c125977246
ekhomyakova 2 years ago
parent
commit
a0cd30bae5

+ 12
- 15
doc/test/source/test_suite_system.rst View File

@@ -117,12 +117,12 @@ Steps
117 117
 
118 118
     1. Set up for system tests.
119 119
     2. Log in to Horizon Dashboard.
120
-    3. Create two private networks net_01 and net_02.
121
-    4. Launch 1 instance in each network. Instances should belong to different az (nova and vcenter).
122
-    5. Check that instances can't communicate with each other.
123
-    6. Attach (add interface) both networks to default router.
120
+    3. Create private networks net_01 and net_02 with subnets.
121
+    4. Launch 1 instance on each network. Instances should belong to different az (nova and vcenter).
122
+    5. Attach (add interface) net_01 to default router. Check that instances can't communicate with each other.
123
+    6. Attach net_02 to default router.
124 124
     7. Check that instances can communicate with each other via router.
125
-    8. Detach (delete interface) both networks from default router.
125
+    8. Detach (delete interface) net_01 from default router.
126 126
     9. Check that instances can't communicate with each other.
127 127
     10. Delete created instances.
128 128
     11. Delete created networks.
@@ -251,16 +251,16 @@ Steps
251 251
     1. Set up for system tests.
252 252
     2. Log in to Horizon Dashboard.
253 253
     3. Add two private networks (net01 and net02).
254
-    4. Add one subnet (net01_subnet01: 192.168.101.0/24, net02_subnet01, 192.168.101.0/24) to each network. Disable gateway for all subnets.
254
+    4. Add one subnet (net01_subnet01: 192.168.101.0/24, net02_subnet01, 192.168.102.0/24) to each network. Disable gateway for both subnets.
255 255
     5. Launch 1 instance in each network. Instances should belong to different az (nova and vcenter).
256 256
     6. Create new router (Router_01), set gateway and add interface to external network.
257 257
     7. Enable gateway on subnets. Attach private networks to created router.
258
-    8. Verify that VMs of different networks should communicate between each other.
258
+    8. Verify that VMs of different networks communicate between each other.
259 259
     9. Add one more router (Router_02), set gateway and add interface to external network.
260 260
     10. Detach net_02 from Router_01 and attach it to Router_02.
261 261
     11. Assign floating IPs for all created VMs.
262
-    12. Check that default security group allow the ICMP.
263
-    13. Verify that VMs of different networks should communicate between each other by FIPs.
262
+    12. Check that default security group allows the ICMP.
263
+    13. Verify that VMs of different networks communicate between each other by FIPs.
264 264
     14. Delete instances.
265 265
     15. Detach created networks from routers.
266 266
     16. Delete created networks.
@@ -484,12 +484,9 @@ Steps
484 484
 
485 485
     1. Set up for system tests.
486 486
     2. Navigate to Project -> Compute -> Instances
487
-    3. Launch 5 instance VM_1 simultaneously with image TestVM-VMDK and flavor m1.tiny in vcenter az in default net_04.
488
-    4. All instance should be created without any error.
489
-    5. Launch 5 instance VM_2 simultaneously with image TestVM and flavor m1.tiny in nova az in default net_04.
490
-    6. All instance should be created without any error.
491
-    7. Check connection between VMs (ping, ssh)
492
-    8. Delete all VMs from horizon simultaneously.
487
+    3. Launch 5 instances VM_1 simultaneously in vcenter az in default net. Verify that creation was successful.
488
+    4. Launch 5 instances VM_2 simultaneously in nova az in default net. Verify that creation was successful.
489
+    5. Delete all VMs simultaneously.
493 490
 
494 491
 
495 492
 Expected result

+ 13
- 4
plugin_test/helpers/openstack.py View File

@@ -94,8 +94,7 @@ def check_connection_vms(ip_pair, command='pingv4', result_of_command=0,
94 94
 
95 95
     msg = 'Command "{0}", Actual exit code is NOT {1}'
96 96
     for ip_from in ip_pair:
97
-        with get_ssh_connection(ip_from, instance_creds[0],
98
-                                instance_creds[1]) as ssh:
97
+        with get_ssh_connection(ip_from, *instance_creds, timeout=60*5) as ssh:
99 98
             for ip_to in ip_pair[ip_from]:
100 99
                 logger.info('Check connection from {0} to {1}'.format(
101 100
                     ip_from, ip_to))
@@ -243,8 +242,7 @@ def remote_execute_command(instance1_ip, instance2_ip, command, wait=30):
243 242
         transport.start_client()
244 243
 
245 244
         logger.info("Passing authentication to VM")
246
-        transport.auth_password(
247
-            instance_creds[0], instance_creds[1])
245
+        transport.auth_password(*instance_creds)
248 246
         channel = transport.open_session()
249 247
         channel.get_pty()
250 248
         channel.fileno()
@@ -393,3 +391,14 @@ def create_access_point(os_conn, nics, security_groups, host_num=0):
393 391
         access_point, use_neutron=True)['floating_ip_address']
394 392
     wait(lambda: tcp_ping(access_point_ip, 22), timeout=60 * 5, interval=5)
395 393
     return access_point, access_point_ip
394
+
395
+
396
+def add_gateway_ip(os_conn, subnet_id, ip):
397
+    """Add gateway ip for subnet."""
398
+    os_conn.neutron.update_subnet(subnet_id, {'subnet': {'gateway_ip': ip}})
399
+
400
+
401
+def remove_router_interface(os_conn, router_id, subnet_id):
402
+    """Remove subnet interface from router."""
403
+    os_conn.neutron.remove_interface_router(
404
+        router_id, {"router_id": router_id, "subnet_id": subnet_id})

+ 2
- 1
plugin_test/tests/test_plugin_scale.py View File

@@ -330,7 +330,8 @@ class TestNSXtScale(TestNSXtBase):
330 330
         target_node2 = self.fuel_web.get_nailgun_node_by_name('slave-05')
331 331
         self.fuel_web.vcenter_configure(cluster_id,
332 332
                                         target_node_1=target_node1['hostname'],
333
-                                        target_node_2=target_node2['hostname'])
333
+                                        target_node_2=target_node2['hostname'],
334
+					multiclusters=True)
334 335
 
335 336
         self.show_step(12)  # Redeploy cluster
336 337
         self.fuel_web.deploy_cluster_wait(cluster_id)

+ 817
- 0
plugin_test/tests/test_plugin_system.py View File

@@ -205,6 +205,823 @@ class TestNSXtSystem(TestNSXtBase):
205 205
         vm1.delete()
206 206
         vm2.delete()
207 207
 
208
+    @test(depends_on=[nsxt_setup_system],
209
+          groups=['nsxt_manage_networks'])
210
+    @log_snapshot_after_test
211
+    def nsxt_manage_networks(self):
212
+        """Check abilities to create and terminate networks on NSX.
213
+
214
+        Scenario:
215
+            1. Set up for system tests.
216
+            2. Get access to OpenStack.
217
+            3. Create private networks net_01 and net_02 with subnets.
218
+            4. Launch 1 instance on each network. Instances should belong to
219
+               different az (nova and vcenter).
220
+            5. Attach (add interface) net_01 to default router. Check that
221
+               instances can't communicate with each other.
222
+            6. Attach net_02 to default router.
223
+            7. Check that instances can communicate with each other via router.
224
+            8. Detach (delete interface) net_01 from default router.
225
+            9. Check that instances can't communicate with each other.
226
+            10. Delete created instances.
227
+            11. Delete created networks.
228
+
229
+        Duration: 30 min
230
+        """
231
+        self.show_step(1)  # Set up for system tests
232
+        self.env.revert_snapshot('nsxt_setup_system')
233
+
234
+        self.show_step(2)  # Get access to OpenStack
235
+        cluster_id = self.fuel_web.get_last_created_cluster()
236
+
237
+        os_conn = os_actions.OpenStackActions(
238
+            self.fuel_web.get_public_vip(cluster_id),
239
+            SERVTEST_USERNAME,
240
+            SERVTEST_PASSWORD,
241
+            SERVTEST_TENANT)
242
+
243
+        # Create private networks net_01 and net_02 with subnets
244
+        self.show_step(3)
245
+        net1 = self._create_net(os_conn, 'net_01')
246
+        subnet1 = os_conn.create_subnet(subnet_name=net1['name'],
247
+                                        network_id=net1['id'],
248
+                                        cidr='192.168.1.0/24',
249
+                                        ip_version=4)
250
+
251
+        net2 = self._create_net(os_conn, 'net_02')
252
+        subnet2 = os_conn.create_subnet(subnet_name=net2['name'],
253
+                                        network_id=net2['id'],
254
+                                        cidr='192.168.2.0/24',
255
+                                        ip_version=4)
256
+
257
+        # Launch 2 instances on each network. Instances should belong to
258
+        # different az (nova and vcenter)
259
+        self.show_step(4)
260
+        sg = os_conn.create_sec_group_for_ssh().name
261
+        vm1 = os_help.create_instance(os_conn, net=net1, sg_names=[sg])
262
+        vm2 = os_help.create_instance(os_conn, net=net2, sg_names=[sg],
263
+                                      az='vcenter')
264
+
265
+        vm1_ip = os_conn.get_nova_instance_ip(vm1, net_name=net1['name'])
266
+        vm2_ip = os_conn.get_nova_instance_ip(vm2, net_name=net2['name'])
267
+
268
+        # Attach (add interface) net_01 to default router. Check that
269
+        # instances can't communicate with each other.
270
+        self.show_step(5)
271
+        router_id = os_conn.get_router(os_conn.get_network(
272
+            self.default.ADMIN_NET))['id']
273
+
274
+        os_conn.add_router_interface(router_id=router_id,
275
+                                     subnet_id=subnet1['id'])
276
+        vm1_fip = os_conn.assign_floating_ip(vm1).ip
277
+
278
+        os_help.check_connection_vms({vm1_fip: [vm2_ip]},
279
+                                     result_of_command=1)
280
+
281
+        self.show_step(6)  # Attach net_02 to default router.
282
+        os_conn.add_router_interface(router_id=router_id,
283
+                                     subnet_id=subnet2['id'])
284
+        vm2_fip = os_conn.assign_floating_ip(vm2).ip
285
+
286
+        # Check that instances can communicate with each other via router
287
+        self.show_step(7)
288
+        os_help.check_connection_vms({vm2_fip: [vm1_ip]})
289
+
290
+        # Detach (delete interface) net_01 from default router.
291
+        self.show_step(8)
292
+        vm1.remove_floating_ip(vm1_fip)
293
+        os_help.remove_router_interface(os_conn, router_id, subnet1['id'])
294
+
295
+        # Check that instances can't communicate with each other
296
+        self.show_step(9)
297
+        os_help.check_connection_vms({vm2_fip: [vm1_ip]}, result_of_command=1)
298
+
299
+        self.show_step(10)  # Delete created instances
300
+        vm2.remove_floating_ip(vm2_fip)
301
+        os_help.remove_router_interface(os_conn, router_id, subnet2['id'])
302
+
303
+        os_conn.delete_instance(vm1)
304
+        os_conn.delete_instance(vm2)
305
+        os_conn.verify_srv_deleted(vm1)
306
+        os_conn.verify_srv_deleted(vm2)
307
+
308
+        self.show_step(11)  # Delete created networks
309
+        os_conn.neutron.delete_network(net1['id'])
310
+        os_conn.neutron.delete_network(net2['id'])
311
+
312
+    @test(depends_on=[nsxt_setup_system],
313
+          groups=['nsxt_public_network_availability'])
314
+    @log_snapshot_after_test
315
+    def nsxt_public_network_availability(self):
316
+        """Check connectivity from VMs to public network.
317
+
318
+        Scenario:
319
+            1. Set up for system tests.
320
+            2. Get access to OpenStack.
321
+            3. Launch two instances in default network. Instances should belong
322
+               to different az (nova and vcenter).
323
+            4. Send ping from each instance to 8.8.8.8.
324
+
325
+        Duration: 30 min
326
+        """
327
+        self.show_step(1)  # Set up for system tests
328
+        self.env.revert_snapshot('nsxt_setup_system')
329
+
330
+        self.show_step(2)  # Get access to OpenStack
331
+        cluster_id = self.fuel_web.get_last_created_cluster()
332
+
333
+        os_ip = self.fuel_web.get_public_vip(cluster_id)
334
+        os_conn = os_actions.OpenStackActions(
335
+            os_ip, SERVTEST_USERNAME,
336
+            SERVTEST_PASSWORD,
337
+            SERVTEST_TENANT)
338
+
339
+        # Launch two instances in default network. Instances should belong to
340
+        # different az (nova and vcenter)
341
+        self.show_step(3)
342
+        sg = os_conn.create_sec_group_for_ssh().name
343
+        vm1 = os_help.create_instance(os_conn, sg_names=[sg], az='vcenter')
344
+        vm2 = os_help.create_instance(os_conn, sg_names=[sg])
345
+
346
+        # Send ping from each instance to 8.8.8.8
347
+        self.show_step(4)
348
+        vm1_fip, vm2_fip = \
349
+            os_help.create_and_assign_floating_ips(os_conn, [vm1, vm2])
350
+
351
+        os_help.check_connection_vms({vm1_fip: ['8.8.8.8'],
352
+                                      vm2_fip: ['8.8.8.8']})
353
+
354
+    @test(depends_on=[nsxt_setup_system],
355
+          groups=['nsxt_connectivity_diff_networks'])
356
+    @log_snapshot_after_test
357
+    def nsxt_connectivity_diff_networks(self):
358
+        """Check connection between VMs from different nets through the router.
359
+
360
+        Scenario:
361
+            1. Set up for system tests.
362
+            2. Get access to OpenStack.
363
+            3. Add two private networks (net01 and net02).
364
+            4. Add one subnet  to each network
365
+                 net01_subnet01: 192.168.101.0/24,
366
+                 net02_subnet01: 192.168.102.0/24.
367
+               Disable gateway for both subnets.
368
+            5. Launch 1 instance in each network. Instances should belong to
369
+               different az (nova and vcenter).
370
+            6. Create new router (Router_01), set gateway and add interface
371
+               to external network.
372
+            7. Enable gateway on subnets. Attach private networks to created
373
+               router.
374
+            8. Verify that VMs of different networks communicate between
375
+               each other.
376
+            9. Add one more router (Router_02), set gateway and add interface
377
+               to external network.
378
+            10. Detach net_02 from Router_01 and attach it to Router_02.
379
+            11. Assign floating IPs for all created VMs.
380
+            12. Check that default security group allows the ICMP.
381
+            13. Verify that VMs of different networks communicate between
382
+                each other by FIPs.
383
+            14. Delete instances.
384
+            15. Detach created networks from routers.
385
+            16. Delete created networks.
386
+            17. Delete created routers.
387
+
388
+        Duration: 30 min
389
+        """
390
+        self.show_step(1)  # Set up for system tests
391
+        self.env.revert_snapshot('nsxt_setup_system')
392
+
393
+        self.show_step(2)  # Get access to OpenStack
394
+        cluster_id = self.fuel_web.get_last_created_cluster()
395
+        os_conn = os_actions.OpenStackActions(
396
+            self.fuel_web.get_public_vip(cluster_id),
397
+            SERVTEST_USERNAME,
398
+            SERVTEST_PASSWORD,
399
+            SERVTEST_TENANT)
400
+
401
+        self.show_step(3)  # Add two private networks (net01 and net02)
402
+        net1 = self._create_net(os_conn, 'net_01')
403
+        net2 = self._create_net(os_conn, 'net_02')
404
+
405
+        # Add one subnet to each network: net01_subnet01 (192.168.101.0/24) and
406
+        # net02_subnet01 (192.168.102.0/24). Disable gateway for both subnets
407
+        self.show_step(4)
408
+        subnet1 = os_conn.create_subnet(
409
+            subnet_name='net01_subnet01',
410
+            network_id=net1['id'],
411
+            cidr='192.168.101.0/24',
412
+            allocation_pools=[
413
+                {'start': '192.168.101.2','end': '192.168.101.254'}
414
+            ],
415
+            ip_version=4,
416
+            gateway_ip=None)
417
+
418
+        subnet2 = os_conn.create_subnet(
419
+            subnet_name='net02_subnet01',
420
+            network_id=net2['id'],
421
+            cidr='192.168.102.0/24',
422
+            allocation_pools=[
423
+                {'start': '192.168.102.2', 'end': '192.168.102.254'}
424
+            ],
425
+            ip_version=4,
426
+            gateway_ip=None)
427
+
428
+        # Launch 1 instance in each network. Instances should belong to
429
+        # different az (nova and vcenter)
430
+        self.show_step(5)
431
+        sg = os_conn.create_sec_group_for_ssh().name
432
+        vm1 = os_help.create_instance(os_conn, net=net1, sg_names=[sg],
433
+                                      az='vcenter')
434
+        vm2 = os_help.create_instance(os_conn, net=net2, sg_names=[sg])
435
+
436
+        # Create new router (Router_01), set gateway and add interface to
437
+        # external network
438
+        self.show_step(6)
439
+        tenant = os_conn.get_tenant(SERVTEST_TENANT)
440
+        router1 = os_conn.create_router('Router_01', tenant)
441
+
442
+        # Enable gateway on subnets. Attach private networks to created router
443
+        self.show_step(7)
444
+        os_help.add_gateway_ip(os_conn, subnet1['id'], '192.168.101.1')
445
+        os_conn.add_router_interface(router_id=router1['id'],
446
+                                     subnet_id=subnet1['id'])
447
+
448
+        os_help.add_gateway_ip(os_conn, subnet2['id'], '192.168.102.1')
449
+        os_conn.add_router_interface(router_id=router1['id'],
450
+                                     subnet_id=subnet2['id'])
451
+
452
+        # Verify that VMs of different networks communicate between each other
453
+        self.show_step(8)
454
+        vm1_ip = os_conn.get_nova_instance_ip(vm1, net_name=net1['name'])
455
+        vm2_ip = os_conn.get_nova_instance_ip(vm2, net_name=net2['name'])
456
+
457
+        vm1_fip, vm2_fip = \
458
+            os_help.create_and_assign_floating_ips(os_conn, [vm1, vm2])
459
+
460
+        os_help.check_connection_vms({vm1_fip: [vm2_ip], vm2_fip: [vm1_ip]})
461
+
462
+        # Add one more router (Router_02), set gateway and add interface
463
+        # to external network
464
+        self.show_step(9)
465
+        router2 = os_conn.create_router('Router_02', tenant)
466
+
467
+        # Detach net_02 from Router_01 and attach it to Router_02
468
+        self.show_step(10)
469
+        vm2.remove_floating_ip(vm2_fip)
470
+        os_help.remove_router_interface(os_conn, router1['id'], subnet2['id'])
471
+        os_conn.add_router_interface(router_id=router2['id'],
472
+                                     subnet_id=subnet2['id'])
473
+
474
+        self.show_step(11)  # Assign floating IPs for all created VMs
475
+        vm2_fip = os_help.create_and_assign_floating_ips(os_conn, [vm2])[0]
476
+
477
+        self.show_step(12)  # Check that default security group allow the ICMP
478
+
479
+        # Verify that VMs of different networks communicate between each
480
+        # other by FIPs
481
+        self.show_step(13)
482
+        os_help.check_connection_vms({vm1_fip: [vm2_fip], vm2_fip: [vm1_fip]})
483
+
484
+        self.show_step(14)  # Delete instances
485
+        vm1.remove_floating_ip(vm1_fip)
486
+        vm2.remove_floating_ip(vm2_fip)
487
+        os_conn.delete_instance(vm1)
488
+        os_conn.delete_instance(vm2)
489
+
490
+        self.show_step(15)  # Detach created networks from routers
491
+        os_help.remove_router_interface(os_conn, router1['id'], subnet1['id'])
492
+        os_help.remove_router_interface(os_conn, router2['id'], subnet2['id'])
493
+
494
+        os_conn.verify_srv_deleted(vm2)
495
+        os_conn.verify_srv_deleted(vm1)
496
+
497
+        self.show_step(16)  # Delete created networks
498
+        os_conn.neutron.delete_network(net1['id'])
499
+        os_conn.neutron.delete_network(net2['id'])
500
+
501
+        self.show_step(17)  # Delete created routers
502
+        os_conn.neutron.delete_router(router1['id'])
503
+        os_conn.neutron.delete_router(router2['id'])
504
+
505
+    @test(depends_on=[nsxt_setup_system],
506
+          groups=['nsxt_batch_instance_creation'])
507
+    @log_snapshot_after_test
508
+    def nsxt_batch_instance_creation(self):
509
+        """Check instance creation in the one group simultaneously.
510
+
511
+        Scenario:
512
+            1. Set up for system tests.
513
+            2. Get access to OpenStack.
514
+            3. Launch 5 instances VM_1 simultaneously with image TestVM-VMDK
515
+               and flavor m1.tiny in vcenter az in default net.
516
+            4. Launch 5 instances VM_2 simultaneously with image TestVM and
517
+               flavor m1.tiny in nova az in default net.
518
+            5. Delete all VMs simultaneously.
519
+
520
+        Duration: 30 min
521
+        """
522
+        self.show_step(1)  # Set up for system tests
523
+        # self.env.revert_snapshot('nsxt_setup_system')
524
+
525
+        self.show_step(2)  # Get access to OpenStack
526
+        cluster_id = self.fuel_web.get_last_created_cluster()
527
+        os_conn = os_actions.OpenStackActions(
528
+            self.fuel_web.get_public_vip(cluster_id),
529
+            SERVTEST_USERNAME,
530
+            SERVTEST_PASSWORD,
531
+            SERVTEST_TENANT)
532
+
533
+        # Launch 5 instances VM_1 simultaneously. Image: TestVM-VMDK,
534
+        # flavor: m1.tiny, az: vcenter, net: default
535
+        self.show_step(3)
536
+        sg = os_conn.create_sec_group_for_ssh().name
537
+        net_name = self.default.PRIVATE_NET
538
+        net = os_conn.get_network(net_name)
539
+        flavors = os_conn.nova.flavors.list()
540
+        micro_flavor = [f for f in flavors if f.name == 'm1.micro'][0]
541
+
542
+        image = os_conn.get_image(os_help.zone_image_maps['vcenter'])
543
+        os_conn.nova.servers.create(
544
+            name='VM_1',
545
+            image=image,
546
+            flavor=micro_flavor,
547
+            min_count=5,
548
+            availability_zone='vcenter',
549
+            nics=[{'net-id': net['id']}],
550
+            security_groups=[sg])
551
+        os_help.verify_instance_state(os_conn)
552
+
553
+        # Launch 5 instances VM_2 simultaneously. Image TestVM,
554
+        # flavor: m1.tiny, az: nova, net: default
555
+        self.show_step(4)
556
+        image = os_conn.get_image(os_help.zone_image_maps['nova'])
557
+        os_conn.nova.servers.create(
558
+            name='VM_2',
559
+            image=image,
560
+            flavor=micro_flavor,
561
+            min_count=5,
562
+            availability_zone='nova',
563
+            nics=[{'net-id': net['id']}],
564
+            security_groups=[sg])
565
+        os_help.verify_instance_state(os_conn)
566
+
567
+        self.show_step(5)  # Delete all VMs simultaneously
568
+        for instance in instances:
569
+            instance.delete()
570
+        for instance in instances:
571
+            os_conn.verify_srv_deleted(instance)
572
+
573
+    @test(depends_on=[nsxt_setup_system],
574
+          groups=['nsxt_manage_secgroups'])
575
+    @log_snapshot_after_test
576
+    def nsxt_manage_secgroups(self):
577
+        """Check ability to create and delete security group.
578
+
579
+        Scenario:
580
+            1. Set up for system tests.
581
+            2. Get access to OpenStack.
582
+            3. Create new security group with default rules.
583
+            4. Add ingress rule for ICMP protocol.
584
+            5. Launch two instances in default network. Instances should
585
+               belong to different az (nova and vcenter).
586
+            6. Attach created security group to instances.
587
+            7. Check that instances can ping each other.
588
+            8. Delete ingress rule for ICMP protocol.
589
+            9. Check that instances can't ping each other.
590
+            10. Delete instances.
591
+            11. Delete security group.
592
+
593
+        Duration: 30 min
594
+        """
595
+        self.show_step(1)  # Set up for system tests
596
+        self.env.revert_snapshot('nsxt_setup_system')
597
+
598
+        self.show_step(2)  # Get access to OpenStack
599
+        cluster_id = self.fuel_web.get_last_created_cluster()
600
+        os_conn = os_actions.OpenStackActions(
601
+            self.fuel_web.get_public_vip(cluster_id),
602
+            SERVTEST_USERNAME,
603
+            SERVTEST_PASSWORD,
604
+            SERVTEST_TENANT)
605
+
606
+        # Create new security group with default rules
607
+        self.show_step(3)
608
+        sg1 = os_conn.nova.security_groups.create('SG_1', 'test-icmp')
609
+
610
+        # Add ingress rule for ICMP protocol
611
+        self.show_step(4)
612
+        icmp = {
613
+            'ip_protocol': 'icmp',
614
+            'from_port': -1,
615
+            'to_port': -1,
616
+            'cidr': '0.0.0.0/0'
617
+        }
618
+        sg1_rule = os_conn.nova.security_group_rules.create(sg1.id, **icmp)
619
+
620
+        # Launch two instances in default network. Instances should belong to
621
+        # different az (nova and vcenter)
622
+        self.show_step(5)
623
+        ssh = {
624
+            'ip_protocol': 'tcp',
625
+            'from_port': 22,
626
+            'to_port': 22,
627
+            'cidr': '0.0.0.0/0'
628
+        }
629
+        ssh_sg = os_conn.nova.security_groups.create('ssh_sg', 'test-ssh')
630
+        os_conn.nova.security_group_rules.create(ssh_sg.id, **ssh)
631
+
632
+        vm1 = os_help.create_instance(os_conn, sg_names=[ssh_sg.name])
633
+        vm2 = os_help.create_instance(os_conn, sg_names=[ssh_sg.name],
634
+                                      az='vcenter')
635
+
636
+        # Attach created security group to instances
637
+        self.show_step(6)
638
+        os_conn.nova.servers.add_security_group(vm1, sg1.name)
639
+        os_conn.nova.servers.add_security_group(vm2, sg1.name)
640
+
641
+        # Check that instances can ping each other
642
+        self.show_step(7)
643
+        vm1_fip, vm2_fip = \
644
+            os_help.create_and_assign_floating_ips(os_conn, [vm1, vm2])
645
+
646
+        net_name = self.default.PRIVATE_NET
647
+        vm1_ip = os_conn.get_nova_instance_ip(vm1, net_name=net_name)
648
+        vm2_ip = os_conn.get_nova_instance_ip(vm2, net_name=net_name)
649
+
650
+        os_help.check_connection_vms({vm1_fip: [vm2_ip], vm2_fip: [vm1_ip]})
651
+
652
+        # Delete ingress rule for ICMP protocol
653
+        self.show_step(8)
654
+        os_conn.nova.security_group_rules.delete(sg1_rule)
655
+
656
+        # Check that instances can't ping each other
657
+        self.show_step(9)
658
+        os_help.check_connection_vms({vm1_fip: [vm2_ip], vm2_fip: [vm1_ip]},
659
+                                     result_of_command=1)
660
+
661
+        # Delete instances
662
+        self.show_step(10)
663
+        os_conn.delete_instance(vm1)
664
+        os_conn.delete_instance(vm2)
665
+        os_conn.verify_srv_deleted(vm1)
666
+        os_conn.verify_srv_deleted(vm2)
667
+
668
+        # Delete security group
669
+        self.show_step(11)
670
+        os_conn.nova.security_groups.delete(sg1)
671
+        os_conn.nova.security_groups.delete(ssh_sg)
672
+
673
+    @test(depends_on=[nsxt_setup_system],
674
+          groups=['nsxt_manage_compute_hosts'])
675
+    @log_snapshot_after_test
676
+    def nsxt_manage_compute_hosts(self):
677
+        """Verify that instances could be launched on enabled compute host.
678
+
679
+        Scenario:
680
+            1. Set up for system tests.
681
+            2. Disable one of compute host in each availability zone
682
+               (vcenter and nova).
683
+            3. Create several instances in both az.
684
+            4. Check that instances were created on enabled compute hosts.
685
+            5. Disable second compute host and enable first one in each
686
+               availability zone (vcenter and nova).
687
+            6. Create several instances in both az.
688
+            7. Check that instances were created on enabled compute hosts.
689
+
690
+        Duration: 30 min
691
+        """
692
+        self.show_step(1)  # Set up for system tests
693
+        self.env.revert_snapshot('nsxt_setup_system')
694
+
695
+        cluster_id = self.fuel_web.get_last_created_cluster()
696
+        os_conn = os_actions.OpenStackActions(
697
+            self.fuel_web.get_public_vip(cluster_id),
698
+            SERVTEST_USERNAME,
699
+            SERVTEST_PASSWORD,
700
+            SERVTEST_TENANT)
701
+
702
+        # Disable one of compute host in each availability zone
703
+        self.show_step(2)
704
+        services = os_conn.nova.services.list(binary='nova-compute')
705
+        disabled_services = [
706
+            [srv for srv in services if srv.zone == 'vcenter'].pop(),
707
+            [srv for srv in services if srv.zone == 'nova'].pop()
708
+        ]
709
+        for service in disabled_services:
710
+            os_conn.disable_nova_service(service)
711
+
712
+        self.show_step(3)  # Create several instances in both az
713
+        instances = []
714
+        for i in range(1):
715
+            instances.append(os_help.create_instance(os_conn, az='vcenter'))
716
+            instances.append(os_help.create_instance(os_conn))
717
+
718
+        # Check that instances were created on enabled compute hosts
719
+        self.show_step(4)
720
+        vmware_hosts = [srv.host for srv in disabled_services]
721
+        for inst in instances:
722
+            inst_host = getattr(inst, 'OS-EXT-SRV-ATTR:host')
723
+            assert_true(inst_host not in vmware_hosts,
724
+                        'Instance was launched on disabled cluster')
725
+        for i in instances:
726
+            i.delete()
727
+        instances = []
728
+
729
+        # Disable second compute host and enable first one in each
730
+        # availability zone (vcenter and nova)
731
+        self.show_step(5)
732
+        for service in services:
733
+            if service in disabled_services:
734
+                os_conn.enable_nova_service(service)
735
+            else:
736
+                os_conn.disable_nova_service(service)
737
+
738
+        self.show_step(6)  # Create several instances in both az
739
+        for i in range(1):
740
+            instances.append(os_help.create_instance(os_conn, az='vcenter'))
741
+            instances.append(os_help.create_instance(os_conn))
742
+
743
+        # Check that instances were created on enabled compute hosts
744
+        self.show_step(7)
745
+        for inst in instances:
746
+            inst_host = getattr(inst, 'OS-EXT-SRV-ATTR:host')
747
+            assert_true(inst_host in vmware_hosts,
748
+                        'Instance was launched on disabled cluster')
749
+
750
+        for service in services:
751
+            if service not in disabled_services:
752
+                os_conn.enable_nova_service(service)
753
+        for i in instances:
754
+            i.delete()
755
+
756
+    @test(depends_on=[nsxt_setup_system],
757
+          groups=['nsxt_different_tenants'])
758
+    @log_snapshot_after_test
759
+    def nsxt_different_tenants(self):
760
+        """Check isolation between VMs in different tenants.
761
+
762
+        Scenario:
763
+            1. Set up for system tests.
764
+            2. Get access to OpenStack.
765
+            3. Create new tenant with new user.
766
+            4. In new tenant create network with subnet.
767
+            5. In new tenant create router, set gateway and add interface.
768
+            6. In new tenant launch instance and associate floating ip with vm.
769
+            7. Launch instance in default network and associate floating ip
770
+               with vm.
771
+            8. Check that default security group allow ingress icmp traffic.
772
+            9. Send icmp ping between instances in different tenants via
773
+               floating ip.
774
+
775
+        Duration: 30 min
776
+        """
777
+        self.show_step(1)  # Set up for system tests
778
+        self.env.revert_snapshot('nsxt_setup_system')
779
+
780
+        self.show_step(2)  # Get access to OpenStack
781
+        cluster_id = self.fuel_web.get_last_created_cluster()
782
+
783
+        os_ip = self.fuel_web.get_public_vip(cluster_id)
784
+        os_conn = os_actions.OpenStackActions(
785
+            os_ip, SERVTEST_USERNAME,
786
+            SERVTEST_PASSWORD,
787
+            SERVTEST_TENANT)
788
+
789
+        self.show_step(3)  # Create new tenant with new user
790
+        tenant = os_conn.create_tenant('test_tenant')
791
+
792
+        user = os_conn.create_user('test', 'test', tenant)
793
+        os_help.add_role_to_user(os_conn, 'test', 'admin', 'test_tenant')
794
+
795
+        os_conn_test = os_actions.OpenStackActions(os_ip, 'test', 'test',
796
+                                                   'test_tenant')
797
+
798
+        self.show_step(4)  # In new tenant create network with subnet
799
+        net1 = os_conn_test.create_network(network_name='net_01',
800
+                                           tenant_id=tenant.id)['network']
801
+        subnet1 = os_conn_test.create_subnet(
802
+            subnet_name=net1['name'],
803
+            network_id=net1['id'],
804
+            cidr='192.168.1.0/24',
805
+            ip_version=4)
806
+
807
+        # In new tenant create router, set gateway and add interface
808
+        self.show_step(5)
809
+        router = os_conn_test.create_router('test_router', tenant)
810
+        os_conn_test.add_router_interface(router_id=router["id"],
811
+                                          subnet_id=subnet1["id"])
812
+
813
+        # In new tenant launch instance and associate floating ip with vm
814
+        self.show_step(6)
815
+        default_net = self.default.PRIVATE_NET
816
+        sg = os_conn_test.create_sec_group_for_ssh().name
817
+        vm1 = os_help.create_instance(os_conn_test, sg_names=[sg])
818
+
819
+        vm1_fip = os_conn_test.assign_floating_ip(vm1).ip
820
+        vm1_ip = os_conn.get_nova_instance_ip(vm1, net_name=default_net)
821
+
822
+        # Launch instance in default network and associate floating ip with vm
823
+        self.show_step(7)
824
+        sg = os_conn.create_sec_group_for_ssh().name
825
+        vm2 = os_help.create_instance(os_conn, sg_names=[sg], az='vcenter')
826
+
827
+        vm2_fip = os_conn.assign_floating_ip(vm2).ip
828
+        vm2_ip = os_conn.get_nova_instance_ip(vm2, net_name=default_net)
829
+
830
+        # Check that default security group allow ingress icmp traffic
831
+        self.show_step(8)
832
+
833
+        # Send icmp ping between instances in different tenants via floating ip
834
+        self.show_step(9)
835
+        os_help.check_connection_vms({vm1_fip: [vm2_ip], vm2_fip: [vm1_ip]})
836
+
837
+        # Cleanup
838
+        vm1.delete()
839
+        vm2.delete()
840
+        os_help.remove_router_interface(os_conn_test,
841
+                                        router['id'], subnet1['id'])
842
+        os_conn.neutron.delete_network(net1['id'])
843
+        os_conn.neutron.delete_router(router['id'])
844
+
845
+        os_conn.delete_tenant(tenant)
846
+        os_conn.delete_user(user)
847
+
848
+    @test(depends_on=[nsxt_setup_system],
849
+          groups=['nsxt_same_ip_different_tenants'])
850
+    @log_snapshot_after_test
851
+    def nsxt_same_ip_different_tenants(self):
852
+        """Check connectivity between VMs with same ip in different tenants.
853
+
854
+        Scenario:
855
+            1. Set up for system tests.
856
+            2. Get access to OpenStack.
857
+            3. Create 2 non-admin tenants 'test_1' and 'test_2' with common
858
+               admin user.
859
+            4. In tenant 'test_1' create network 'net1' and subnet 'subnet1'
860
+               with CIDR 10.0.0.0/24.
861
+            5. In tenant 'test_1' create router 'router1' and attach 'net1'
862
+               to it.
863
+            6. In tenant 'test_1' create security group 'SG_1' and add rule
864
+               that allows ingress icmp traffic.
865
+            7. In tenant 'test_1' launch two instances (VM_1 and VM_2) in
866
+               created network with created security group. Instances should
867
+               belong to different az (nova and vcenter).
868
+            8. Assign floating IPs for created VMs.
869
+            9. In tenant 'test_2' create network 'net2' and subnet 'subnet2'
870
+               with CIDR 10.0.0.0/24.
871
+            10. In tenant 'test_2' create router 'router2' and attach 'net2'
872
+                to it.
873
+            11. In tenant 'test_2' create security group 'SG_2' and add rule
874
+                that allows ingress icmp traffic.
875
+            12. In tenant 'test_2' launch two instances (VM_3 and VM_4) in
876
+                created network with created security group. Instances should
877
+                belong to different az (nova and vcenter).
878
+            13. Assign floating IPs for created VMs.
879
+            14. Verify that VMs with same ip on different tenants communicate
880
+                between each other by FIPs. Send icmp ping from VM_1 to VM_3,
881
+                VM_2 to VM_4 and vice versa.
882
+
883
+        Duration: 30 min
884
+        """
885
+        icmp_rule = {
886
+            'ip_protocol': 'icmp',
887
+            'from_port': -1,
888
+            'to_port': -1,
889
+            'cidr': '0.0.0.0/0',
890
+        }
891
+
892
+        self.show_step(1)  # Set up for system tests
893
+        self.env.revert_snapshot('nsxt_setup_system')
894
+
895
+        self.show_step(2)  # Get access to OpenStack
896
+        cluster_id = self.fuel_web.get_last_created_cluster()
897
+
898
+        os_ip = self.fuel_web.get_public_vip(cluster_id)
899
+        os_conn = os_actions.OpenStackActions(
900
+            os_ip, SERVTEST_USERNAME,
901
+            SERVTEST_PASSWORD,
902
+            SERVTEST_TENANT)
903
+
904
+        # Create 2 non-admin tenants 'test_1' and 'test_2' with common
905
+        # admin user
906
+        self.show_step(3)
907
+        tenant1 = os_conn.create_tenant('test_1')
908
+        tenant2 = os_conn.create_tenant('test_2')
909
+
910
+        os_help.add_role_to_user(os_conn, 'admin', 'admin', 'test_1')
911
+        os_help.add_role_to_user(os_conn, 'admin', 'admin', 'test_2')
912
+
913
+        os_conn1 = os_actions.OpenStackActions(os_ip, 'admin',
914
+                                               'admin', 'test_1')
915
+        os_conn2 = os_actions.OpenStackActions(os_ip, 'admin',
916
+                                               'admin', 'test_2')
917
+
918
+        # In tenant 'test_1' create network 'net1' and subnet 'subnet1' with
919
+        # CIDR 10.0.0.0/24
920
+        self.show_step(4)
921
+        net1 = os_conn1.create_network(network_name='net01',
922
+                                       tenant_id=tenant1.id)['network']
923
+        subnet1 = os_conn1.create_subnet(
924
+            subnet_name='subnet1',
925
+            network_id=net1['id'],
926
+            cidr='10.0.0.0/24',
927
+            ip_version=4)
928
+
929
+        # In tenant 'test_1' create router 'router1' and attach 'net1' to it
930
+        self.show_step(5)
931
+        router1 = os_conn1.create_router('router1', tenant1)
932
+        os_conn1.add_router_interface(router_id=router1["id"],
933
+                                      subnet_id=subnet1["id"])
934
+
935
+        # In tenant 'test_1' create security group 'SG_1' and add rule that
936
+        # allows ingress icmp traffic
937
+        self.show_step(6)
938
+        sg1 = os_conn1.nova.security_groups.create('SG_1', 'descr')
939
+        os_conn1.nova.security_group_rules.create(sg1.id, **icmp_rule)
940
+
941
+        # In tenant 'test_1' launch two instances (VM_1 and VM_2) in created
942
+        # network with created security group. Instances should belong to
943
+        # different az
944
+        self.show_step(7)
945
+        sg = os_conn1.create_sec_group_for_ssh().name
946
+        vm1 = os_help.create_instance(os_conn1, net=net1,
947
+                                      sg_names=[sg, sg1.name])
948
+        vm2 = os_help.create_instance(os_conn1, net=net1, az='vcenter',
949
+                                      sg_names=[sg, sg1.name])
950
+
951
+        self.show_step(8)  # Assign floating IPs for created VMs
952
+        vm1_fip = os_conn1.assign_floating_ip(vm1).ip
953
+        vm2_fip = os_conn1.assign_floating_ip(vm2).ip
954
+
955
+        # In tenant 'test_2' create network 'net2' and subnet 'subnet2' with
956
+        # CIDR 10.0.0.0/24
957
+        self.show_step(9)
958
+        net2 = os_conn2.create_network(network_name='net02',
959
+                                       tenant_id=tenant2.id)['network']
960
+
961
+        subnet2 = os_conn2.create_subnet(
962
+            subnet_name='subnet2',
963
+            network_id=net2['id'],
964
+            cidr='10.0.0.0/24',
965
+            ip_version=4)
966
+
967
+        # In tenant 'test_2' create router 'router2' and attach 'net2' to it
968
+        self.show_step(10)
969
+        router2 = os_conn2.create_router('router2', tenant2)
970
+        os_conn2.add_router_interface(router_id=router2["id"],
971
+                                      subnet_id=subnet2["id"])
972
+
973
+        # In tenant 'test_2' create security group 'SG_2' and add rule that
974
+        # allows ingress icmp traffic
975
+        self.show_step(11)
976
+        sg = os_conn2.create_sec_group_for_ssh().name
977
+        sg2 = os_conn2.nova.security_groups.create('SG_2', 'descr')
978
+        os_conn2.nova.security_group_rules.create(sg2.id, **icmp_rule)
979
+
980
+        # In tenant 'test_2' launch two instances (VM_3 and VM_4) in created
981
+        # network with created security group. Instances should belong to
982
+        # different az
983
+        self.show_step(12)
984
+        vm3 = os_help.create_instance(os_conn2, net=net2,
985
+                                      sg_names=[sg, sg2.name])
986
+        vm4 = os_help.create_instance(os_conn2, net=net2, az='vcenter',
987
+                                      sg_names=[sg, sg2.name])
988
+
989
+        self.show_step(13)  # Assign floating IPs for created VMs
990
+        vm3_fip = os_conn2.assign_floating_ip(vm3).ip
991
+        vm4_fip = os_conn2.assign_floating_ip(vm4).ip
992
+
993
+        # Verify that VMs with same ip on different tenants communicate
994
+        # between each other by FIPs. Send icmp ping from VM_1 to VM_3,
995
+        # VM_2 to VM_4 and vice versa
996
+        self.show_step(14)
997
+        os_help.check_connection_vms({vm1_fip: [vm3_fip], vm3_fip: [vm1_fip],
998
+                                      vm2_fip: [vm4_fip], vm4_fip: [vm2_fip]})
999
+
1000
+        vms = (vm1, vm2, vm3, vm4)
1001
+
1002
+        # Cleanup
1003
+        for vm, fip in zip(vms, (vm1_fip, vm2_fip, vm3_fip, vm4_fip)):
1004
+            vm.remove_floating_ip(fip)
1005
+            vm.delete()
1006
+
1007
+        os_help.remove_router_interface(os_conn1, router1['id'], subnet1['id'])
1008
+        os_help.remove_router_interface(os_conn2, router2['id'], subnet2['id'])
1009
+
1010
+        for vm in (vm1, vm2):
1011
+            os_conn.verify_srv_deleted(vm)
1012
+
1013
+        os_conn.neutron.delete_router(router1['id'])
1014
+        os_conn.neutron.delete_router(router2['id'])
1015
+
1016
+        for vm in (vm3, vm4):
1017
+            os_conn.verify_srv_deleted(vm)
1018
+
1019
+        os_conn.neutron.delete_network(net1['id'])
1020
+        os_conn.neutron.delete_network(net2['id'])
1021
+
1022
+        os_conn.delete_tenant(tenant1)
1023
+        os_conn.delete_tenant(tenant2)
1024
+
208 1025
     @test(depends_on=[nsxt_setup_system],
209 1026
           groups=['nsxt_hot'])
210 1027
     @log_snapshot_after_test

Loading…
Cancel
Save