Browse Source

Adds a mixed IPv4/IPv6 members traffic test

This patch adds a traffic scenario test for a load balancer with one
IPv4 member and one IPv6 member.
It also makes sure the cirros web servers enable the IPv6 address
assigned to them.

Story: 1627892
Task: 5311
Depends-On: https://review.openstack.org/611460

Change-Id: Ic640c89b5a6ef0d6aade386a910b0d023520aedc
Michael Johnson 6 months ago
parent
commit
bf916df9ad

+ 63
- 0
octavia_tempest_plugin/tests/scenario/v2/test_traffic_ops.py View File

@@ -620,3 +620,66 @@ class TrafficOperationsScenarioTest(test_base.LoadBalancerBaseTestWithCompute):
620 620
         self.assertConsistentResponse((403, None),
621 621
                                       url_for_member1,
622 622
                                       headers={'reject': 'true'})
623
+
624
+    @testtools.skipIf(CONF.load_balancer.test_with_noop,
625
+                      'Traffic tests will not work in noop mode.')
626
+    @testtools.skipUnless(CONF.load_balancer.test_with_ipv6,
627
+                          'Mixed IPv4/IPv6 member test requires IPv6.')
628
+    @decorators.idempotent_id('20b6b671-0101-4bed-a249-9af6ee3aa6d9')
629
+    def test_mixed_ipv4_ipv6_members_traffic(self):
630
+        """Tests traffic through a loadbalancer with IPv4 and IPv6 members.
631
+
632
+        * Set up members on a loadbalancer.
633
+        * Test traffic to ensure it is balanced properly.
634
+        """
635
+        # Set up Member 1 for Webserver 1
636
+        member1_name = data_utils.rand_name("lb_member_member1-traffic")
637
+        member1_kwargs = {
638
+            const.POOL_ID: self.pool_id,
639
+            const.NAME: member1_name,
640
+            const.ADMIN_STATE_UP: True,
641
+            const.ADDRESS: self.webserver1_ip,
642
+            const.PROTOCOL_PORT: 80,
643
+        }
644
+        if self.lb_member_1_subnet:
645
+            member1_kwargs[const.SUBNET_ID] = self.lb_member_1_subnet[const.ID]
646
+
647
+        member1 = self.mem_member_client.create_member(
648
+            **member1_kwargs)
649
+        self.addCleanup(
650
+            self.mem_member_client.cleanup_member,
651
+            member1[const.ID], pool_id=self.pool_id,
652
+            lb_client=self.mem_lb_client, lb_id=self.lb_id)
653
+        waiters.wait_for_status(
654
+            self.mem_lb_client.show_loadbalancer, self.lb_id,
655
+            const.PROVISIONING_STATUS, const.ACTIVE,
656
+            CONF.load_balancer.check_interval,
657
+            CONF.load_balancer.check_timeout)
658
+
659
+        # Set up Member 2 for Webserver 2
660
+        member2_name = data_utils.rand_name("lb_member_member2-traffic")
661
+        member2_kwargs = {
662
+            const.POOL_ID: self.pool_id,
663
+            const.NAME: member2_name,
664
+            const.ADMIN_STATE_UP: True,
665
+            const.ADDRESS: self.webserver2_ipv6,
666
+            const.PROTOCOL_PORT: 80,
667
+        }
668
+        if self.lb_member_2_ipv6_subnet:
669
+            member2_kwargs[const.SUBNET_ID] = (
670
+                self.lb_member_2_ipv6_subnet[const.ID])
671
+
672
+        member2 = self.mem_member_client.create_member(
673
+            **member2_kwargs)
674
+        self.addCleanup(
675
+            self.mem_member_client.cleanup_member,
676
+            member2[const.ID], pool_id=self.pool_id,
677
+            lb_client=self.mem_lb_client, lb_id=self.lb_id)
678
+        waiters.wait_for_status(
679
+            self.mem_lb_client.show_loadbalancer, self.lb_id,
680
+            const.PROVISIONING_STATUS, const.ACTIVE,
681
+            CONF.load_balancer.check_interval,
682
+            CONF.load_balancer.check_timeout)
683
+
684
+        # Send some traffic
685
+        self.check_members_balanced(self.lb_vip_address)

