Merge pull request #386 from ajkavanagh/fix-charm-upgrade-tests
Fix the charm-upgrade tests as used by CoT
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import collections
|
||||
import copy
|
||||
import mock
|
||||
import pprint
|
||||
@@ -89,12 +88,13 @@ class TestUpgradeUtils(ut_utils.BaseTestCase):
|
||||
expected)
|
||||
|
||||
def test_get_upgrade_groups(self):
|
||||
expected = collections.OrderedDict([
|
||||
expected = [
|
||||
('Database Services', []),
|
||||
('Stateful Services', []),
|
||||
('Core Identity', []),
|
||||
('Control Plane', ['cinder']),
|
||||
('Data Plane', ['nova-compute']),
|
||||
('sweep_up', [])])
|
||||
('sweep_up', [])]
|
||||
actual = openstack_upgrade.get_upgrade_groups()
|
||||
pprint.pprint(expected)
|
||||
pprint.pprint(actual)
|
||||
@@ -103,12 +103,13 @@ class TestUpgradeUtils(ut_utils.BaseTestCase):
|
||||
expected)
|
||||
|
||||
def test_get_series_upgrade_groups(self):
|
||||
expected = collections.OrderedDict([
|
||||
('Stateful Services', ['mydb']),
|
||||
expected = [
|
||||
('Database Services', ['mydb']),
|
||||
('Stateful Services', []),
|
||||
('Core Identity', []),
|
||||
('Control Plane', ['cinder']),
|
||||
('Data Plane', ['nova-compute']),
|
||||
('sweep_up', ['ntp'])])
|
||||
('sweep_up', ['ntp'])]
|
||||
actual = openstack_upgrade.get_series_upgrade_groups()
|
||||
pprint.pprint(expected)
|
||||
pprint.pprint(actual)
|
||||
|
||||
@@ -53,8 +53,11 @@ class FullCloudCharmUpgradeTest(unittest.TestCase):
|
||||
"""Run charm upgrade."""
|
||||
self.lts.test_launch_small_instance()
|
||||
applications = zaza.model.get_status().applications
|
||||
groups = upgrade_utils.get_charm_upgrade_groups()
|
||||
for group_name, group in groups.items():
|
||||
groups = upgrade_utils.get_charm_upgrade_groups(
|
||||
extra_filters=[upgrade_utils._filter_etcd,
|
||||
upgrade_utils._filter_easyrsa,
|
||||
upgrade_utils._filter_memcached])
|
||||
for group_name, group in groups:
|
||||
logging.info("About to upgrade {} ({})".format(group_name, group))
|
||||
for application, app_details in applications.items():
|
||||
if application not in group:
|
||||
|
||||
@@ -73,11 +73,14 @@ class ParallelSeriesUpgradeTest(unittest.TestCase):
|
||||
workaround_script = None
|
||||
files = []
|
||||
applications = model.get_status().applications
|
||||
for group_name, apps in upgrade_groups.items():
|
||||
for group_name, apps in upgrade_groups:
|
||||
logging.info("About to upgrade {} from {} to {}".format(
|
||||
group_name, from_series, to_series))
|
||||
upgrade_functions = []
|
||||
if group_name in ["Stateful Services", "Data Plane", "sweep_up"]:
|
||||
if group_name in ["Database Services",
|
||||
"Stateful Services",
|
||||
"Data Plane",
|
||||
"sweep_up"]:
|
||||
logging.info("Going to upgrade {} unit by unit".format(apps))
|
||||
upgrade_function = \
|
||||
parallel_series_upgrade.serial_series_upgrade
|
||||
|
||||
@@ -30,22 +30,6 @@ from zaza.openstack.utilities import (
|
||||
from zaza.openstack.charm_tests.nova.tests import LTSGuestCreateTest
|
||||
|
||||
|
||||
def _filter_easyrsa(app, app_config, model_name=None):
|
||||
charm_name = upgrade_utils.extract_charm_name_from_url(app_config['charm'])
|
||||
if "easyrsa" in charm_name:
|
||||
logging.warn("Skipping series upgrade of easyrsa Bug #1850121")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _filter_etcd(app, app_config, model_name=None):
|
||||
charm_name = upgrade_utils.extract_charm_name_from_url(app_config['charm'])
|
||||
if "etcd" in charm_name:
|
||||
logging.warn("Skipping series upgrade of easyrsa Bug #1850124")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class SeriesUpgradeTest(unittest.TestCase):
|
||||
"""Class to encapsulate Series Upgrade Tests."""
|
||||
|
||||
@@ -75,7 +59,7 @@ class SeriesUpgradeTest(unittest.TestCase):
|
||||
continue
|
||||
if "etcd" in app_details["charm"]:
|
||||
logging.warn(
|
||||
"Skipping series upgrade of easyrsa Bug #1850124")
|
||||
"Skipping series upgrade of etcd Bug #1850124")
|
||||
continue
|
||||
charm_name = upgrade_utils.extract_charm_name_from_url(
|
||||
app_details['charm'])
|
||||
@@ -208,10 +192,11 @@ class ParallelSeriesUpgradeTest(unittest.TestCase):
|
||||
# Set Feature Flag
|
||||
os.environ["JUJU_DEV_FEATURE_FLAGS"] = "upgrade-series"
|
||||
upgrade_groups = upgrade_utils.get_series_upgrade_groups(
|
||||
extra_filters=[_filter_etcd, _filter_easyrsa])
|
||||
extra_filters=[upgrade_utils._filter_etcd,
|
||||
upgrade_utils._filter_easyrsa])
|
||||
applications = model.get_status().applications
|
||||
completed_machines = []
|
||||
for group_name, group in upgrade_groups.items():
|
||||
for group_name, group in upgrade_groups:
|
||||
logging.warn("About to upgrade {} ({})".format(group_name, group))
|
||||
upgrade_group = []
|
||||
for application, app_details in applications.items():
|
||||
|
||||
@@ -13,15 +13,17 @@
|
||||
# limitations under the License.
|
||||
|
||||
"""Collection of functions to support upgrade testing."""
|
||||
import re
|
||||
|
||||
import itertools
|
||||
import logging
|
||||
import collections
|
||||
import re
|
||||
|
||||
import zaza.model
|
||||
|
||||
|
||||
SERVICE_GROUPS = collections.OrderedDict([
|
||||
('Stateful Services', ['percona-cluster', 'rabbitmq-server', 'ceph-mon',
|
||||
'mysql-innodb-cluster']),
|
||||
SERVICE_GROUPS = (
|
||||
('Database Services', ['percona-cluster', 'mysql-innodb-cluster']),
|
||||
('Stateful Services', ['rabbitmq-server', 'ceph-mon']),
|
||||
('Core Identity', ['keystone']),
|
||||
('Control Plane', [
|
||||
'aodh', 'barbican', 'ceilometer', 'ceph-fs',
|
||||
@@ -31,8 +33,7 @@ SERVICE_GROUPS = collections.OrderedDict([
|
||||
'nova-cloud-controller', 'openstack-dashboard']),
|
||||
('Data Plane', [
|
||||
'nova-compute', 'ceph-osd',
|
||||
'swift-proxy', 'swift-storage'])
|
||||
])
|
||||
'swift-proxy', 'swift-storage']))
|
||||
|
||||
UPGRADE_EXCLUDE_LIST = ['rabbitmq-server', 'percona-cluster']
|
||||
|
||||
@@ -106,6 +107,30 @@ def _apply_extra_filters(filters, extra_filters):
|
||||
return filters
|
||||
|
||||
|
||||
def _filter_easyrsa(app, app_config, model_name=None):
|
||||
charm_name = extract_charm_name_from_url(app_config['charm'])
|
||||
if "easyrsa" in charm_name:
|
||||
logging.warn("Skipping upgrade of easyrsa Bug #1850121")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _filter_etcd(app, app_config, model_name=None):
|
||||
charm_name = extract_charm_name_from_url(app_config['charm'])
|
||||
if "etcd" in charm_name:
|
||||
logging.warn("Skipping upgrade of easyrsa Bug #1850124")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _filter_memcached(app, app_config, model_name=None):
|
||||
charm_name = extract_charm_name_from_url(app_config['charm'])
|
||||
if "memcached" in charm_name:
|
||||
logging.warn("Skipping upgrade of memcached charm")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_upgrade_groups(model_name=None, extra_filters=None):
|
||||
"""Place apps in the model into their upgrade groups.
|
||||
|
||||
@@ -170,21 +195,21 @@ def get_charm_upgrade_groups(model_name=None, extra_filters=None):
|
||||
|
||||
|
||||
def _build_service_groups(applications):
|
||||
groups = collections.OrderedDict()
|
||||
for phase_name, charms in SERVICE_GROUPS.items():
|
||||
groups = []
|
||||
for phase_name, charms in SERVICE_GROUPS:
|
||||
group = []
|
||||
for app, app_config in applications.items():
|
||||
charm_name = extract_charm_name_from_url(app_config['charm'])
|
||||
if charm_name in charms:
|
||||
group.append(app)
|
||||
groups[phase_name] = group
|
||||
groups.append((phase_name, group))
|
||||
|
||||
sweep_up = []
|
||||
for app in applications:
|
||||
if not (app in [a for group in groups.values() for a in group]):
|
||||
sweep_up.append(app)
|
||||
groups['sweep_up'] = sweep_up
|
||||
for name, group in groups.items():
|
||||
# collect all the values into a list, and then a lookup hash
|
||||
values = list(itertools.chain(*(ls for _, ls in groups)))
|
||||
vhash = {v: 1 for v in values}
|
||||
sweep_up = [app for app in applications if app not in vhash]
|
||||
groups.append(('sweep_up', sweep_up))
|
||||
for name, group in groups:
|
||||
group.sort()
|
||||
return groups
|
||||
|
||||
|
||||
Reference in New Issue
Block a user