Browse Source

Merge "Adds provider API tests"

tags/1.0.0
Zuul 4 months ago
parent
commit
ebbe4ef969

+ 10
- 0
octavia_tempest_plugin/config.py View File

@@ -114,6 +114,16 @@ OctaviaGroup = [
114 114
                help='Type of RBAC tests to run. "advanced" runs the octavia '
115 115
                     'default RBAC tests. "owner_or_admin" runs the legacy '
116 116
                     'owner or admin tests. "none" disables the RBAC tests.'),
117
+    cfg.DictOpt('enabled_provider_drivers',
118
+                help=('List of enabled provider drivers and description '
119
+                      'dictionaries. Must match the driver name in the '
120
+                      'octavia.api.drivers entrypoint. Example: '
121
+                      '{\'amphora\': \'The Octavia Amphora driver.\', '
122
+                      '\'octavia\': \'Deprecated alias of the Octavia '
123
+                      'Amphora driver.\'}'),
124
+                default={'amphora': 'The Octavia Amphora driver.',
125
+                         'octavia': 'Deprecated alias of the Octavia Amphora '
126
+                         'driver.'}),
117 127
     # Networking
118 128
     cfg.BoolOpt('test_with_ipv6',
119 129
                 default=True,

+ 73
- 0
octavia_tempest_plugin/tests/api/v2/test_provider.py View File

@@ -0,0 +1,73 @@
1
+#    Copyright 2019 Rackspace US Inc.  All rights reserved.
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 oslo_log import log as logging
16
+from tempest import config
17
+from tempest.lib import decorators
18
+from tempest.lib import exceptions
19
+
20
+from octavia_tempest_plugin.common import constants as const
21
+from octavia_tempest_plugin.tests import test_base
22
+
23
+CONF = config.CONF
24
+LOG = logging.getLogger(__name__)
25
+
26
+
27
+class ProviderAPITest(test_base.LoadBalancerBaseTest):
28
+    """Test the provider object API."""
29
+
30
+    @decorators.idempotent_id('8b94e0cc-a24d-4c29-bc8e-53f58214dc67')
31
+    def test_provider_list(self):
32
+        """Tests provider list API and field filtering.
33
+
34
+        * Validates that non-lb member accounts cannot list the providers.
35
+        * List the providers and validate against the expected provider list.
36
+        * List the providers returning one field at a time.
37
+        """
38
+        # We have to do this here as the api_version and clients are not
39
+        # setup in time to use a decorator or the skip_checks mixin
40
+        if not self.mem_provider_client.is_version_supported(
41
+                self.api_version, '2.1'):
42
+            raise self.skipException('Providers are only available on '
43
+                                     'Octavia API version 2.1 or newer.')
44
+
45
+        # Test that a user without the load balancer role cannot
46
+        # list providers.
47
+        if CONF.load_balancer.RBAC_test_type == const.ADVANCED:
48
+            self.assertRaises(
49
+                exceptions.Forbidden,
50
+                self.os_primary.provider_client.list_providers)
51
+
52
+        providers = self.mem_provider_client.list_providers()
53
+
54
+        # Check against the expected providers from the tempest config
55
+        enabled_providers = CONF.load_balancer.enabled_provider_drivers
56
+        for provider in providers:
57
+            self.assertEqual(enabled_providers[provider[const.NAME]],
58
+                             provider.get(const.DESCRIPTION, ''))
59
+
60
+        # Test fields
61
+        providers = self.mem_provider_client.list_providers(
62
+            query_params='{fields}={field}'.format(fields=const.FIELDS,
63
+                                                   field=const.NAME))
64
+        for provider in providers:
65
+            self.assertEqual(1, len(provider))
66
+            self.assertIn(provider[const.NAME], enabled_providers.keys())
67
+        providers = self.mem_provider_client.list_providers(
68
+            query_params='{fields}={field}'.format(fields=const.FIELDS,
69
+                                                   field=const.DESCRIPTION))
70
+        for provider in providers:
71
+            self.assertEqual(1, len(provider))
72
+            self.assertIn(provider[const.DESCRIPTION],
73
+                          enabled_providers.values())

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

@@ -126,6 +126,7 @@ class LoadBalancerBaseTest(test.BaseTestCase):
126 126
             cls.os_roles_lb_admin.flavor_profile_client)
127 127
         cls.lb_admin_flavor_client = cls.os_roles_lb_admin.flavor_client
128 128
         cls.mem_flavor_client = cls.os_roles_lb_member.flavor_client
129
+        cls.mem_provider_client = cls.os_roles_lb_member.provider_client
129 130
 
130 131
     @classmethod
131 132
     def resource_setup(cls):

Loading…
Cancel
Save