def test_series_upgrade_application_no_pause(self):
        self.patch_object(generic_utils.model, "run_action")
        self.patch_object(generic_utils, "series_upgrade")
        _application = "app"
        _from_series = "xenial"
        _to_series = "bionic"
        _origin = "source"
        _series_upgrade_calls = []
        _files = ["filename", "scriptname"]
        _workaround_script = "scriptname"
        _completed_machines = []

        for machine_num in ("0", "1", "2"):
            _series_upgrade_calls.append(
                mock.call("{}/{}".format(_application, machine_num),
                          machine_num,
                          origin=_origin,
                          from_series=_from_series,
                          to_series=_to_series,
                          workaround_script=_workaround_script,
                          files=_files), )

        # No Pausiing
        generic_utils.series_upgrade_application(
            _application,
            origin=_origin,
            to_series=_to_series,
            from_series=_from_series,
            pause_non_leader_primary=False,
            pause_non_leader_subordinate=False,
            completed_machines=_completed_machines,
            workaround_script=_workaround_script,
            files=_files)
        self.run_action.assert_not_called()
        self.series_upgrade.assert_has_calls(_series_upgrade_calls)
Ejemplo n.º 2
0
    def test_200_run_series_upgrade(self):
        """Run series upgrade."""
        # Set Feature Flag
        os.environ["JUJU_DEV_FEATURE_FLAGS"] = "upgrade-series"

        applications = model.get_status().applications
        completed_machines = []
        for application in applications:
            # Defaults
            origin = "openstack-origin"
            pause_non_leader_subordinate = True
            pause_non_leader_primary = True
            # Skip subordinates
            if applications[application]["subordinate-to"]:
                continue
            if "percona-cluster" in applications[application]["charm"]:
                origin = "source"
                pause_non_leader_primary = True
                pause_non_leader_subordinate = True
            if "rabbitmq-server" in applications[application]["charm"]:
                origin = "source"
                pause_non_leader_primary = True
                pause_non_leader_subordinate = False
            if "nova-compute" in applications[application]["charm"]:
                pause_non_leader_primary = False
                pause_non_leader_subordinate = False
            if "ceph" in applications[application]["charm"]:
                origin = "source"
                pause_non_leader_primary = False
                pause_non_leader_subordinate = False
            if "memcached" in applications[application]["charm"]:
                origin = None
                pause_non_leader_primary = False
                pause_non_leader_subordinate = False
            if ("mongodb" in applications[application]["charm"]
                    or "vault" in applications[application]["charm"]):
                # Mongodb and vault need to run series upgrade
                # on its secondaries first.
                generic_utils.series_upgrade_non_leaders_first(
                    application,
                    from_series=self.from_series,
                    to_series=self.to_series,
                    completed_machines=completed_machines)
                continue

            # The rest are likley APIs use defaults

            generic_utils.series_upgrade_application(
                application,
                pause_non_leader_primary=pause_non_leader_primary,
                pause_non_leader_subordinate=pause_non_leader_subordinate,
                from_series=self.from_series,
                to_series=self.to_series,
                origin=origin,
                completed_machines=completed_machines,
                workaround_script=self.workaround_script,
                files=self.files)
    def test_series_upgrade_application_pause_peers_and_subordinates(self):
        self.patch_object(generic_utils.model, "run_action")
        self.patch_object(generic_utils, "series_upgrade")
        _application = "app"
        _from_series = "xenial"
        _to_series = "bionic"
        _origin = "source"
        _files = ["filename", "scriptname"]
        _workaround_script = "scriptname"
        _completed_machines = []
        # Peers and Subordinates
        _run_action_calls = [
            mock.call("{}-hacluster/1".format(_application),
                      "pause",
                      action_params={}),
            mock.call("{}/1".format(_application), "pause", action_params={}),
            mock.call("{}-hacluster/2".format(_application),
                      "pause",
                      action_params={}),
            mock.call("{}/2".format(_application), "pause", action_params={}),
        ]
        _series_upgrade_calls = []
        for machine_num in ("0", "1", "2"):
            _series_upgrade_calls.append(
                mock.call("{}/{}".format(_application, machine_num),
                          machine_num,
                          origin=_origin,
                          from_series=_from_series,
                          to_series=_to_series,
                          workaround_script=_workaround_script,
                          files=_files,
                          post_upgrade_functions=None), )

        # Pause primary peers and subordinates
        generic_utils.series_upgrade_application(
            _application,
            origin=_origin,
            to_series=_to_series,
            from_series=_from_series,
            pause_non_leader_primary=True,
            pause_non_leader_subordinate=True,
            completed_machines=_completed_machines,
            workaround_script=_workaround_script,
            files=_files),
        self.run_action.assert_has_calls(_run_action_calls)
        self.series_upgrade.assert_has_calls(_series_upgrade_calls)
Ejemplo n.º 4
0
    def test_200_run_series_upgrade(self):
        """Run series upgrade."""
        # Set Feature Flag
        os.environ["JUJU_DEV_FEATURE_FLAGS"] = "upgrade-series"

        applications = model.get_status().applications
        completed_machines = []
        for application in applications:
            # Defaults
            origin = "openstack-origin"
            pause_non_leader_subordinate = True
            pause_non_leader_primary = True
            post_upgrade_functions = []
            # Skip subordinates
            if applications[application]["subordinate-to"]:
                continue
            if "percona-cluster" in applications[application]["charm"]:
                origin = "source"
                pause_non_leader_primary = True
                pause_non_leader_subordinate = True
            if "rabbitmq-server" in applications[application]["charm"]:
                origin = "source"
                pause_non_leader_primary = True
                pause_non_leader_subordinate = False
            if "nova-compute" in applications[application]["charm"]:
                pause_non_leader_primary = False
                pause_non_leader_subordinate = False
            if "ceph" in applications[application]["charm"]:
                origin = "source"
                pause_non_leader_primary = False
                pause_non_leader_subordinate = False
            if "designate-bind" in applications[application]["charm"]:
                origin = None
            if "tempest" in applications[application]["charm"]:
                origin = None
            if "memcached" in applications[application]["charm"]:
                origin = None
                pause_non_leader_primary = False
                pause_non_leader_subordinate = False
            if "vault" in applications[application]["charm"]:
                post_upgrade_functions = [
                    ('zaza.openstack.charm_tests.vault.setup.'
                     'basic_setup_and_unseal')]
            if ("mongodb" in applications[application]["charm"] or
                    "vault" in applications[application]["charm"]):
                # Mongodb and vault need to run series upgrade
                # on its secondaries first.
                generic_utils.series_upgrade_non_leaders_first(
                    application,
                    from_series=self.from_series,
                    to_series=self.to_series,
                    completed_machines=completed_machines,
                    post_upgrade_functions=post_upgrade_functions)
                continue

            # The rest are likley APIs use defaults

            generic_utils.series_upgrade_application(
                application,
                pause_non_leader_primary=pause_non_leader_primary,
                pause_non_leader_subordinate=pause_non_leader_subordinate,
                from_series=self.from_series,
                to_series=self.to_series,
                origin=origin,
                completed_machines=completed_machines,
                workaround_script=self.workaround_script,
                files=self.files,
                post_upgrade_functions=post_upgrade_functions)

            if "rabbitmq-server" in applications[application]["charm"]:
                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()