From 0684a62383d6678964c351f94125f6ab90cd1c51 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Tue, 17 Oct 2023 20:00:48 +0000 Subject: [PATCH 1/2] Updates for charm/openstack upgrade testing Updates charm upgrades to use channels, tracks, and risks instead of URLs. Currently these tests only upgrade OpenStack charms and packages. The OVN, ceph, and misc charms and payloads are not upgraded. Remove instance creation since tempest can be used to verify the cloud. --- .../test_zaza_utilities_upgrade_utils.py | 15 ++++++ .../charm_tests/charm_upgrade/tests.py | 52 +++++++------------ .../charm_tests/openstack_upgrade/tests.py | 25 ++------- zaza/openstack/utilities/upgrade_utils.py | 44 ++++++++++++++-- 4 files changed, 77 insertions(+), 59 deletions(-) diff --git a/unit_tests/utilities/test_zaza_utilities_upgrade_utils.py b/unit_tests/utilities/test_zaza_utilities_upgrade_utils.py index 986ba38..7a814c5 100644 --- a/unit_tests/utilities/test_zaza_utilities_upgrade_utils.py +++ b/unit_tests/utilities/test_zaza_utilities_upgrade_utils.py @@ -102,6 +102,21 @@ class TestUpgradeUtils(ut_utils.BaseTestCase): actual, expected) + def test_get_charm_upgrade_groups(self): + expected = [ + ('Database Services', []), + ('Stateful Services', []), + ('Core Identity', []), + ('Control Plane', ['cinder']), + ('Data Plane', ['nova-compute']), + ('sweep_up', ['neutron-openvswitch', 'ntp'])] + actual = openstack_upgrade.get_charm_upgrade_groups() + pprint.pprint(expected) + pprint.pprint(actual) + self.assertEqual( + actual, + expected) + def test_get_series_upgrade_groups(self): expected = [ ('Database Services', ['mydb']), diff --git a/zaza/openstack/charm_tests/charm_upgrade/tests.py b/zaza/openstack/charm_tests/charm_upgrade/tests.py index f55caf0..52223e4 100644 --- a/zaza/openstack/charm_tests/charm_upgrade/tests.py +++ b/zaza/openstack/charm_tests/charm_upgrade/tests.py @@ -22,9 +22,9 @@ import unittest import zaza.model from zaza.openstack.utilities import ( cli as cli_utils, + os_versions as os_versions, upgrade_utils as upgrade_utils, ) -from zaza.openstack.charm_tests.nova.tests import LTSGuestCreateTest class FullCloudCharmUpgradeTest(unittest.TestCase): @@ -34,25 +34,9 @@ class FullCloudCharmUpgradeTest(unittest.TestCase): def setUpClass(cls): """Run setup for Charm Upgrades.""" cli_utils.setup_logging() - cls.lts = LTSGuestCreateTest() - cls.lts.setUpClass() - cls.target_charm_namespace = '~openstack-charmers-next' - - def get_upgrade_url(self, charm_url): - """Return the charm_url to upgrade to. - - :param charm_url: Current charm url. - :type charm_url: str - """ - charm_name = upgrade_utils.extract_charm_name_from_url( - charm_url) - next_charm_url = zaza.model.get_latest_charm_url( - "cs:{}/{}".format(self.target_charm_namespace, charm_name)) - return next_charm_url def test_200_run_charm_upgrade(self): """Run charm upgrade.""" - self.lts.test_launch_small_instance() applications = zaza.model.get_status().applications groups = upgrade_utils.get_charm_upgrade_groups( extra_filters=[upgrade_utils._filter_etcd, @@ -63,20 +47,22 @@ class FullCloudCharmUpgradeTest(unittest.TestCase): for application, app_details in applications.items(): if application not in group: continue - target_url = self.get_upgrade_url(app_details['charm']) - if target_url == app_details['charm']: - logging.warn( - "Skipping upgrade of {}, already using {}".format( - application, - target_url)) + charm_channel = applications[application].charm_channel + charm_track, charm_risk = charm_channel.split('/') + os_version, os_codename = ( + upgrade_utils.determine_next_openstack_release( + charm_track)) + if os_versions.CompareOpenStack(os_codename) >= 'zed': + new_charm_track = os_version else: - logging.info("Upgrading {} to {}".format( - application, - target_url)) - zaza.model.upgrade_charm( - application, - switch=target_url) - logging.info("Waiting for charm url to update") - zaza.model.block_until_charm_url(application, target_url) - zaza.model.block_until_all_units_idle() - self.lts.test_launch_small_instance() + new_charm_track = os_codename + new_charm_channel = f"{new_charm_track}/{charm_risk}" + self.assertNotEqual(charm_channel, new_charm_channel) + logging.info("Upgrading {} to {}".format( + application, new_charm_channel)) + zaza.model.upgrade_charm( + application, channel=new_charm_channel) + logging.info("Waiting for charm channel to update") + zaza.model.block_until_charm_channel( + application, new_charm_channel) + zaza.model.block_until_all_units_idle(timeout=10800) diff --git a/zaza/openstack/charm_tests/openstack_upgrade/tests.py b/zaza/openstack/charm_tests/openstack_upgrade/tests.py index 661a076..36629b1 100644 --- a/zaza/openstack/charm_tests/openstack_upgrade/tests.py +++ b/zaza/openstack/charm_tests/openstack_upgrade/tests.py @@ -43,7 +43,7 @@ class OpenStackUpgradeVMLaunchBase(unittest.TestCase): nova-cloud-controller, nova-compute, neutron-gateway, neutron-api and neutron-openvswitch. - This class should be used as a base class to the upgrade 'test'. + This class can be used as a base class to the upgrade 'test'. """ @classmethod @@ -85,21 +85,7 @@ class WaitForMySQL(unittest.TestCase): logging.info("Done .. all seems well.") -class OpenStackUpgradeTestsFocalUssuri(OpenStackUpgradeVMLaunchBase): - """Upgrade OpenStack from distro -> cloud:focal-victoria.""" - - @classmethod - def setUpClass(cls): - """Run setup for OpenStack Upgrades.""" - super().setUpClass() - cli_utils.setup_logging() - - def test_200_run_openstack_upgrade(self): - """Run openstack upgrade, but work out what to do.""" - openstack_upgrade.run_upgrade_tests("cloud:focal-victoria") - - -class OpenStackUpgradeTestsByOption(OpenStackUpgradeVMLaunchBase): +class OpenStackUpgradeTestsByOption(unittest.TestCase): """A Principal Class to encapsulate OpenStack Upgrade Tests. A generic Test class that uses the options in the tests.yaml to use a charm @@ -121,12 +107,7 @@ class OpenStackUpgradeTestsByOption(OpenStackUpgradeVMLaunchBase): cli_utils.setup_logging() def test_200_run_openstack_upgrade(self): - """Run openstack upgrade, but work out what to do. - - TODO: This is really inefficient at the moment, and doesn't (yet) - determine which ubuntu version to work from. Don't use until we can - make it better. - """ + """Run openstack upgrade, but work out what to do.""" # get the tests_options / openstack-upgrade.detect-using-charm so that # the ubuntu version and OpenStack version can be detected. try: diff --git a/zaza/openstack/utilities/upgrade_utils.py b/zaza/openstack/utilities/upgrade_utils.py index 3add346..8c03872 100644 --- a/zaza/openstack/utilities/upgrade_utils.py +++ b/zaza/openstack/utilities/upgrade_utils.py @@ -50,9 +50,37 @@ SERVICE_GROUPS = ( 'swift-proxy', 'swift-storage'])) UPGRADE_EXCLUDE_LIST = [ - 'rabbitmq-server', + 'ceph-fs', + 'ceph-mon', + 'ceph-osd', + 'memcached', + 'mysql-innodb-cluster', + 'ovn-central', + 'ovn-chassis', 'percona-cluster', + # glance-simplestreams-sync disabled due to: + # https://bugs.launchpad.net/juju/+bug/1951182 'glance-simplestreams-sync', + 'percona-cluster', + 'rabbitmq-server', + 'vault', + 'aodh-mysql-router', + 'barbican-mysql-router', + 'cinder-mysql-router', + 'designate-mysql-router', + 'glance-mysql-router', + 'gnocchi-mysql-router', + 'heat-mysql-router', + 'keystone-mysql-router', + 'magnum-mysql-router', + 'manila-ganesha-mysql-router', + 'manila-mysql-router', + 'neutron-mysql-router', + 'nova-mysql-router', + 'octavia-mysql-router', + 'placement-mysql-router', + 'vault-mysql-router', + 'watcher-mysql-router', ] @@ -231,7 +259,10 @@ def get_charm_upgrade_groups(model_name=None, extra_filters=None): :returns: Dict of group lists keyed on group name. :rtype: collections.OrderedDict """ - filters = _apply_extra_filters([], extra_filters) + filters = [ + _filter_openstack_upgrade_list, + ] + filters = _apply_extra_filters(filters, extra_filters) apps_in_model = get_upgrade_candidates( model_name=model_name, filters=filters) @@ -306,13 +337,18 @@ def determine_next_openstack_release(release): The returned value is a tuple of the form: ('2020.1', 'ussuri') - :param release: the release to use as the base + :param release: the release version or codename to use as the base :type release: str :returns: the release tuple immediately after the current one. :rtype: Tuple[str, str] :raises: KeyError if the current release doesn't actually exist """ - old_index = list(OPENSTACK_CODENAMES.values()).index(release) + version_match = r"[0-9]{4}\.[0-2]" + if re.match(version_match, release): + releases = list(OPENSTACK_CODENAMES.keys()) + else: + releases = list(OPENSTACK_CODENAMES.values()) + old_index = releases.index(release) new_index = old_index + 1 return list(OPENSTACK_CODENAMES.items())[new_index] From 1bb67ab122be0316fbe51e1c2522a38df04d2f35 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Thu, 26 Oct 2023 12:23:33 +0000 Subject: [PATCH 2/2] Improve charm_upgrade imports and remove test pprints --- .../utilities/test_zaza_utilities_upgrade_utils.py | 9 --------- zaza/openstack/charm_tests/charm_upgrade/tests.py | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/unit_tests/utilities/test_zaza_utilities_upgrade_utils.py b/unit_tests/utilities/test_zaza_utilities_upgrade_utils.py index 7a814c5..2032d18 100644 --- a/unit_tests/utilities/test_zaza_utilities_upgrade_utils.py +++ b/unit_tests/utilities/test_zaza_utilities_upgrade_utils.py @@ -14,7 +14,6 @@ import copy import mock -import pprint import unit_tests.utils as ut_utils import zaza.openstack.utilities.upgrade_utils as openstack_upgrade @@ -96,8 +95,6 @@ class TestUpgradeUtils(ut_utils.BaseTestCase): ('Data Plane', ['nova-compute']), ('sweep_up', [])] actual = openstack_upgrade.get_upgrade_groups() - pprint.pprint(expected) - pprint.pprint(actual) self.assertEqual( actual, expected) @@ -111,8 +108,6 @@ class TestUpgradeUtils(ut_utils.BaseTestCase): ('Data Plane', ['nova-compute']), ('sweep_up', ['neutron-openvswitch', 'ntp'])] actual = openstack_upgrade.get_charm_upgrade_groups() - pprint.pprint(expected) - pprint.pprint(actual) self.assertEqual( actual, expected) @@ -126,8 +121,6 @@ class TestUpgradeUtils(ut_utils.BaseTestCase): ('Data Plane', ['nova-compute']), ('sweep_up', ['ntp'])] actual = openstack_upgrade.get_series_upgrade_groups() - pprint.pprint(expected) - pprint.pprint(actual) self.assertEqual( actual, expected) @@ -141,8 +134,6 @@ class TestUpgradeUtils(ut_utils.BaseTestCase): ('sweep_up', ['ntp'])] actual = openstack_upgrade.get_series_upgrade_groups( target_series='focal') - pprint.pprint(expected) - pprint.pprint(actual) self.assertEqual( actual, expected) diff --git a/zaza/openstack/charm_tests/charm_upgrade/tests.py b/zaza/openstack/charm_tests/charm_upgrade/tests.py index 52223e4..f2df62e 100644 --- a/zaza/openstack/charm_tests/charm_upgrade/tests.py +++ b/zaza/openstack/charm_tests/charm_upgrade/tests.py @@ -22,8 +22,8 @@ import unittest import zaza.model from zaza.openstack.utilities import ( cli as cli_utils, - os_versions as os_versions, - upgrade_utils as upgrade_utils, + os_versions, + upgrade_utils, )