+ 32
- 0
octavia_tempest_plugin/tests/test_base.py View File

@@ -305,6 +305,10 @@ class LoadBalancerBaseTest(test.BaseTestCase):
305 305
                 'cidr': CONF.load_balancer.member_1_ipv6_subnet_cidr,
306 306
                 'ip_version': 6}
307 307
             result = cls.lb_mem_subnet_client.create_subnet(**subnet_kwargs)
308
+            cls.lb_member_1_subnet_prefix = (
309
+                CONF.load_balancer.member_1_ipv6_subnet_cidr.rpartition('/')[2]
310
+                )
311
+            assert(cls.lb_member_1_subnet_prefix.isdigit())
308 312
             cls.lb_member_1_ipv6_subnet = result['subnet']
309 313
             LOG.info('lb_member_1_ipv6_subnet: {}'.format(
310 314
                 cls.lb_member_1_ipv6_subnet))
@@ -354,6 +358,10 @@ class LoadBalancerBaseTest(test.BaseTestCase):
354 358
                 'cidr': CONF.load_balancer.member_2_ipv6_subnet_cidr,
355 359
                 'ip_version': 6}
356 360
             result = cls.lb_mem_subnet_client.create_subnet(**subnet_kwargs)
361
+            cls.lb_member_2_subnet_prefix = (
362
+                CONF.load_balancer.member_2_ipv6_subnet_cidr.rpartition('/')[2]
363
+                )
364
+            assert(cls.lb_member_2_subnet_prefix.isdigit())
357 365
             cls.lb_member_2_ipv6_subnet = result['subnet']
358 366
             LOG.info('lb_member_2_ipv6_subnet: {}'.format(
359 367
                 cls.lb_member_2_ipv6_subnet))
@@ -520,6 +528,17 @@ class LoadBalancerBaseTestWithCompute(LoadBalancerBaseTest):
520 528
         LOG.debug('Octavia Setup: webserver2_public_ip = {}'.format(
521 529
             cls.webserver2_public_ip))
522 530
 
531
+        if CONF.load_balancer.test_with_ipv6:
532
+            # Enable the IPv6 nic in webserver 1
533
+            cls._enable_ipv6_nic_webserver(
534
+                cls.webserver1_public_ip, cls.lb_member_keypair['private_key'],
535
+                cls.webserver1_ipv6, cls.lb_member_1_subnet_prefix)
536
+
537
+            # Enable the IPv6 nic in webserver 2
538
+            cls._enable_ipv6_nic_webserver(
539
+                cls.webserver2_public_ip, cls.lb_member_keypair['private_key'],
540
+                cls.webserver2_ipv6, cls.lb_member_2_subnet_prefix)
541
+
523 542
         # Set up serving on webserver 1
524 543
         cls._install_start_webserver(cls.webserver1_public_ip,
525 544
                                      cls.lb_member_keypair['private_key'],
@@ -710,6 +729,19 @@ class LoadBalancerBaseTestWithCompute(LoadBalancerBaseTest):
710 729
         linux_client.exec_command('sudo screen -d -m {0} -port 81 '
711 730
                                   '-id {1}'.format(dest_file, start_id + 1))
712 731
 
732
+    # Cirros does not configure the assigned IPv6 address by default
733
+    # so enable it manually like tempest does here:
734
+    # tempest/scenario/test_netowrk_v6.py turn_nic6_on()
735
+    @classmethod
736
+    def _enable_ipv6_nic_webserver(cls, ip_address, ssh_key,
737
+                                   ipv6_address, ipv6_prefix):
738
+        linux_client = remote_client.RemoteClient(
739
+            ip_address, CONF.validation.image_ssh_user, pkey=ssh_key)
740
+        linux_client.validate_authentication()
741
+
742
+        linux_client.exec_command('sudo ip address add {0}/{1} dev '
743
+                                  'eth0'.format(ipv6_address, ipv6_prefix))
744
+
713 745
     @classmethod
714 746
     def _validate_webserver(cls, ip_address, start_id):
715 747
         URL = 'http://{0}'.format(ip_address)

Loading…
Cancel
Save