Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 1 | import pytest |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 2 | import sys |
| 3 | import os |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 4 | |
| 5 | from tcp_tests import logger |
| 6 | from tcp_tests import settings |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 7 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 8 | sys.path.append(os.getcwd()) |
| 9 | try: |
| 10 | from tcp_tests.fixtures import config_fixtures |
| 11 | from tcp_tests.managers import underlay_ssh_manager |
| 12 | from tcp_tests.managers import saltmanager as salt_manager |
| 13 | except ImportError: |
| 14 | print("ImportError: Run the application from the tcp-qa directory or " |
| 15 | "set the PYTHONPATH environment variable to directory which contains" |
| 16 | " ./tcp_tests") |
| 17 | sys.exit(1) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 18 | LOG = logger.logger |
| 19 | |
| 20 | |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 21 | def has_only_similar(values_by_nodes): |
| 22 | """ |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 23 | :param values_by_nodes: dict |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 24 | :return: bool, True if all items in the dict have similar values |
| 25 | """ |
| 26 | values = list(values_by_nodes.values()) |
| 27 | return all(value == values[0] for value in values) |
| 28 | |
| 29 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 30 | def get_control_plane_targets(): |
| 31 | config = config_fixtures.config() |
| 32 | underlay = underlay_ssh_manager.UnderlaySSHManager(config) |
| 33 | saltmanager = salt_manager.SaltManager(config, underlay) |
Hanna Arhipova | fbcea85 | 2019-10-03 13:24:53 +0300 | [diff] [blame] | 34 | targets = list() |
Hanna Arhipova | 52bb17d | 2019-10-28 19:15:17 +0200 | [diff] [blame] | 35 | telemetry_exists = False |
| 36 | barbican_exists = False |
Hanna Arhipova | fbcea85 | 2019-10-03 13:24:53 +0300 | [diff] [blame] | 37 | try: |
| 38 | targets += saltmanager.run_state( |
| 39 | "I@keystone:server", 'test.ping')[0]['return'][0].keys() |
| 40 | targets += saltmanager.run_state( |
| 41 | "I@nginx:server and not I@salt:master", |
| 42 | "test.ping")[0]['return'][0].keys() |
Hanna Arhipova | 4462dd0 | 2019-10-28 19:05:08 +0200 | [diff] [blame] | 43 | telemetry_exists = saltmanager.get_single_pillar( |
| 44 | "I@salt:master", |
| 45 | "_param:openstack_telemetry_hostname") |
| 46 | barbican_exists = saltmanager.get_single_pillar( |
| 47 | "I@salt:master", |
| 48 | "_param:barbican_enabled") |
Hanna Arhipova | fbcea85 | 2019-10-03 13:24:53 +0300 | [diff] [blame] | 49 | except BaseException as err: |
| 50 | LOG.warning("Can't retrieve data from Salt. \ |
| 51 | Maybe cluster is not deployed completely.\ |
| 52 | Err: {}".format(err)) |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 53 | |
Hanna Arhipova | 75f21bb | 2019-10-07 19:22:15 +0300 | [diff] [blame] | 54 | # check for Manila existence |
| 55 | # if saltmanager.get_single_pillar("I@salt:master", |
| 56 | # "_param:manila_service_protocol"): |
| 57 | # targets.append('share*') |
| 58 | |
| 59 | # check for Tenant Telemetry existence |
Hanna Arhipova | 4462dd0 | 2019-10-28 19:05:08 +0200 | [diff] [blame] | 60 | if telemetry_exists: |
Hanna Arhipova | 75f21bb | 2019-10-07 19:22:15 +0300 | [diff] [blame] | 61 | targets.append('mdb*') |
| 62 | |
| 63 | # check for Barbican existence |
Hanna Arhipova | 4462dd0 | 2019-10-28 19:05:08 +0200 | [diff] [blame] | 64 | if barbican_exists: |
Hanna Arhipova | 75f21bb | 2019-10-07 19:22:15 +0300 | [diff] [blame] | 65 | targets.append('kmn*') |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 66 | return targets |
| 67 | |
| 68 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 69 | @pytest.fixture(scope='class') |
Hanna Arhipova | e1dd27a | 2021-07-28 12:40:40 +0300 | [diff] [blame] | 70 | def update_to_tag(request): |
| 71 | return request.config.getoption("--update-to-tag") |
Hanna Arhipova | 672efc6 | 2021-03-15 09:55:14 +0200 | [diff] [blame] | 72 | |
| 73 | |
| 74 | @pytest.fixture(scope='class') |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 75 | def update_mysql_to_version(request): |
| 76 | return request.config.getoption("--update-mysql-version") |
| 77 | |
| 78 | |
| 79 | @pytest.fixture(scope='class') |
Hanna Arhipova | 672efc6 | 2021-03-15 09:55:14 +0200 | [diff] [blame] | 80 | def switch_to_proposed_pipelines(reclass_actions, salt_actions, |
Hanna Arhipova | e1dd27a | 2021-07-28 12:40:40 +0300 | [diff] [blame] | 81 | update_to_tag): |
| 82 | if update_to_tag: |
Hanna Arhipova | 672efc6 | 2021-03-15 09:55:14 +0200 | [diff] [blame] | 83 | return True |
| 84 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 85 | reclass = reclass_actions |
| 86 | proposed_repo = "http://mirror.mirantis.com/update/proposed/" |
| 87 | repo_param = "parameters._param.linux_system_repo_update_url" |
Hanna Arhipova | 7cfeb07 | 2019-10-11 15:04:10 +0300 | [diff] [blame] | 88 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 89 | proposed_pipeline_branch = "release/proposed/2019.2.0" |
| 90 | pipeline_branch_param = "parameters._param.jenkins_pipelines_branch" |
| 91 | infra_yml = "cluster/*/infra/init.yml" |
| 92 | |
| 93 | LOG.info("Check reclass has release/proposed/2019.2.0 branches") |
| 94 | if reclass.get_key(pipeline_branch_param, |
| 95 | infra_yml) == proposed_pipeline_branch \ |
| 96 | and reclass.get_key(repo_param, infra_yml) == proposed_repo: |
| 97 | return True |
| 98 | |
| 99 | LOG.info("Switch to release/proposed/2019.2.0 branches") |
| 100 | reclass.add_key(pipeline_branch_param, proposed_pipeline_branch, infra_yml) |
| 101 | |
| 102 | reclass.add_key(repo_param, proposed_repo, infra_yml) |
| 103 | reclass.add_key(repo_param, proposed_repo, "cluster/*/openstack/init.yml") |
| 104 | reclass.add_key(repo_param, proposed_repo, "cluster/*/stacklight/init.yml") |
| 105 | reclass.add_key(repo_param, proposed_repo, "cluster/*/ceph/init.yml") |
Hanna Arhipova | 7cfeb07 | 2019-10-11 15:04:10 +0300 | [diff] [blame] | 106 | |
| 107 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
Hanna Arhipova | 9ee7590 | 2019-10-29 16:33:26 +0200 | [diff] [blame] | 108 | salt_actions.enforce_state("*", "salt.minion") |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 109 | salt_actions.enforce_state("I@jenkins:client", "jenkins.client") |
| 110 | |
| 111 | |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 112 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 113 | @pytest.fixture |
| 114 | def wa_for_stacklight_monitor_hostname_prod37068(reclass_actions, |
| 115 | salt_actions): |
| 116 | stacklight_monitor_hostname = salt_actions.cmd_run( |
| 117 | "I@salt:master", |
| 118 | ". /root/venv-reclass-tools/bin/activate; " |
| 119 | "reclass-tools get-key " |
| 120 | "parameters.dogtag.server.stacklight_monitor_hostname " |
| 121 | "/srv/salt/reclass/classes/cluster/{env_name}" |
| 122 | "/openstack/barbican.yml".format( |
| 123 | env_name=settings.ENV_NAME)) |
| 124 | |
| 125 | if stacklight_monitor_hostname != '': |
| 126 | reclass_actions.add_key( |
| 127 | "parameters.dogtag.server.stacklight_monitor_hostname", |
| 128 | "mon", |
| 129 | "cluster/*/openstack/barbican.yml" |
| 130 | ) |
| 131 | salt_actions.cmd_run("cfg01*", |
| 132 | "cd /srv/salt/reclass; git add -u && " |
| 133 | "git commit --allow-empty " |
| 134 | "-m 'fix stacklight_monitor_hostname " |
| 135 | "for dogtag'") |
| 136 | else: |
| 137 | LOG.info("Skipping WA stacklight_monitor_hostname fix prod37068") |
| 138 | |
| 139 | |
Hanna Arhipova | 745fdbb | 2020-03-30 14:40:44 +0300 | [diff] [blame] | 140 | @pytest.fixture |
Hanna Arhipova | ec201e7 | 2020-10-26 17:14:25 +0200 | [diff] [blame] | 141 | def wa_for_galera_clustercheck_password_prod35705(reclass_actions, |
| 142 | salt_actions): |
Hanna Arhipova | 0e816d2 | 2021-01-29 00:17:44 +0200 | [diff] [blame] | 143 | tgt = "I@galera:master or I@galera:slave" |
| 144 | if not salt_actions.get_pillar(tgt, |
| 145 | "_param:galera_clustercheck_password")[0]: |
| 146 | reclass_actions.add_key( |
| 147 | "parameters._param.galera_clustercheck_password", |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 148 | "a" * 32, |
Hanna Arhipova | 0e816d2 | 2021-01-29 00:17:44 +0200 | [diff] [blame] | 149 | "cluster/*/infra/secrets.yml") |
| 150 | salt_actions.run_state(tgt, "saltutil.refresh_pillar") |
| 151 | salt_actions.enforce_state(tgt, "galera") |
| 152 | salt_actions.enforce_state(tgt, "haproxy") |
| 153 | reclass_actions.commit( |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 154 | "[from TCP-QA] Add galera_clustercheck_password") |
Hanna Arhipova | 0e816d2 | 2021-01-29 00:17:44 +0200 | [diff] [blame] | 155 | else: |
Hanna Arhipova | 672efc6 | 2021-03-15 09:55:14 +0200 | [diff] [blame] | 156 | |
Hanna Arhipova | 0e816d2 | 2021-01-29 00:17:44 +0200 | [diff] [blame] | 157 | LOG.info("Skipping WA for Galera Clustercheck Password") |
Hanna Arhipova | 745fdbb | 2020-03-30 14:40:44 +0300 | [diff] [blame] | 158 | |
| 159 | |
Hanna Arhipova | 97fac6e | 2020-12-03 13:10:56 +0200 | [diff] [blame] | 160 | @pytest.fixture |
PGlazov | f597729 | 2021-11-25 19:38:27 +0400 | [diff] [blame] | 161 | def wa_cve_2021_20288_global_id_reclaim(reclass_actions, |
| 162 | salt_actions): |
| 163 | tgt = "I@ceph:common" |
| 164 | context_file = "cluster/*/ceph/common.yml" |
| 165 | if not reclass_actions.check_existence( |
Pavel Glazov | 6ed8d44 | 2022-09-20 12:50:18 +0400 | [diff] [blame] | 166 | 'parameters.ceph.common.config.mon.' + |
| 167 | 'auth_allow_insecure_global_id_reclaim'): |
PGlazov | 4b01396 | 2022-01-31 14:01:42 +0400 | [diff] [blame] | 168 | if salt_actions.get_single_pillar( |
| 169 | "I@ceph:mgr and *01.*", |
| 170 | "_param.ceph_version") == 'luminous': |
| 171 | LOG.info('Skip reclaim set') |
| 172 | return |
PGlazov | f597729 | 2021-11-25 19:38:27 +0400 | [diff] [blame] | 173 | reclass_actions.add_bool_key( |
Pavel Glazov | 6ed8d44 | 2022-09-20 12:50:18 +0400 | [diff] [blame] | 174 | 'parameters.ceph.common.config.mon.' + |
| 175 | 'auth_allow_insecure_global_id_reclaim', "False", context_file) |
PGlazov | f597729 | 2021-11-25 19:38:27 +0400 | [diff] [blame] | 176 | salt_actions.run_state(tgt, "state.apply", "ceph.common") |
| 177 | salt_actions.cmd_run(tgt, "systemctl restart ceph-mon.target") |
| 178 | else: |
| 179 | LOG.info("Skipping WA ceph set auth_allow_insecure_global_id_reclaim") |
| 180 | |
| 181 | |
| 182 | @pytest.fixture |
Hanna Arhipova | 97fac6e | 2020-12-03 13:10:56 +0200 | [diff] [blame] | 183 | def wa_for_alerta_password_prod35958(reclass_actions, |
| 184 | salt_actions): |
Hanna Arhipova | 0e816d2 | 2021-01-29 00:17:44 +0200 | [diff] [blame] | 185 | if not salt_actions.get_pillar("I@prometheus:alerta", |
| 186 | "_param:alerta_admin_api_key_generated")[0]: |
| 187 | reclass_actions.add_key( |
| 188 | "parameters._param.alerta_admin_api_key_generated", |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 189 | "a" * 32, |
Hanna Arhipova | 0e816d2 | 2021-01-29 00:17:44 +0200 | [diff] [blame] | 190 | "cluster/*/infra/secrets.yml") |
| 191 | reclass_actions.add_key( |
| 192 | "parameters._param.alerta_admin_key", |
| 193 | "${_param:alerta_admin_api_key_generated}", |
| 194 | "cluster/*/stacklight/init.yml") |
| 195 | reclass_actions.commit("[from TCP-QA] Add alerta_admin_key") |
| 196 | salt_actions.run_state( |
| 197 | "I@prometheus:alerta or I@prometheus:alertmanager", |
| 198 | "saltutil.refresh_pillar") |
| 199 | salt_actions.enforce_state( |
| 200 | "I@prometheus:alerta", "prometheus.alerta") |
| 201 | salt_actions.enforce_state( |
| 202 | "I@prometheus:alertmanager", "prometheus.alertmanager") |
| 203 | salt_actions.enforce_state( |
| 204 | "I@prometheus:alerta or I@prometheus:alertmanager", |
| 205 | "docker.client") |
| 206 | else: |
| 207 | LOG.info("Skipping WA for Alerta API key") |
Hanna Arhipova | 97fac6e | 2020-12-03 13:10:56 +0200 | [diff] [blame] | 208 | |
| 209 | |
Vladimir Khlyunev | 5fe0aaa | 2022-08-16 23:13:22 +0400 | [diff] [blame] | 210 | @pytest.fixture |
| 211 | def wa_redis_server_version_3_prod36960(reclass_actions, salt_actions): |
| 212 | version_pillar = "redis:server:version" |
| 213 | tgt = "I@{}".format(version_pillar) |
| 214 | pillar_file = "cluster/*/openstack/telemetry.yml" |
| 215 | redis_target_version = "5.0" |
| 216 | |
| 217 | msg_nodes = salt_actions.get_minions_by_target(tgt) |
| 218 | if not msg_nodes: |
| 219 | LOG.info("dbs* nodes not found, skipping") |
| 220 | return |
| 221 | else: |
| 222 | msg_node = msg_nodes[0] |
| 223 | |
| 224 | if str(salt_actions.get_single_pillar( |
| 225 | msg_node, |
| 226 | version_pillar)) == redis_target_version: |
| 227 | LOG.info("Redis-server is already '{}', skipping".format( |
| 228 | redis_target_version)) |
| 229 | return |
| 230 | |
| 231 | LOG.info("Setting redis-server version to '{}'".format( |
| 232 | redis_target_version)) |
| 233 | reclass_actions.add_key( |
| 234 | "parameters.{}".format(version_pillar.replace(":", ".")), |
| 235 | redis_target_version, |
| 236 | pillar_file) |
| 237 | salt_actions.run_state(" or ".join(msg_nodes), |
| 238 | "saltutil.refresh_pillar") |
| 239 | |
| 240 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 241 | @pytest.fixture(scope='class') |
| 242 | def enable_openstack_update(reclass_actions, salt_actions): |
| 243 | param = "parameters._param.openstack_upgrade_enabled" |
| 244 | context_file = "cluster/*/infra/init.yml" |
| 245 | |
| 246 | LOG.info("Enable openstack_upgrade_enabled in reclass") |
| 247 | reclass_actions.add_bool_key(param, "True", context_file) |
| 248 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
| 249 | yield True |
| 250 | LOG.info("Disable openstack_upgrade_enabled in reclass") |
| 251 | reclass_actions.add_bool_key(param, "False", context_file) |
| 252 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
| 253 | |
| 254 | |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 255 | @pytest.fixture(scope='class') |
Pavel Glazov | 6ee164c | 2022-12-12 06:42:28 +0400 | [diff] [blame] | 256 | def switch_to_staging_updates_mirantis_repo(update_to_tag, |
| 257 | reclass_actions, |
| 258 | salt_actions): |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 259 | version_param = "parameters._param.updates_mirantis_version" |
| 260 | infra_yml = "cluster/*/infra/init.yml" |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 261 | current_version = reclass_actions.get_key(version_param, infra_yml) |
Pavel Glazov | 6ee164c | 2022-12-12 06:42:28 +0400 | [diff] [blame] | 262 | |
| 263 | if update_to_tag is not None: |
| 264 | reclass_actions.add_key(version_param, update_to_tag, infra_yml) |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 265 | if current_version == 'staging': |
| 266 | LOG.info("updates.mirantis.com already set to 'staging', skipping") |
| 267 | return |
| 268 | if current_version is None: |
| 269 | LOG.info("updates.mirantis.com is not enabled, " |
| 270 | "skipping /staging repo pillar") |
| 271 | return |
Pavel Glazov | 6ee164c | 2022-12-12 06:42:28 +0400 | [diff] [blame] | 272 | if current_version is not None: |
| 273 | LOG.info("updates.mirantis.com is other tag " |
| 274 | "skipping /staging repo pillar") |
| 275 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
| 276 | return |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 277 | |
| 278 | LOG.info("Switch to updates.mirantis.com/staging repo") |
| 279 | reclass_actions.add_key(version_param, 'staging', infra_yml) |
| 280 | |
| 281 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
| 282 | |
| 283 | |
Hanna Arhipova | 745fdbb | 2020-03-30 14:40:44 +0300 | [diff] [blame] | 284 | @pytest.mark.usefixtures("switch_to_proposed_pipelines", |
Hanna Arhipova | e1dd27a | 2021-07-28 12:40:40 +0300 | [diff] [blame] | 285 | "update_to_tag", |
Hanna Arhipova | 97fac6e | 2020-12-03 13:10:56 +0200 | [diff] [blame] | 286 | "wa_for_galera_clustercheck_password_prod35705", |
Vladimir Khlyunev | 5fe0aaa | 2022-08-16 23:13:22 +0400 | [diff] [blame] | 287 | "wa_for_alerta_password_prod35958", |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 288 | "wa_redis_server_version_3_prod36960", |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 289 | "wa_for_stacklight_monitor_hostname_prod37068", |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 290 | "switch_to_staging_updates_mirantis_repo") |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 291 | class TestUpdateMcpCluster(object): |
| 292 | """ |
| 293 | Following the steps in |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 294 | https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update.html#minor-update |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 295 | """ |
| 296 | |
| 297 | @pytest.mark.grab_versions |
| 298 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 299 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 300 | def test_update_drivetrain(self, salt_actions, drivetrain_actions, |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 301 | show_step, update_to_tag, reclass_actions, _): |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 302 | """Updating DriveTrain component to release/proposed/2019.2.0 version |
| 303 | |
| 304 | Scenario: |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 305 | 1. Add workaround for PROD-32751 |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 306 | 2. Run job git-mirror-downstream-mk-pipelines |
| 307 | 3. Run job git-mirror-downstream-pipeline-library |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 308 | 4. Switch mcp-ci/pipeline-library to new version |
| 309 | 5. Run job pre-upgrade-verify |
| 310 | 6. If jobs are passed then start 'Deploy - upgrade MCP Drivetrain' |
| 311 | 7. Wait till salt-master completes all async jobs |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 312 | |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 313 | Duration: ~70 min |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 314 | """ |
| 315 | salt = salt_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 316 | dt = drivetrain_actions |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 317 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 318 | # #################### Add workaround for PROD-32751 ################# |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 319 | show_step(1) |
| 320 | |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 321 | # FIXME: workaround for PROD-32751 |
| 322 | salt.cmd_run("cfg01*", "cd /srv/salt/reclass; git add -u && \ |
| 323 | git commit --allow-empty -m 'Cluster model update'") |
| 324 | |
| 325 | # ################### Downstream mk-pipelines ######################### |
| 326 | show_step(2) |
| 327 | job_name = 'git-mirror-downstream-mk-pipelines' |
| 328 | job_parameters = { |
Hanna Arhipova | e1dd27a | 2021-07-28 12:40:40 +0300 | [diff] [blame] | 329 | 'BRANCHES': '*' or |
| 330 | 'release/proposed/2019.2.0' |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 331 | } |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 332 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 333 | job_name=job_name, |
Hanna Arhipova | c3c5929 | 2020-04-23 16:29:09 +0300 | [diff] [blame] | 334 | job_parameters=job_parameters, |
| 335 | verbose=True) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 336 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 337 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 338 | |
| 339 | # ################### Downstream pipeline-library #################### |
| 340 | show_step(3) |
| 341 | job_name = 'git-mirror-downstream-pipeline-library' |
| 342 | job_parameters = { |
Hanna Arhipova | e1dd27a | 2021-07-28 12:40:40 +0300 | [diff] [blame] | 343 | 'BRANCHES': '*' or |
| 344 | 'release/proposed/2019.2.0' |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 345 | } |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 346 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 347 | job_name=job_name, |
Hanna Arhipova | c3c5929 | 2020-04-23 16:29:09 +0300 | [diff] [blame] | 348 | job_parameters=job_parameters, |
| 349 | verbose=True) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 350 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 351 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 352 | |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 353 | # ############### Switch mcp-ci/pipeline-library to new version######## |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 354 | show_step(4) |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 355 | |
| 356 | # https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/ |
| 357 | # update-upgrade/minor-update/preupdate-drivetrain-verify.html |
| 358 | actual_piplines_version = salt.get_single_pillar( |
| 359 | "I@salt:master", |
| 360 | "_param:jenkins_pipelines_branch") |
| 361 | LOG.info(actual_piplines_version) |
Pavel Glazov | 16d86e8 | 2023-03-30 15:06:14 +0400 | [diff] [blame] | 362 | if update_to_tag is not None: |
| 363 | if actual_piplines_version != "refs/tags/{}".format( |
| 364 | update_to_tag): |
| 365 | reclass_actions.add_key( |
| 366 | 'parameters._param.jenkins_pipelines_branch', |
| 367 | "refs/tags/{}".format( |
| 368 | update_to_tag), |
| 369 | 'cluster/*/infra/init.yml') |
| 370 | salt.run_state("I@jenkins:client and not I@salt:master", |
| 371 | "saltutil.refresh_pillar") |
| 372 | salt_actions.enforce_state("I@jenkins:client:lib", |
| 373 | "jenkins.client.lib") |
| 374 | salt_actions.cmd_run("cfg01*", |
| 375 | "cd /srv/salt/reclass; git add -u && " |
| 376 | "git commit --allow-empty " |
| 377 | "-m 'use workaround for PROD-37068 " |
| 378 | "missing'") |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 379 | |
| 380 | # ############### Start 'Pre-upgrade verify' job (since 2019.2.17)##### |
| 381 | show_step(5) |
dtsapikov | cbff233 | 2022-01-19 19:32:22 +0400 | [diff] [blame] | 382 | job_name = 'pre-upgrade-verify' |
| 383 | job_parameters = {} |
| 384 | |
Pavel Glazov | 794b1a9 | 2022-10-03 16:33:04 +0400 | [diff] [blame] | 385 | if (dt.check_job_exists_on_jenkins(job_name)): |
dtsapikov | cbff233 | 2022-01-19 19:32:22 +0400 | [diff] [blame] | 386 | LOG.info("Pre-upgrade verify job exists on Jenkins!") |
| 387 | job_result, job_description = dt.start_job_on_jenkins( |
| 388 | job_name=job_name, |
| 389 | job_parameters=job_parameters, |
| 390 | verbose=True, |
| 391 | build_timeout=4 * 60 * 60) |
| 392 | |
| 393 | assert job_result == 'SUCCESS', job_description |
| 394 | |
| 395 | # ################### Start 'Deploy - upgrade MCP Drivetrain' job ##### |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 396 | show_step(6) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 397 | |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 398 | job_name = 'upgrade-mcp-release' |
| 399 | job_parameters = { |
Hanna Arhipova | e1dd27a | 2021-07-28 12:40:40 +0300 | [diff] [blame] | 400 | 'GIT_REFSPEC': update_to_tag or 'release/proposed/2019.2.0', |
PGlazov | 1df9e54 | 2021-11-16 02:31:49 +0400 | [diff] [blame] | 401 | 'MK_PIPELINES_REFSPEC': |
| 402 | update_to_tag or 'release/proposed/2019.2.0', |
Hanna Arhipova | e1dd27a | 2021-07-28 12:40:40 +0300 | [diff] [blame] | 403 | 'TARGET_MCP_VERSION': update_to_tag or '2019.2.0', |
Hanna Arhipova | 874c68f | 2021-03-29 15:57:19 +0300 | [diff] [blame] | 404 | "DRIVE_TRAIN_PARAMS": { |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 405 | "OS_DIST_UPGRADE": True, |
| 406 | "OS_UPGRADE": True, |
| 407 | "BATCH_SIZE": 10 |
| 408 | } |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 409 | } |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 410 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 411 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 412 | job_parameters=job_parameters, |
Hanna Arhipova | c3c5929 | 2020-04-23 16:29:09 +0300 | [diff] [blame] | 413 | verbose=True, |
Hanna Arhipova | e7f2e32 | 2021-02-25 13:53:18 +0200 | [diff] [blame] | 414 | build_timeout=4 * 60 * 60) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 415 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 416 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 7a593da | 2021-06-25 11:16:09 +0300 | [diff] [blame] | 417 | # ############### Wait till salt-master completes all async jobs ##### |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 418 | show_step(7) |
| 419 | salt.wait_jobs_completed(timeout=20 * 60) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 420 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 421 | @pytest.mark.grab_versions |
| 422 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 423 | @pytest.mark.run_mcp_update |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 424 | def test_update_glusterfs(self, salt_actions, reclass_actions, |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 425 | drivetrain_actions, show_step, |
| 426 | update_mysql_to_version, _): |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 427 | """ Upgrade GlusterFS |
| 428 | Scenario: |
| 429 | 1. In infra/init.yml in Reclass, add the glusterfs_version parameter |
| 430 | 2. Start linux.system.repo state |
| 431 | 3. Start "update-glusterfs" job |
| 432 | 4. Check version for GlusterFS servers |
| 433 | 5. Check version for GlusterFS clients |
| 434 | |
| 435 | """ |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 436 | |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 437 | salt = salt_actions |
| 438 | reclass = reclass_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 439 | dt = drivetrain_actions |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 440 | |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 441 | # ############## Change reclass ###################################### |
| 442 | show_step(1) |
| 443 | reclass.add_key( |
| 444 | "parameters._param.linux_system_repo_mcp_glusterfs_version_number", |
| 445 | "5", |
| 446 | "cluster/*/infra/init.yml" |
| 447 | ) |
| 448 | # ################# Run linux.system state ########################### |
| 449 | show_step(2) |
| 450 | salt.enforce_state("*", "linux.system.repo") |
| 451 | |
| 452 | # ############## Start deploy-upgrade-galera job ##################### |
| 453 | show_step(3) |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 454 | job_name = 'update-glusterfs' |
| 455 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 456 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 457 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 458 | build_timeout=40 * 60) |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 459 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 460 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 461 | |
| 462 | # ################ Check GlusterFS version for servers ############## |
| 463 | show_step(4) |
| 464 | gluster_server_versions_by_nodes = salt.cmd_run( |
| 465 | "I@glusterfs:server", |
| 466 | "glusterd --version|head -n1")[0] |
| 467 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 468 | assert has_only_similar(gluster_server_versions_by_nodes), \ |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 469 | gluster_server_versions_by_nodes |
| 470 | |
| 471 | # ################ Check GlusterFS version for clients ############## |
| 472 | show_step(5) |
| 473 | gluster_client_versions_by_nodes = salt.cmd_run( |
| 474 | "I@glusterfs:client", |
| 475 | "glusterfs --version|head -n1")[0] |
| 476 | |
| 477 | assert has_only_similar(gluster_client_versions_by_nodes), \ |
| 478 | gluster_client_versions_by_nodes |
| 479 | |
| 480 | @pytest.mark.grab_versions |
| 481 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 482 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 483 | def test_update_galera(self, salt_actions, reclass_actions, |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 484 | drivetrain_actions, show_step, |
| 485 | update_mysql_to_version, _): |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 486 | """ Upgrade Galera automatically |
| 487 | |
| 488 | Scenario: |
| 489 | 1. Include the Galera upgrade pipeline job to DriveTrain |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 490 | 2. Add fix for mysql 5.7 |
| 491 | 3. Apply the jenkins.client state on the Jenkins nodes |
| 492 | 4. set the openstack_upgrade_enabled parameter to true |
| 493 | 5. Refresh pillars |
| 494 | 6. Add repositories with new Galera packages |
| 495 | 7. Start job from Jenkins |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 496 | """ |
| 497 | salt = salt_actions |
| 498 | reclass = reclass_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 499 | dt = drivetrain_actions |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 500 | # ################### Enable pipeline ################################# |
| 501 | show_step(1) |
| 502 | reclass.add_class( |
| 503 | "system.jenkins.client.job.deploy.update.upgrade_galera", |
| 504 | "cluster/*/cicd/control/leader.yml") |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 505 | # ################### Fix for Mysql 5.7 ############################## |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 506 | show_step(2) |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 507 | if (update_mysql_to_version == '5.7'): |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 508 | mysql_class = "cluster.{env_name}.openstack." \ |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 509 | "database.mysql_version" \ |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 510 | .format(env_name=settings.ENV_NAME) |
| 511 | reclass.add_class( |
| 512 | mysql_class, |
| 513 | "cluster/*/openstack/database/master.yml") |
| 514 | reclass.add_class( |
| 515 | mysql_class, |
| 516 | "cluster/*/openstack/database/slave.yml") |
| 517 | mysql_path = "cluster/{env_name}" \ |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 518 | "/openstack/database/mysql_version.yml" \ |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 519 | .format(env_name=settings.ENV_NAME) |
| 520 | galera_mysql_version = '5.7' |
| 521 | if update_mysql_to_version != '5.7': |
| 522 | galera_mysql_version = update_mysql_to_version |
| 523 | mysql_version = "parameters:\n" \ |
| 524 | " _param:\n" \ |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 525 | " galera_mysql_version: {}" \ |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 526 | .format(galera_mysql_version) |
| 527 | if not os.path.isfile("/srv/salt/reclass/classes/{path}".format( |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 528 | path=mysql_path)): |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 529 | reclass.create_yaml_with_context(mysql_version, |
| 530 | mysql_path) |
| 531 | else: |
| 532 | reclass.merge_context(mysql_version, |
| 533 | mysql_path) |
| 534 | reclass_actions.commit( |
| 535 | "[from TCP-QA] Change for mysql new version") |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 536 | |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 537 | show_step(3) |
Vladimir Khlyunev | 1746827 | 2022-06-29 16:19:36 +0400 | [diff] [blame] | 538 | salt.run_state("I@jenkins:client and not I@salt:master", |
| 539 | "saltutil.refresh_pillar") |
| 540 | salt.enforce_state("I@jenkins:client and not I@salt:master", |
| 541 | "jenkins.client.job") |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 542 | else: |
| 543 | LOG.info("Skip mysql upgrade fix") |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 544 | # ############### Enable automatic upgrade ############################ |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 545 | show_step(4) |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 546 | reclass.add_bool_key("parameters._param.openstack_upgrade_enabled", |
| 547 | "True", |
| 548 | "cluster/*/infra/init.yml") |
| 549 | |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 550 | show_step(5) |
Hanna Arhipova | 7cfeb07 | 2019-10-11 15:04:10 +0300 | [diff] [blame] | 551 | salt.run_state("dbs*", "saltutil.refresh_pillar") |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 552 | |
| 553 | # ############# Add repositories with new Galera packages ####### |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 554 | show_step(6) |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 555 | salt.enforce_state("dbs*", "linux.system.repo") |
| 556 | salt.enforce_state("cfg*", "salt.master") |
| 557 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 558 | # #################### Login Jenkins on cid01 node ################### |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 559 | show_step(7) |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 560 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 561 | job_name = 'deploy-upgrade-galera' |
| 562 | job_parameters = { |
Hanna Arhipova | 874c68f | 2021-03-29 15:57:19 +0300 | [diff] [blame] | 563 | 'INTERACTIVE': 'false', |
| 564 | 'OS_DIST_UPGRADE': 'true', |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 565 | 'OS_UPGRADE': 'true', |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 566 | } |
PGlazov | 554c4fd | 2022-03-23 14:31:41 +0400 | [diff] [blame] | 567 | if (update_mysql_to_version == '5.7'): |
PGlazov | 7efe3b2 | 2022-02-16 17:29:05 +0400 | [diff] [blame] | 568 | job_parameters.update({'UPDATE_TO_MYSQL57': 'true'}) |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 569 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 570 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 571 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 572 | job_parameters=job_parameters, |
Pavel Glazov | 2e9cbcd | 2022-12-06 14:52:53 +0400 | [diff] [blame] | 573 | build_timeout=60 * 60) |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 574 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 575 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 576 | |
| 577 | @pytest.fixture |
| 578 | def disable_automatic_failover_neutron_for_test(self, salt_actions): |
| 579 | """ |
| 580 | On each OpenStack controller node, modify the neutron.conf file |
| 581 | Restart the neutron-server service |
| 582 | """ |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 583 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 584 | def comment_line(node, file_name, word): |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 585 | """ |
| 586 | Adds '#' before the specific line in specific file |
| 587 | |
| 588 | :param node: string, salt target of node where the file locates |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 589 | :param file_name: string, full path to the file |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 590 | :param word: string, the begin of line which should be commented |
| 591 | :return: None |
| 592 | """ |
| 593 | salt_actions.cmd_run(node, |
| 594 | "sed -i 's/^{word}/#{word}/' {file}". |
| 595 | format(word=word, |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 596 | file=file_name)) |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 597 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 598 | def add_line(node, file_name, line): |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 599 | """ |
| 600 | Appends line to the end of file |
| 601 | |
| 602 | :param node: string, salt target of node where the file locates |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 603 | :param file_name: string, full path to the file |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 604 | :param line: string, line that should be added |
| 605 | :return: None |
| 606 | """ |
| 607 | salt_actions.cmd_run(node, "echo {line} >> {file}".format( |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 608 | line=line, |
| 609 | file=file_name)) |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 610 | |
| 611 | neutron_conf = '/etc/neutron/neutron.conf' |
| 612 | neutron_server = "I@neutron:server" |
| 613 | # ######## Create backup for config file ####################### |
| 614 | salt_actions.cmd_run( |
| 615 | neutron_server, |
| 616 | "cp -p {file} {file}.backup".format(file=neutron_conf)) |
| 617 | |
| 618 | # ## Change parameters in neutron.conf' |
| 619 | comment_line(neutron_server, neutron_conf, |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 620 | "allow_automatic_l3agent_failover", ) |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 621 | comment_line(neutron_server, neutron_conf, |
| 622 | "allow_automatic_dhcp_failover") |
| 623 | add_line(neutron_server, neutron_conf, |
| 624 | "allow_automatic_dhcp_failover = false") |
| 625 | add_line(neutron_server, neutron_conf, |
| 626 | "allow_automatic_l3agent_failover = false") |
| 627 | |
| 628 | # ## Apply changed config to the neutron-server service |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 629 | result = salt_actions.cmd_run(neutron_server, |
| 630 | "service neutron-server restart") |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 631 | # TODO: add check that neutron-server is up and running |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 632 | yield result |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 633 | # ## Revert file changes |
| 634 | salt_actions.cmd_run( |
| 635 | neutron_server, |
| 636 | "cp -p {file}.backup {file}".format(file=neutron_conf)) |
| 637 | salt_actions.cmd_run(neutron_server, |
| 638 | "service neutron-server restart") |
| 639 | |
| 640 | @pytest.fixture |
| 641 | def disable_neutron_agents_for_test(self, salt_actions): |
| 642 | """ |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 643 | Disable the neutron services before the test and |
| 644 | enable it after test |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 645 | """ |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 646 | result = salt_actions.cmd_run("I@neutron:server", """ |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 647 | service neutron-dhcp-agent stop && \ |
| 648 | service neutron-l3-agent stop && \ |
| 649 | service neutron-metadata-agent stop && \ |
| 650 | service neutron-openvswitch-agent stop |
| 651 | """) |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 652 | yield result |
| 653 | # |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 654 | salt_actions.cmd_run("I@neutron:server", """ |
| 655 | service neutron-dhcp-agent start && \ |
| 656 | service neutron-l3-agent start && \ |
| 657 | service neutron-metadata-agent start && \ |
| 658 | service neutron-openvswitch-agent start |
| 659 | """) |
| 660 | # TODO: add check that all services are UP and running |
| 661 | |
| 662 | @pytest.mark.grab_versions |
| 663 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 664 | @pytest.mark.run_mcp_update |
| 665 | def test_update_rabbit(self, salt_actions, reclass_actions, |
| 666 | drivetrain_actions, show_step, _, |
| 667 | disable_automatic_failover_neutron_for_test, |
| 668 | disable_neutron_agents_for_test): |
| 669 | """ Updates RabbitMQ |
| 670 | Scenario: |
| 671 | 1. Include the RabbitMQ upgrade pipeline job to DriveTrain |
| 672 | 2. Add repositories with new RabbitMQ packages |
| 673 | 3. Start Deploy - upgrade RabbitMQ pipeline |
| 674 | |
| 675 | Updating RabbitMq should be completed before the OpenStack updating |
| 676 | process starts |
| 677 | """ |
| 678 | salt = salt_actions |
| 679 | reclass = reclass_actions |
| 680 | dt = drivetrain_actions |
| 681 | |
| 682 | # ####### Include the RabbitMQ upgrade pipeline job to DriveTrain #### |
| 683 | show_step(1) |
| 684 | reclass.add_class( |
| 685 | "system.jenkins.client.job.deploy.update.upgrade_rabbitmq", |
| 686 | "cluster/*/cicd/control/leader.yml") |
| 687 | salt.enforce_state("I@jenkins:client", "jenkins.client") |
| 688 | |
| 689 | reclass.add_bool_key("parameters._param.openstack_upgrade_enabled", |
| 690 | "True", |
| 691 | "cluster/*/infra/init.yml") |
| 692 | salt.run_state("I@rabbitmq:server", "saltutil.refresh_pillar") |
| 693 | |
| 694 | # ########### Add repositories with new RabbitMQ packages ############ |
| 695 | show_step(2) |
| 696 | salt.enforce_state("I@rabbitmq:server", "linux.system.repo") |
| 697 | |
| 698 | # ########### Start Deploy - upgrade RabbitMQ pipeline ############ |
| 699 | show_step(3) |
| 700 | job_parameters = { |
Hanna Arhipova | 874c68f | 2021-03-29 15:57:19 +0300 | [diff] [blame] | 701 | 'INTERACTIVE': 'false', |
| 702 | 'OS_DIST_UPGRADE': 'true', |
| 703 | 'OS_UPGRADE': 'true' |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 704 | } |
| 705 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 706 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 707 | job_name='deploy-upgrade-rabbitmq', |
| 708 | job_parameters=job_parameters, |
PGlazov | 99364cb | 2021-09-20 12:36:18 +0400 | [diff] [blame] | 709 | build_timeout=50 * 60 |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 710 | ) |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 711 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 712 | |
| 713 | @pytest.mark.grab_versions |
| 714 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 715 | @pytest.mark.run_mcp_update |
PGlazov | 215a457 | 2022-03-05 05:09:04 +0400 | [diff] [blame] | 716 | def test_update_ceph(self, salt_actions, drivetrain_actions, |
| 717 | reclass_actions, show_step, _): |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 718 | """ Updates Ceph to the latest minor version |
| 719 | |
| 720 | Scenario: |
| 721 | 1. Add workaround for unhealth Ceph |
| 722 | 2. Start ceph-upgrade job with default parameters |
| 723 | 3. Check Ceph version for all nodes |
PGlazov | 215a457 | 2022-03-05 05:09:04 +0400 | [diff] [blame] | 724 | 4. WA id_reclaim only for nautilus |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 725 | |
| 726 | https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update/ceph-update.html |
| 727 | """ |
| 728 | salt = salt_actions |
PGlazov | 215a457 | 2022-03-05 05:09:04 +0400 | [diff] [blame] | 729 | reclass = reclass_actions |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 730 | dt = drivetrain_actions |
| 731 | |
| 732 | # ###################### Add workaround for unhealth Ceph ############ |
| 733 | show_step(1) |
| 734 | salt.cmd_run("I@ceph:radosgw", |
| 735 | "ceph config set 'mon pg warn max object skew' 20") |
| 736 | # ###################### Start ceph-upgrade pipeline ################# |
| 737 | show_step(2) |
| 738 | job_parameters = {} |
| 739 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 740 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 741 | job_name='ceph-update', |
| 742 | job_parameters=job_parameters) |
| 743 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 744 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 745 | |
| 746 | # ########## Verify Ceph version ##################################### |
| 747 | show_step(3) |
| 748 | |
| 749 | ceph_version_by_nodes = salt.cmd_run( |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 750 | "I@ceph:* and not I@ceph:monitoring and not I@ceph:backup:server", |
| 751 | "ceph version")[0] |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 752 | |
| 753 | assert has_only_similar(ceph_version_by_nodes), ceph_version_by_nodes |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 754 | |
PGlazov | 215a457 | 2022-03-05 05:09:04 +0400 | [diff] [blame] | 755 | # ########## WA id_reclaim only for nautilus ######################### |
| 756 | show_step(4) |
| 757 | |
| 758 | ceph_version = salt_actions.get_single_pillar( |
| 759 | "I@salt:master", |
Pavel Glazov | 5093eaf | 2023-03-09 21:02:42 +0400 | [diff] [blame] | 760 | "_param:ceph_version") |
PGlazov | 215a457 | 2022-03-05 05:09:04 +0400 | [diff] [blame] | 761 | if ceph_version == "nautilus": |
| 762 | wa_cve_2021_20288_global_id_reclaim(reclass, salt) |
| 763 | else: |
| 764 | LOG.info("Skip WA for luminous") |
| 765 | |
Hanna Arhipova | ac00856 | 2019-10-17 11:54:23 +0300 | [diff] [blame] | 766 | @pytest.mark.grab_versions |
| 767 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 768 | @pytest.mark.run_mcp_update |
| 769 | def test_update_stacklight(self, _, drivetrain_actions): |
| 770 | """ Update packages for Stacklight |
| 771 | Scenario: |
| 772 | 1. Start Deploy - upgrade Stacklight job |
| 773 | """ |
| 774 | drivetrain = drivetrain_actions |
| 775 | |
| 776 | job_parameters = { |
| 777 | "STAGE_UPGRADE_DOCKER_COMPONENTS": True, |
| 778 | "STAGE_UPGRADE_ES_KIBANA": True, |
Hanna Arhipova | 874c68f | 2021-03-29 15:57:19 +0300 | [diff] [blame] | 779 | "STAGE_UPGRADE_SYSTEM_PART": True, |
| 780 | 'OS_DIST_UPGRADE': 'true', |
| 781 | 'OS_UPGRADE': 'true' |
Hanna Arhipova | ac00856 | 2019-10-17 11:54:23 +0300 | [diff] [blame] | 782 | } |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 783 | job_result, job_description = drivetrain.start_job_on_jenkins( |
Hanna Arhipova | ac00856 | 2019-10-17 11:54:23 +0300 | [diff] [blame] | 784 | job_name="stacklight-upgrade", |
| 785 | job_parameters=job_parameters) |
| 786 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 787 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | ac00856 | 2019-10-17 11:54:23 +0300 | [diff] [blame] | 788 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 789 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 790 | @pytest.mark.usefixtures("switch_to_proposed_pipelines", |
| 791 | "enable_openstack_update") |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 792 | class TestOpenstackUpdate(object): |
| 793 | |
| 794 | @pytest.mark.grab_versions |
| 795 | @pytest.mark.run_mcp_update |
| 796 | def test__pre_update__enable_pipeline_job(self, |
| 797 | reclass_actions, salt_actions, |
| 798 | show_step): |
| 799 | """ Enable pipeline in the Drivetrain |
| 800 | |
| 801 | Scenario: |
| 802 | 1. Add deploy.update.* classes to the reclass |
| 803 | 2. Start jenkins.client salt state |
| 804 | |
| 805 | """ |
| 806 | salt = salt_actions |
| 807 | reclass = reclass_actions |
| 808 | show_step(1) |
| 809 | reclass.add_class("system.jenkins.client.job.deploy.update.upgrade", |
| 810 | "cluster/*/cicd/control/leader.yml") |
| 811 | |
| 812 | reclass.add_class( |
| 813 | "system.jenkins.client.job.deploy.update.upgrade_ovs_gateway", |
| 814 | "cluster/*/cicd/control/leader.yml") |
| 815 | |
| 816 | reclass.add_class( |
| 817 | "system.jenkins.client.job.deploy.update.upgrade_compute", |
| 818 | "cluster/*/cicd/control/leader.yml") |
| 819 | |
| 820 | show_step(2) |
| 821 | r, errors = salt.enforce_state("I@jenkins:client", "jenkins.client") |
| 822 | assert errors is None |
| 823 | |
| 824 | @pytest.mark.grab_versions |
| 825 | @pytest.mark.parametrize('target', get_control_plane_targets()) |
| 826 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 827 | def test__update__control_plane(self, drivetrain_actions, target): |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 828 | """Start 'Deploy - upgrade control VMs' for specific node |
| 829 | """ |
| 830 | job_parameters = { |
| 831 | "TARGET_SERVERS": target, |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 832 | "OS_DIST_UPGRADE": True, |
PGlazov | a503925 | 2021-10-06 21:40:01 +0400 | [diff] [blame] | 833 | "UPGRADE_SALTSTACK": True, |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 834 | "OS_UPGRADE": True, |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 835 | "INTERACTIVE": False} |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 836 | job_result, job_description = drivetrain_actions.start_job_on_jenkins( |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 837 | job_name="deploy-upgrade-control", |
| 838 | job_parameters=job_parameters) |
| 839 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 840 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 841 | |
| 842 | @pytest.mark.grab_versions |
| 843 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 844 | def test__update__data_plane(self, drivetrain_actions, salt_actions): |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 845 | """Start 'Deploy - upgrade OVS gateway' |
| 846 | """ |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 847 | if not salt_actions.cmd_run("gtw*", "test.ping")[0].keys(): |
| 848 | pytest.skip("This deployment doesn't have gtw* nodes") |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 849 | job_parameters = { |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 850 | "OS_DIST_UPGRADE": True, |
| 851 | "OS_UPGRADE": True, |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 852 | "INTERACTIVE": False} |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 853 | job_result, job_description = drivetrain_actions.start_job_on_jenkins( |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 854 | job_name="deploy-upgrade-ovs-gateway", |
| 855 | job_parameters=job_parameters) |
| 856 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 857 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 858 | |
| 859 | @pytest.mark.grab_versions |
| 860 | @pytest.mark.run_mcp_update |
| 861 | def test__update__computes(self, drivetrain_actions): |
| 862 | """Start 'Deploy - upgrade computes' |
| 863 | """ |
| 864 | job_parameters = { |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 865 | "OS_DIST_UPGRADE": True, |
| 866 | "OS_UPGRADE": True, |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 867 | "INTERACTIVE": False} |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 868 | job_result, job_description = drivetrain_actions.start_job_on_jenkins( |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 869 | job_name="deploy-upgrade-compute", |
| 870 | job_parameters=job_parameters) |
| 871 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 872 | assert job_result == 'SUCCESS', job_description |