예제 #1
0
 def test_get_series_upgrade_groups(self):
     expected = [('Database Services', ['mydb']), ('Stateful Services', []),
                 ('Core Identity', []), ('Control Plane', ['cinder']),
                 ('Data Plane', ['nova-compute']), ('sweep_up', ['ntp'])]
     actual = openstack_upgrade.get_series_upgrade_groups()
     pprint.pprint(expected)
     pprint.pprint(actual)
     self.assertEqual(actual, expected)
     # test that, at focal, there are no database services.
     expected = [('Database Services', []), ('Stateful Services', []),
                 ('Core Identity', []), ('Control Plane', ['cinder']),
                 ('Data Plane', ['nova-compute']), ('sweep_up', ['ntp'])]
     actual = openstack_upgrade.get_series_upgrade_groups(
         target_series='focal')
     pprint.pprint(expected)
     pprint.pprint(actual)
     self.assertEqual(actual, expected)
예제 #2
0
 def test_get_series_upgrade_groups(self):
     expected = collections.OrderedDict([('Core Identity', []),
                                         ('Control Plane', ['cinder']),
                                         ('Data Plane', ['nova-compute']),
                                         ('sweep_up', ['mydb', 'ntp'])])
     actual = openstack_upgrade.get_series_upgrade_groups()
     pprint.pprint(expected)
     pprint.pprint(actual)
     self.assertEqual(actual, expected)
    def test_200_run_series_upgrade(self):
        """Run series upgrade."""
        # 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],
            target_series=self.to_series)
        from_series = self.from_series
        to_series = self.to_series
        completed_machines = []
        workaround_script = None
        files = []
        applications = model.get_status().applications
        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 [
                    "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
            else:
                logging.info("Going to upgrade {} all at once".format(apps))
                upgrade_function = \
                    parallel_series_upgrade.parallel_series_upgrade

            # allow up to 4 parallel upgrades at a time.  This is to limit the
            # amount of data/calls that asyncio is handling as it's gets
            # unstable if all the applications are done at the same time.
            sem = asyncio.Semaphore(4)
            for charm_name in apps:
                charm = applications[charm_name]['charm']
                name = upgrade_utils.extract_charm_name_from_url(charm)
                upgrade_config = parallel_series_upgrade.app_config(name)
                upgrade_functions.append(
                    wrap_coroutine_with_sem(
                        sem,
                        upgrade_function(charm_name,
                                         **upgrade_config,
                                         from_series=from_series,
                                         to_series=to_series,
                                         completed_machines=completed_machines,
                                         workaround_script=workaround_script,
                                         files=files)))
            asyncio.get_event_loop().run_until_complete(
                asyncio.gather(*upgrade_functions))
            model.block_until_all_units_idle()
            logging.info("Finished {}".format(group_name))
        logging.info("Done!")
예제 #4
0
    def test_200_run_series_upgrade(self):
        """Run series upgrade."""
        # Set Feature Flag
        os.environ["JUJU_DEV_FEATURE_FLAGS"] = "upgrade-series"
        upgrade_groups = upgrade_utils.get_series_upgrade_groups(
            extra_filters=[
                upgrade_utils._filter_etcd, upgrade_utils._filter_easyrsa
            ],
            target_series=self.to_series)
        applications = model.get_status().applications
        completed_machines = []
        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():
                if application not in group:
                    continue
                charm_name = upgrade_utils.extract_charm_name_from_url(
                    app_details['charm'])
                upgrade_config = series_upgrade_utils.app_config(charm_name)
                upgrade_function = upgrade_config.pop('upgrade_function')
                logging.warn("About to upgrade {}".format(application))
                upgrade_group.append(
                    upgrade_function(
                        application,
                        **upgrade_config,
                        from_series=self.from_series,
                        to_series=self.to_series,
                        completed_machines=completed_machines,
                        workaround_script=self.workaround_script,
                        files=self.files,
                    ))
            asyncio.get_event_loop().run_until_complete(
                asyncio.gather(*upgrade_group))
            if "rabbitmq-server" in group:
                logging.info(
                    "Running complete-cluster-series-upgrade action on leader")
                model.run_action_on_leader('rabbitmq-server',
                                           'complete-cluster-series-upgrade',
                                           action_params={})
                model.block_until_all_units_idle()

            if "percona-cluster" in group:
                logging.info(
                    "Running complete-cluster-series-upgrade action on leader")
                model.run_action_on_leader('mysql',
                                           'complete-cluster-series-upgrade',
                                           action_params={})
                model.block_until_all_units_idle()
    def test_200_run_series_upgrade(self):
        """Run series upgrade."""
        # 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])
        from_series = self.from_series
        to_series = self.to_series
        completed_machines = []
        workaround_script = None
        files = []
        applications = model.get_status().applications
        for group_name, apps in upgrade_groups.items():
            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"]:
                logging.info("Going to upgrade {} unit by unit".format(apps))
                upgrade_function = \
                    parallel_series_upgrade.serial_series_upgrade
            else:
                logging.info("Going to upgrade {} all at once".format(apps))
                upgrade_function = \
                    parallel_series_upgrade.parallel_series_upgrade

            for charm_name in apps:
                charm = applications[charm_name]['charm']
                name = upgrade_utils.extract_charm_name_from_url(charm)
                upgrade_config = parallel_series_upgrade.app_config(name)
                upgrade_functions.append(
                    upgrade_function(charm_name,
                                     **upgrade_config,
                                     from_series=from_series,
                                     to_series=to_series,
                                     completed_machines=completed_machines,
                                     workaround_script=workaround_script,
                                     files=files))
            asyncio.get_event_loop().run_until_complete(
                asyncio.gather(*upgrade_functions))
            model.block_until_all_units_idle()
            logging.info("Finished {}".format(group_name))
        logging.info("Done!")