Browse Source

Add traffic tests using an IPv6 VIP

Adds a traffic scenario test that has an IPv6 VIP address and mixed
IPv4/IPv6 members. It tests that connections to the IPv6 VIP are
evenly balanced across the mixed members.

Change-Id: I6bb7be14379174be9018a74b07356ecd85089f45
Story: 1627892
Task: 27532
Depends-On: https://review.openstack.org/#/c/611460/
Michael Johnson 6 months ago
parent
commit
5a16ad3267

+ 6
- 2
octavia_tempest_plugin/tests/api/v2/test_load_balancer.py View File

@@ -108,12 +108,16 @@ class LoadBalancerAPITest(test_base.LoadBalancerBaseTest):
108 108
             self.assertEqual(const.OFFLINE, lb[const.OPERATING_STATUS])
109 109
         else:
110 110
             self.assertEqual(const.ONLINE, lb[const.OPERATING_STATUS])
111
+            if ip_version == 4:
112
+                self.assertEqual(self.lb_member_vip_net[const.ID],
113
+                                 lb[const.VIP_NETWORK_ID])
114
+            else:
115
+                self.assertEqual(self.lb_member_vip_ipv6_net[const.ID],
116
+                                 lb[const.VIP_NETWORK_ID])
111 117
 
112 118
         self.assertEqual(self.os_roles_lb_member.credentials.project_id,
113 119
                          lb[const.PROJECT_ID])
114 120
         self.assertEqual(CONF.load_balancer.provider, lb[const.PROVIDER])
115
-        self.assertEqual(self.lb_member_vip_net[const.ID],
116
-                         lb[const.VIP_NETWORK_ID])
117 121
         self.assertIsNotNone(lb[const.VIP_PORT_ID])
118 122
         if lb_kwargs[const.VIP_SUBNET_ID]:
