diff --git a/unit_tests/utilities/test_zaza_utilities_upgrade_utils.py b/unit_tests/utilities/test_zaza_utilities_upgrade_utils.py index 986ba382f..2032d1856 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,19 @@ def test_get_upgrade_groups(self): ('Data Plane', ['nova-compute']), ('sweep_up', [])] actual = openstack_upgrade.get_upgrade_groups() - pprint.pprint(expected) - pprint.pprint(actual) + self.assertEqual( + 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() self.assertEqual( actual, expected) @@ -111,8 +121,6 @@ def test_get_series_upgrade_groups(self): ('Data Plane', ['nova-compute']), ('sweep_up', ['ntp'])] actual = openstack_upgrade.get_series_upgrade_groups() - pprint.pprint(expected) - pprint.pprint(actual) self.assertEqual( actual, expected) @@ -126,8 +134,6 @@ def test_get_series_upgrade_groups(self): ('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 f55caf042..f2df62e36 100644 --- a/zaza/openstack/charm_tests/charm_upgrade/tests.py +++ b/zaza/openstack/charm_tests/charm_upgrade/tests.py @@ -22,9 +22,9 @@ import zaza.model from zaza.openstack.utilities import ( cli as cli_utils, - upgrade_utils as upgrade_utils, + os_versions, + 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 @@ def test_200_run_charm_upgrade(self): 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 661a07679..36629b1bb 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 @@ def test_100_wait_for_happy_mysql_innodb_cluster(self): 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 @@ def setUpClass(cls): 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 3add34624..8c038725e 100644 --- a/zaza/openstack/utilities/upgrade_utils.py +++ b/zaza/openstack/utilities/upgrade_utils.py @@ -50,9 +50,37 @@ '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]