Improve octavia tempest plugin configuration

To run octavia tempest plugin some configuration need to
set in tempestconf file. If octavia service is enabled
then configuration region, enable_provider_drivers will
set automatically.

Added tripleo-ci-centos-8-scenario010-standalone job in
check and gate list.

Added tests for list_drivers and post_configuration.

Change-Id: Ic719f83f4fb9a330fc64ef46144e0b0b39c3a7d5
Signed-off-by: Amol Kahat <amolkahat@gmail.com>
This commit is contained in:
Amol Kahat 2020-05-28 16:49:38 +05:30
parent e93f9ff2b9
commit 7ee63b1517
No known key found for this signature in database
GPG Key ID: FDD3BA6C832D7715
4 changed files with 94 additions and 7 deletions

View File

@ -20,6 +20,7 @@
- tripleo-ci-centos-8-scenario002-standalone
- tripleo-ci-centos-8-standalone
- refstack-client-devstack-tempestconf
- tripleo-ci-centos-8-scenario010-standalone
gate:
jobs:
- openstack-tox-pep8
@ -31,6 +32,7 @@
- tripleo-ci-centos-8-scenario002-standalone
- tripleo-ci-centos-8-standalone
- refstack-client-devstack-tempestconf
- tripleo-ci-centos-8-scenario010-standalone
experimental:
jobs:
- python-tempestconf-tempest-devstack-demo-train

View File

@ -14,10 +14,10 @@
# under the License.
from config_tempest.services.base import VersionedService
import json
class LoadBalancerService(VersionedService):
def set_versions(self):
super(LoadBalancerService, self).set_versions(top_level=False)
@ -34,6 +34,23 @@ class LoadBalancerService(VersionedService):
def get_codename():
return 'octavia'
def list_drivers(self):
"""List lbaas drivers"""
body = self.do_get(self.service_url + '/v2/lbaas/providers')
body = json.loads(body)
names = [
'{p[name]}:{p[description]}'.format(p=i) for i in body['providers']
]
return names
def post_configuration(self, conf, is_service):
if not conf.has_option('auth', 'tempest_roles') \
or conf.get('auth', 'tempest_roles') in ['', None]:
conf.set('load_balancer', 'member_role', 'member')
else:
conf.set('load_balancer', 'member_role',
conf.get('auth', 'tempest_roles').split(',')[0])
conf.set('load_balancer', 'region', conf.get('identity', 'region'))
conf.set('load_balancer',
'enabled_provider_drivers',
','.join(self.list_drivers()))

View File

@ -31,7 +31,6 @@ logging.disable(logging.CRITICAL)
class BaseConfigTempestTest(base.BaseTestCase):
"""Test case base class for all config_tempest unit tests"""
FAKE_V3_VERSIONS = (
@ -105,7 +104,6 @@ class BaseConfigTempestTest(base.BaseTestCase):
class BaseServiceTest(base.BaseTestCase):
"""Test case base class for all api_discovery unit tests"""
FAKE_TOKEN = "s6d5f45sdf4s564f4s6464sdfsd514"
@ -210,6 +208,17 @@ class BaseServiceTest(base.BaseTestCase):
}
}
)
FAKE_LBAAS_PROVIDERS = (
{
"providers": [{
"name": "amphora",
"description": "The Octavia Amphora driver."
}, {
"name": "octavia",
"description": "Deprecated alias of the Octavia driver."
}]
}
)
FAKE_STORAGE_EXTENSIONS = (
{
"formpost": {},

View File

@ -0,0 +1,59 @@
# Copyright 2020 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
from config_tempest.services.octavia import LoadBalancerService
from config_tempest.tests.base import BaseConfigTempestTest
from config_tempest.tests.base import BaseServiceTest as bst
class TestOctaviaService(BaseConfigTempestTest):
def setUp(self):
super(TestOctaviaService, self).setUp()
self.conf = self._get_conf("v2", "v3")
self.clients = self._get_clients(self.conf)
self.Service = LoadBalancerService("ServiceName",
"ServiceType",
bst.FAKE_URL + "v2.0/",
bst.FAKE_TOKEN,
disable_ssl_validation=False)
self.Service.client = bst.FakeServiceClient(
services={"services": [{"name": "octavia", "enabled": True}]}
)
self.conf.set("identity", "region", "regionOne")
bst._fake_service_do_get_method(self, bst.FAKE_LBAAS_PROVIDERS)
def test_list_drivers(self):
expected_resp = [
"amphora:The Octavia Amphora driver.",
"octavia:Deprecated alias of the Octavia driver.",
]
providers = self.Service.list_drivers()
self.assertCountEqual(providers, expected_resp)
@mock.patch("config_tempest.services.services.Services.is_service")
def test_octavia_service_post_configuration(self, mock_is_service):
mock_is_service.return_value = True
self.Service.post_configuration(self.conf, mock_is_service)
self.assertEqual(self.conf.get("load_balancer", "member_role"),
"member")
self.assertEqual(self.conf.get("load_balancer", "region"),
"regionOne")
self.assertEqual(self.conf.get("load_balancer",
"enabled_provider_drivers"),
("amphora:The Octavia Amphora driver.,"
"octavia:Deprecated alias of the Octavia driver."),
)