119 123
             self.assertEqual(lb_kwargs[const.VIP_ADDRESS],

+ 169
- 0
octavia_tempest_plugin/tests/scenario/v2/test_ipv6_traffic_ops.py View File

@@ -0,0 +1,169 @@
1
+# Copyright 2018 Rackspace, US Inc.
2
+#
3
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+#    not use this file except in compliance with the License. You may obtain
5
+#    a copy of the License at
6
+#
7
+#         http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+#    Unless required by applicable law or agreed to in writing, software
10
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+#    License for the specific language governing permissions and limitations
13
+#    under the License.
14
+
15
+from tempest import config
16
+from tempest.lib.common.utils import data_utils
17
+from tempest.lib import decorators
18
+
19
+from octavia_tempest_plugin.common import constants as const
20
+from octavia_tempest_plugin.tests import test_base
21
+from octavia_tempest_plugin.tests import waiters
22
+
23
+CONF = config.CONF
24
+
25
+
26
+class IPv6TrafficOperationsScenarioTest(
27
+    test_base.LoadBalancerBaseTestWithCompute):
28
+    """Test traffic operations with an IPv6 VIP."""
29
+
30
+    @classmethod
31
+    def skip_checks(cls):
32
+        super(IPv6TrafficOperationsScenarioTest, cls).skip_checks()
33
+
34
+        if not CONF.validation.run_validation:
35
+            raise cls.skipException('Traffic tests will not work without '
36
+                                    'run_validation enabled.')
37
+
38
+        if CONF.load_balancer.test_with_noop:
39
+            raise cls.skipException('Traffic tests will not work in noop '
40
+                                    'mode.')
41
+
42
+        if not CONF.load_balancer.test_with_ipv6:
43
+            raise cls.skipException('IPv6 traffic ops tests require Octavia '
44
+                                    'IPv6 testing enabled')
45
+
46
+    @classmethod
47
+    def resource_setup(cls):
48
+        """Setup resources needed by the tests."""
49
+        super(IPv6TrafficOperationsScenarioTest, cls).resource_setup()
50
+
51
+        lb_name = data_utils.rand_name("lb_member_lb1_ipv6_ops")
52
+        lb_kwargs = {const.PROVIDER: CONF.load_balancer.provider,
53
+                     const.NAME: lb_name}
54
+
55
+        ip_version = 6
56
+        cls._setup_lb_network_kwargs(lb_kwargs, ip_version)
57
+
58
+        lb = cls.mem_lb_client.create_loadbalancer(**lb_kwargs)
59
+        cls.lb_id = lb[const.ID]
60
+        cls.addClassResourceCleanup(
61
+            cls.mem_lb_client.cleanup_loadbalancer,
62
+            cls.lb_id)
63
+
64
+        cls.lb_vip_address = lb[const.VIP_ADDRESS]
65
+
66
+        waiters.wait_for_status(cls.mem_lb_client.show_loadbalancer,
67
+                                cls.lb_id, const.PROVISIONING_STATUS,
68
+                                const.ACTIVE,
69
+                                CONF.load_balancer.lb_build_interval,
70
+                                CONF.load_balancer.lb_build_timeout)
71
+
72
+        listener_name = data_utils.rand_name("lb_member_listener1_ipv6_ops")
73
+        listener_kwargs = {
74
+            const.NAME: listener_name,
75
+            const.PROTOCOL: const.HTTP,
76
+            const.PROTOCOL_PORT: '80',
77
+            const.LOADBALANCER_ID: cls.lb_id,
78
+        }
79
+        listener = cls.mem_listener_client.create_listener(**listener_kwargs)
80
+        cls.listener_id = listener[const.ID]
81
+        cls.addClassResourceCleanup(
82
+            cls.mem_listener_client.cleanup_listener,
83
+            cls.listener_id,
84
+            lb_client=cls.mem_lb_client, lb_id=cls.lb_id)
85
+
86
+        waiters.wait_for_status(cls.mem_lb_client.show_loadbalancer,
87
+                                cls.lb_id, const.PROVISIONING_STATUS,
88
+                                const.ACTIVE,
89
+                                CONF.load_balancer.build_interval,
90
+                                CONF.load_balancer.build_timeout)
91
+
92
+        pool_name = data_utils.rand_name("lb_member_pool1_ipv6_ops")
93
+        pool_kwargs = {
94
+            const.NAME: pool_name,
95
+            const.PROTOCOL: const.HTTP,
96
+            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
97
+            const.LISTENER_ID: cls.listener_id,
98
+        }
99
+        pool = cls.mem_pool_client.create_pool(**pool_kwargs)
100
+        cls.pool_id = pool[const.ID]
101
+        cls.addClassResourceCleanup(
102
+            cls.mem_pool_client.cleanup_pool,
103
+            cls.pool_id,
104
+            lb_client=cls.mem_lb_client, lb_id=cls.lb_id)
105
+
106
+        waiters.wait_for_status(cls.mem_lb_client.show_loadbalancer,
107
+                                cls.lb_id, const.PROVISIONING_STATUS,
108
+                                const.ACTIVE,
109
+                                CONF.load_balancer.build_interval,
110
+                                CONF.load_balancer.build_timeout)
111
+
112
+    @decorators.idempotent_id('219ac17d-c5c1-4e7e-a9d5-0764d7ce7746')
113
+    def test_ipv6_vip_mixed_ipv4_ipv6_members_traffic(self):
114
+        """Tests traffic through a loadbalancer with IPv4 and IPv6 members.
115
+
116
+        * Set up members on a loadbalancer.
117
+        * Test traffic to ensure it is balanced properly.
118
+        """
119
+        # Set up Member 1 for Webserver 1
120
+        member1_name = data_utils.rand_name("lb_member_member1-traffic")
121
+        member1_kwargs = {
122
+            const.POOL_ID: self.pool_id,
123
+            const.NAME: member1_name,
124
+            const.ADMIN_STATE_UP: True,
125
+            const.ADDRESS: self.webserver1_ip,
126
+            const.PROTOCOL_PORT: 80,
127
+        }
128
+        if self.lb_member_1_subnet:
129
+            member1_kwargs[const.SUBNET_ID] = self.lb_member_1_subnet[const.ID]
130
+
131
+        member1 = self.mem_member_client.create_member(
132
+            **member1_kwargs)
133
+        self.addCleanup(
134
+            self.mem_member_client.cleanup_member,
135
+            member1[const.ID], pool_id=self.pool_id,
136
+            lb_client=self.mem_lb_client, lb_id=self.lb_id)
137
+        waiters.wait_for_status(
138
+            self.mem_lb_client.show_loadbalancer, self.lb_id,
139
+            const.PROVISIONING_STATUS, const.ACTIVE,
140
+            CONF.load_balancer.check_interval,
141
+            CONF.load_balancer.check_timeout)
142
+
143
+        # Set up Member 2 for Webserver 2
144
+        member2_name = data_utils.rand_name("lb_member_member2-traffic")
145
+        member2_kwargs = {
146
+            const.POOL_ID: self.pool_id,
147
+            const.NAME: member2_name,
148
+            const.ADMIN_STATE_UP: True,
149
+            const.ADDRESS: self.webserver2_ipv6,
150
+            const.PROTOCOL_PORT: 80,
151
+        }
152
+        if self.lb_member_2_ipv6_subnet:
153
+            member2_kwargs[const.SUBNET_ID] = (
154
+                self.lb_member_2_ipv6_subnet[const.ID])
155
+
156
+        member2 = self.mem_member_client.create_member(
157
+            **member2_kwargs)
158
+        self.addCleanup(
159
+            self.mem_member_client.cleanup_member,
160
+            member2[const.ID], pool_id=self.pool_id,
161
+            lb_client=self.mem_lb_client, lb_id=self.lb_id)
162
+        waiters.wait_for_status(
163
+            self.mem_lb_client.show_loadbalancer, self.lb_id,
164
+            const.PROVISIONING_STATUS, const.ACTIVE,
165
+            CONF.load_balancer.check_interval,
166
+            CONF.load_balancer.check_timeout)
167
+
168
+        # Send some traffic
169
+        self.check_members_balanced(self.lb_vip_address)

+ 6
- 2
octavia_tempest_plugin/tests/scenario/v2/test_load_balancer.py View File

@@ -79,8 +79,12 @@ class LoadBalancerScenarioTest(test_base.LoadBalancerBaseTest):
79 79
         self.assertEqual(self.os_roles_lb_member.credentials.project_id,
80 80
                          lb[const.PROJECT_ID])
81 81
         self.assertEqual(CONF.load_balancer.provider, lb[const.PROVIDER])
82
-        self.assertEqual(self.lb_member_vip_net[const.ID],
83
-                         lb[const.VIP_NETWORK_ID])
82
+        if ip_version == 4:
83
+            self.assertEqual(self.lb_member_vip_net[const.ID],
84
+                             lb[const.VIP_NETWORK_ID])
85
+        else:
86
+            self.assertEqual(self.lb_member_vip_ipv6_net[const.ID],
87
+                             lb[const.VIP_NETWORK_ID])
84 88
         self.assertIsNotNone(lb[const.VIP_PORT_ID])
85 89
         if lb_kwargs[const.VIP_SUBNET_ID]:
86 90
             self.assertEqual(lb_kwargs[const.VIP_SUBNET_ID],

+ 39
- 19
octavia_tempest_plugin/tests/test_base.py View File

@@ -140,6 +140,7 @@ class LoadBalancerBaseTest(test.BaseTestCase):
140 140
             cls.lb_member_2_net = {'id': uuidutils.generate_uuid()}
141 141
             cls.lb_member_2_subnet = {'id': uuidutils.generate_uuid()}
142 142
             if CONF.load_balancer.test_with_ipv6:
143
+                cls.lb_member_vip_ipv6_net = {'id': uuidutils.generate_uuid()}
143 144
                 cls.lb_member_vip_ipv6_subnet = {'id':
144 145
                                                  uuidutils.generate_uuid()}
145 146
                 cls.lb_member_1_ipv6_subnet = {'id': uuidutils.generate_uuid()}
@@ -250,20 +251,30 @@ class LoadBalancerBaseTest(test.BaseTestCase):
250 251
 
251 252
         # Create tenant VIP IPv6 subnet
252 253
         if CONF.load_balancer.test_with_ipv6:
253
-            subnet_kwargs = {
254
-                'name': data_utils.rand_name("lb_member_vip_ipv6_subnet"),
255
-                'network_id': cls.lb_member_vip_net['id'],
256
-                'cidr': CONF.load_balancer.vip_ipv6_subnet_cidr,
257
-                'ip_version': 6}
258
-            result = cls.lb_mem_subnet_client.create_subnet(**subnet_kwargs)
259
-            cls.lb_member_vip_ipv6_subnet = result['subnet']
254
+            # See if ipv6-public-subnet exists and use it if so.
255
+            pub_ipv6_subnet = cls.os_admin.subnets_client.list_subnets(
256
+                name='ipv6-public-subnet')['subnets']
257
+
258
+            if len(pub_ipv6_subnet) == 1:
259
+                cls.lb_member_vip_ipv6_subnet = pub_ipv6_subnet[0]
260
+                cls.lb_member_vip_ipv6_net = {
261
+                    'id': pub_ipv6_subnet[0]['network_id']}
262
+            else:
263
+                subnet_kwargs = {
264
+                    'name': data_utils.rand_name("lb_member_vip_ipv6_subnet"),
265
+                    'network_id': cls.lb_member_vip_net['id'],
266
+                    'cidr': CONF.load_balancer.vip_ipv6_subnet_cidr,
267
+                    'ip_version': 6}
268
+                result = cls.lb_mem_subnet_client.create_subnet(
269
+                    **subnet_kwargs)
270
+                cls.lb_member_vip_ipv6_subnet = result['subnet']
271
+                cls.addClassResourceCleanup(
272
+                    waiters.wait_for_not_found,
273
+                    cls.lb_mem_subnet_client.delete_subnet,
274
+                    cls.lb_mem_subnet_client.show_subnet,
275
+                    cls.lb_member_vip_ipv6_subnet['id'])
260 276
             LOG.info('lb_member_vip_ipv6_subnet: {}'.format(
261 277
                 cls.lb_member_vip_ipv6_subnet))
262
-            cls.addClassResourceCleanup(
263
-                waiters.wait_for_not_found,
264
-                cls.lb_mem_subnet_client.delete_subnet,
265
-                cls.lb_mem_subnet_client.show_subnet,
266
-                cls.lb_member_vip_ipv6_subnet['id'])
267 278
 
268 279
         # Create tenant member 1 network
269 280
         network_kwargs = {
@@ -376,21 +387,27 @@ class LoadBalancerBaseTest(test.BaseTestCase):
376 387
                                  use_fixed_ip=False):
377 388
         if not ip_version:
378 389
             ip_version = 6 if CONF.load_balancer.test_with_ipv6 else 4
379
-        if cls.lb_member_vip_subnet:
390
+        if cls.lb_member_vip_subnet or cls.lb_member_vip_ipv6_subnet:
380 391
             ip_index = data_utils.rand_int_id(start=10, end=100)
381 392
             while ip_index in cls.used_ips:
382 393
                 ip_index = data_utils.rand_int_id(start=10, end=100)
383 394
             cls.used_ips.append(ip_index)
384 395
             if ip_version == 4:
385
-                network = ipaddress.IPv4Network(
386
-                    six.u(CONF.load_balancer.vip_subnet_cidr))
387
-                lb_vip_address = str(network[ip_index])
388 396
                 subnet_id = cls.lb_member_vip_subnet[const.ID]
397
+                if CONF.load_balancer.test_with_noop:
398
+                    lb_vip_address = '198.18.33.33'
399
+                else:
400
+                    subnet = cls.os_admin.subnets_client.show_subnet(subnet_id)
401
+                    network = ipaddress.IPv4Network(subnet['subnet']['cidr'])
402
+                    lb_vip_address = str(network[ip_index])
389 403
             else:
390
-                network = ipaddress.IPv6Network(
391
-                    six.u(CONF.load_balancer.vip_ipv6_subnet_cidr))
392
-                lb_vip_address = str(network[ip_index])
393 404
                 subnet_id = cls.lb_member_vip_ipv6_subnet[const.ID]
405
+                if CONF.load_balancer.test_with_noop:
406
+                    lb_vip_address = '2001:db8:33:33:33:33:33:33'
407
+                else:
408
+                    subnet = cls.os_admin.subnets_client.show_subnet(subnet_id)
409
+                    network = ipaddress.IPv6Network(subnet['subnet']['cidr'])
410
+                    lb_vip_address = str(network[ip_index])
394 411
             lb_kwargs[const.VIP_SUBNET_ID] = subnet_id
395 412
             if use_fixed_ip:
396 413
                 lb_kwargs[const.VIP_ADDRESS] = lb_vip_address
@@ -769,6 +786,9 @@ class LoadBalancerBaseTestWithCompute(LoadBalancerBaseTest):
769 786
         session = requests.Session()
770 787
         response_counts = {}
771 788
 
789
+        if ipaddress.ip_address(vip_address).version == 6:
790
+            vip_address = '[{}]'.format(vip_address)
791
+
772 792
         self._wait_for_lb_functional(vip_address)
773 793
 
774 794
         # Send a number requests to lb vip

+ 1
- 0
zuul.d/jobs.yaml View File

@@ -237,6 +237,7 @@
237 237
           o-cw: true
238 238
           o-hm: true
239 239
           o-hk: true
240
+          q-agt: true
240 241
 
241 242
 - job:
242 243
     name: octavia-dsvm-noop-base

Loading…
Cancel
Save