summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Johnson <johnsomor@gmail.com>2019-01-15 16:40:05 -0800
committerMichael Johnson <johnsomor@gmail.com>2019-01-28 22:40:36 +0000
commitfc223fe16c88171810831e34ad66dd034a38651c (patch)
tree42183a47335eb413ca6f9454c9389c38e0889541
parenta2d0307498b5c2c8844e4180f00bb0cdd84b7e4a (diff)
Adds provider API tests
This patch adds provider API tests to the Octavia tempest plugin. Change-Id: I25685276e12dd94e866f7db5b501baaa9a38cc84
Notes
Notes (review): Code-Review+2: Adam Harwell <flux.adam@gmail.com> Code-Review+2: Jacky Hu <hudayou@hotmail.com> Workflow+1: Jacky Hu <hudayou@hotmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 01 Feb 2019 16:56:36 +0000 Reviewed-on: https://review.openstack.org/631105 Project: openstack/octavia-tempest-plugin Branch: refs/heads/master
-rw-r--r--octavia_tempest_plugin/config.py10
-rw-r--r--octavia_tempest_plugin/tests/api/v2/test_provider.py73
-rw-r--r--octavia_tempest_plugin/tests/test_base.py1
3 files changed, 84 insertions, 0 deletions
diff --git a/octavia_tempest_plugin/config.py b/octavia_tempest_plugin/config.py
index 1bc4a63..905dc9c 100644
--- a/octavia_tempest_plugin/config.py
+++ b/octavia_tempest_plugin/config.py
@@ -114,6 +114,16 @@ OctaviaGroup = [
114 help='Type of RBAC tests to run. "advanced" runs the octavia ' 114 help='Type of RBAC tests to run. "advanced" runs the octavia '
115 'default RBAC tests. "owner_or_admin" runs the legacy ' 115 'default RBAC tests. "owner_or_admin" runs the legacy '
116 'owner or admin tests. "none" disables the RBAC tests.'), 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 # Networking 127 # Networking
118 cfg.BoolOpt('test_with_ipv6', 128 cfg.BoolOpt('test_with_ipv6',
119 default=True, 129 default=True,
diff --git a/octavia_tempest_plugin/tests/api/v2/test_provider.py b/octavia_tempest_plugin/tests/api/v2/test_provider.py
new file mode 100644
index 0000000..917b365
--- /dev/null
+++ b/octavia_tempest_plugin/tests/api/v2/test_provider.py
@@ -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
15from oslo_log import log as logging
16from tempest import config
17from tempest.lib import decorators
18from tempest.lib import exceptions
19
20from octavia_tempest_plugin.common import constants as const
21from octavia_tempest_plugin.tests import test_base
22
23CONF = config.CONF
24LOG = logging.getLogger(__name__)
25
26
27class 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())
diff --git a/octavia_tempest_plugin/tests/test_base.py b/octavia_tempest_plugin/tests/test_base.py
index 4ba5cae..f8acc2b 100644
--- a/octavia_tempest_plugin/tests/test_base.py
+++ b/octavia_tempest_plugin/tests/test_base.py
@@ -126,6 +126,7 @@ class LoadBalancerBaseTest(test.BaseTestCase):
126 cls.os_roles_lb_admin.flavor_profile_client) 126 cls.os_roles_lb_admin.flavor_profile_client)
127 cls.lb_admin_flavor_client = cls.os_roles_lb_admin.flavor_client 127 cls.lb_admin_flavor_client = cls.os_roles_lb_admin.flavor_client
128 cls.mem_flavor_client = cls.os_roles_lb_member.flavor_client 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 @classmethod 131 @classmethod
131 def resource_setup(cls): 132 def resource_setup(cls):