diff --git a/requirements.txt b/requirements.txt index 8a2065652..9525414a9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,6 +15,7 @@ juju_wait # https://github.com/pyca/pyopenssl/commit/a145fc3bc6d2e943434beb2f04bbf9b18930296f pyopenssl<22.1.0 +macaroonbakery<=1.3.1 PyYAML<=4.2,>=3.0; python_version < '3.9' PyYAML>=5.1; python_version >= '3.9' flake8>=2.2.4 @@ -32,7 +33,8 @@ Jinja2>=2.6 # BSD License (3 clause) six>=1.9.0 dnspython>=1.12.0 psutil>=1.1.1,<2.0.0 -python-openstackclient>=3.14.0 +platformdirs<3 +python-openstackclient>=3.14.2,<=5.2 aodhclient gnocchiclient>=7.0.5,<8.0.0 pika>=1.1.0,<2.0.0 @@ -49,6 +51,7 @@ python-neutronclient python-novaclient python-octaviaclient python-swiftclient +openstacksdk<=0.61 tenacity paramiko diff --git a/unit_tests/utilities/test_zaza_utilities_os_versions.py b/unit_tests/utilities/test_zaza_utilities_os_versions.py index 86b0f6220..92b78b3ab 100644 --- a/unit_tests/utilities/test_zaza_utilities_os_versions.py +++ b/unit_tests/utilities/test_zaza_utilities_os_versions.py @@ -20,13 +20,12 @@ class TestOpenStackUtils(ut_utils.BaseTestCase): def test_compare_openstack(self): - yoga = os_versions.CompareOpenStack('yoga') - xena = os_versions.CompareOpenStack('xena') - wallaby = os_versions.CompareOpenStack('wallaby') - self.assertGreater(yoga, xena) - self.assertLess(xena, yoga) - self.assertGreaterEqual(xena, xena) - self.assertGreaterEqual(yoga, yoga) - self.assertGreaterEqual(yoga, wallaby) + ussuri = os_versions.CompareOpenStack('ussuri') + train = os_versions.CompareOpenStack('train') + self.assertGreater(ussuri, train) + self.assertLess(train, ussuri) + self.assertGreaterEqual(ussuri, ussuri) + self.assertGreaterEqual(train, train) + self.assertGreaterEqual(ussuri, train) - self.assertEqual("CompareOpenStack", repr(xena)) + self.assertEqual("CompareOpenStack", repr(ussuri)) diff --git a/zaza/openstack/charm_tests/octavia/tests.py b/zaza/openstack/charm_tests/octavia/tests.py index 295bd5119..dacd4d6d9 100644 --- a/zaza/openstack/charm_tests/octavia/tests.py +++ b/zaza/openstack/charm_tests/octavia/tests.py @@ -14,6 +14,7 @@ """Encapsulate octavia testing.""" +import json import logging import subprocess import tenacity @@ -26,6 +27,7 @@ import zaza.openstack.utilities.openstack as openstack_utils from zaza.openstack.utilities import ObjectRetrierWraps +from zaza.openstack.utilities.os_versions import CompareOpenStack LBAAS_ADMIN_ROLE = 'load-balancer_admin' @@ -136,12 +138,6 @@ def setUpClass(cls): cls.keystone_client = ObjectRetrierWraps( openstack_utils.get_keystone_session_client(cls.keystone_session)) - if (openstack_utils.get_os_release() >= - openstack_utils.get_os_release('focal_wallaby')): - # add role to admin user for the duration of the test - grant_role_current_user(cls.keystone_client, cls.keystone_session, - LBAAS_ADMIN_ROLE) - cls.neutron_client = ObjectRetrierWraps( openstack_utils.get_neutron_session_client(cls.keystone_session)) cls.octavia_client = ObjectRetrierWraps( @@ -159,6 +155,16 @@ def setUpClass(cls): # List of floating IPs created by this test cls.fips = [] + def setUp(self): + """Configure the octavia test environment.""" + super(LBAASv2Test, self).setUp() + if (openstack_utils.get_os_release() >= + openstack_utils.get_os_release('focal_wallaby')): + # add role to admin user for the duration of the test + grant_role_current_user(self.keystone_client, + self.keystone_session, + LBAAS_ADMIN_ROLE) + def _remove_amphorae_instances(self): """Remove amphorae instances forcefully. @@ -189,6 +195,7 @@ def resource_cleanup(self, only_local=False): :param only_local: When set to true do not call parent method :type only_local: bool """ + logging.info("deleting loadbalancer(s): {}".format(self.loadbalancers)) for lb in self.loadbalancers: try: self.octavia_client.load_balancer_delete( @@ -384,7 +391,7 @@ def _get_payload(ip): 'http://{}/'.format(ip)], universal_newlines=True) - def test_create_loadbalancer(self): + def create_loadbalancer(self, ensure_volume_backed=False): """Create load balancer.""" # Prepare payload instances # First we allow communication to port 80 by adding a security group @@ -451,5 +458,47 @@ def test_create_loadbalancer(self): .format(snippet, provider, lb_fp['floating_ip_address'])) + if ensure_volume_backed: + amphora_list = self.octavia_client.amphora_list() + self.assertTrue(len(amphora_list) > 0) + attached_volumes = [] + for amphora in amphora_list.get('amphorae', []): + server_id = amphora['compute_id'] + logging.info("Checking amphora {} server {} for attached " + "volumes".format(amphora['id'], server_id)) + volumes = self.nova_client.volumes.get_server_volumes( + server_id) + logging.info('amphora {} server {} has volumes={}'. + format(amphora['id'], + server_id, volumes)) + attached_volumes.append(json.dumps(vars(volumes))) + + self.assertTrue(len(attached_volumes) > 0) + logging.info("Amphora volumes creation successful: {}".format( + attached_volumes)) + # If we get here, it means the tests passed self.run_resource_cleanup = True + + def test_create_loadbalancer(self): + """Test creating a load balancer.""" + self.create_loadbalancer() + + +class OctaviaVolumeBackedAmphoraTest(LBAASv2Test): + """Octavia service tests.""" + + def test_volume_backed_amphora(self): + """Test volume-backed amphora load balancer.""" + os_versions = openstack_utils.get_current_os_versions(['octavia']) + if CompareOpenStack(os_versions['octavia']) < 'ussuri': + self.skipTest('Run only for Openstack Ussuri and newer releases.') + return + + """Test creating a load balancer that uses volume-based amphora.""" + default_charm_config = {'enable-volume-based-amphora': False} + alternate_charm_config = {'enable-volume-based-amphora': True} + with self.config_change(default_charm_config, + alternate_charm_config, reset_to_charm_default=True): + logging.info("Testing create volume-backed amphora loadbalancer") + self.create_loadbalancer(ensure_volume_backed=True) diff --git a/zaza/openstack/utilities/os_versions.py b/zaza/openstack/utilities/os_versions.py index 9d872ceae..add10e91c 100644 --- a/zaza/openstack/utilities/os_versions.py +++ b/zaza/openstack/utilities/os_versions.py @@ -61,6 +61,8 @@ ('2019.2', 'train'), ('2020.1', 'ussuri'), ('2020.2', 'victoria'), + ('2021.1', 'wallaby'), + ('2021.2', 'xena'), ]) OPENSTACK_RELEASES_PAIRS = [ @@ -393,4 +395,3 @@ class CompareOpenStack(BasicStringComparator): """ _list = list(OPENSTACK_CODENAMES.values()) -