Skip to content

Commit

Permalink
Updates for charm/openstack upgrade testing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Corey Bryant committed Oct 20, 2023
1 parent 18e5b6d commit cc02d81
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 59 deletions.
15 changes: 15 additions & 0 deletions unit_tests/utilities/test_zaza_utilities_upgrade_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ def test_get_upgrade_groups(self):
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']),
Expand Down
50 changes: 18 additions & 32 deletions zaza/openstack/charm_tests/charm_upgrade/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
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):
Expand All @@ -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,
Expand All @@ -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)
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()
self.lts.test_launch_small_instance()
25 changes: 3 additions & 22 deletions zaza/openstack/charm_tests/openstack_upgrade/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
43 changes: 38 additions & 5 deletions zaza/openstack/utilities/upgrade_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,34 @@
'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',
'percona-cluster',
'glance-simplestreams-sync',
'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',
]


Expand Down Expand Up @@ -231,7 +256,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)
Expand Down Expand Up @@ -306,13 +334,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]

Expand Down

0 comments on commit cc02d81

Please sign in to comment.