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 | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 70 | def switch_to_proposed_pipelines(reclass_actions, salt_actions): |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 71 | reclass = reclass_actions |
| 72 | proposed_repo = "http://mirror.mirantis.com/update/proposed/" |
| 73 | repo_param = "parameters._param.linux_system_repo_update_url" |
Hanna Arhipova | 7cfeb07 | 2019-10-11 15:04:10 +0300 | [diff] [blame] | 74 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 75 | proposed_pipeline_branch = "release/proposed/2019.2.0" |
| 76 | pipeline_branch_param = "parameters._param.jenkins_pipelines_branch" |
| 77 | infra_yml = "cluster/*/infra/init.yml" |
| 78 | |
| 79 | LOG.info("Check reclass has release/proposed/2019.2.0 branches") |
| 80 | if reclass.get_key(pipeline_branch_param, |
| 81 | infra_yml) == proposed_pipeline_branch \ |
| 82 | and reclass.get_key(repo_param, infra_yml) == proposed_repo: |
| 83 | return True |
| 84 | |
| 85 | LOG.info("Switch to release/proposed/2019.2.0 branches") |
| 86 | reclass.add_key(pipeline_branch_param, proposed_pipeline_branch, infra_yml) |
| 87 | |
| 88 | reclass.add_key(repo_param, proposed_repo, infra_yml) |
| 89 | reclass.add_key(repo_param, proposed_repo, "cluster/*/openstack/init.yml") |
| 90 | reclass.add_key(repo_param, proposed_repo, "cluster/*/stacklight/init.yml") |
| 91 | reclass.add_key(repo_param, proposed_repo, "cluster/*/ceph/init.yml") |
Hanna Arhipova | 7cfeb07 | 2019-10-11 15:04:10 +0300 | [diff] [blame] | 92 | |
| 93 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
Hanna Arhipova | 9ee7590 | 2019-10-29 16:33:26 +0200 | [diff] [blame] | 94 | salt_actions.enforce_state("*", "salt.minion") |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 95 | salt_actions.enforce_state("I@jenkins:client", "jenkins.client") |
| 96 | |
| 97 | |
Hanna Arhipova | 745fdbb | 2020-03-30 14:40:44 +0300 | [diff] [blame] | 98 | @pytest.fixture |
Hanna Arhipova | ec201e7 | 2020-10-26 17:14:25 +0200 | [diff] [blame] | 99 | def wa_for_galera_clustercheck_password_prod35705(reclass_actions, |
| 100 | salt_actions): |
Hanna Arhipova | 0e816d2 | 2021-01-29 00:17:44 +0200 | [diff] [blame] | 101 | tgt = "I@galera:master or I@galera:slave" |
| 102 | if not salt_actions.get_pillar(tgt, |
| 103 | "_param:galera_clustercheck_password")[0]: |
| 104 | reclass_actions.add_key( |
| 105 | "parameters._param.galera_clustercheck_password", |
| 106 | "a"*32, |
| 107 | "cluster/*/infra/secrets.yml") |
| 108 | salt_actions.run_state(tgt, "saltutil.refresh_pillar") |
| 109 | salt_actions.enforce_state(tgt, "galera") |
| 110 | salt_actions.enforce_state(tgt, "haproxy") |
| 111 | reclass_actions.commit( |
| 112 | "[from TCP-QA] Add galera_clustercheck_password") |
| 113 | else: |
| 114 | LOG.info("Skipping WA for Galera Clustercheck Password") |
Hanna Arhipova | 745fdbb | 2020-03-30 14:40:44 +0300 | [diff] [blame] | 115 | |
| 116 | |
Hanna Arhipova | 97fac6e | 2020-12-03 13:10:56 +0200 | [diff] [blame] | 117 | @pytest.fixture |
| 118 | def wa_for_alerta_password_prod35958(reclass_actions, |
| 119 | salt_actions): |
Hanna Arhipova | 0e816d2 | 2021-01-29 00:17:44 +0200 | [diff] [blame] | 120 | |
| 121 | if not salt_actions.get_pillar("I@prometheus:alerta", |
| 122 | "_param:alerta_admin_api_key_generated")[0]: |
| 123 | reclass_actions.add_key( |
| 124 | "parameters._param.alerta_admin_api_key_generated", |
| 125 | "a"*32, |
| 126 | "cluster/*/infra/secrets.yml") |
| 127 | reclass_actions.add_key( |
| 128 | "parameters._param.alerta_admin_key", |
| 129 | "${_param:alerta_admin_api_key_generated}", |
| 130 | "cluster/*/stacklight/init.yml") |
| 131 | reclass_actions.commit("[from TCP-QA] Add alerta_admin_key") |
| 132 | salt_actions.run_state( |
| 133 | "I@prometheus:alerta or I@prometheus:alertmanager", |
| 134 | "saltutil.refresh_pillar") |
| 135 | salt_actions.enforce_state( |
| 136 | "I@prometheus:alerta", "prometheus.alerta") |
| 137 | salt_actions.enforce_state( |
| 138 | "I@prometheus:alertmanager", "prometheus.alertmanager") |
| 139 | salt_actions.enforce_state( |
| 140 | "I@prometheus:alerta or I@prometheus:alertmanager", |
| 141 | "docker.client") |
| 142 | else: |
| 143 | LOG.info("Skipping WA for Alerta API key") |
Hanna Arhipova | 97fac6e | 2020-12-03 13:10:56 +0200 | [diff] [blame] | 144 | |
| 145 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 146 | @pytest.fixture(scope='class') |
| 147 | def enable_openstack_update(reclass_actions, salt_actions): |
| 148 | param = "parameters._param.openstack_upgrade_enabled" |
| 149 | context_file = "cluster/*/infra/init.yml" |
| 150 | |
| 151 | LOG.info("Enable openstack_upgrade_enabled in reclass") |
| 152 | reclass_actions.add_bool_key(param, "True", context_file) |
| 153 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
| 154 | yield True |
| 155 | LOG.info("Disable openstack_upgrade_enabled in reclass") |
| 156 | reclass_actions.add_bool_key(param, "False", context_file) |
| 157 | salt_actions.run_state("*", "saltutil.refresh_pillar") |
| 158 | |
| 159 | |
Hanna Arhipova | 745fdbb | 2020-03-30 14:40:44 +0300 | [diff] [blame] | 160 | @pytest.mark.usefixtures("switch_to_proposed_pipelines", |
Hanna Arhipova | 97fac6e | 2020-12-03 13:10:56 +0200 | [diff] [blame] | 161 | "wa_for_galera_clustercheck_password_prod35705", |
| 162 | "wa_for_alerta_password_prod35958") |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 163 | class TestUpdateMcpCluster(object): |
| 164 | """ |
| 165 | Following the steps in |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 166 | 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] | 167 | """ |
| 168 | |
| 169 | @pytest.mark.grab_versions |
| 170 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 171 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 172 | def test_update_drivetrain(self, salt_actions, drivetrain_actions, |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 173 | show_step, _): |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 174 | """Updating DriveTrain component to release/proposed/2019.2.0 version |
| 175 | |
| 176 | Scenario: |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 177 | 1. Add workaround for PROD-32751 |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 178 | 2. Run job git-mirror-downstream-mk-pipelines |
| 179 | 3. Run job git-mirror-downstream-pipeline-library |
| 180 | 4. If jobs are passed then start 'Deploy - upgrade MCP Drivetrain' |
| 181 | |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 182 | Duration: ~70 min |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 183 | """ |
| 184 | salt = salt_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 185 | dt = drivetrain_actions |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 186 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 187 | # #################### Add workaround for PROD-32751 ################# |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 188 | show_step(1) |
| 189 | |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 190 | # FIXME: workaround for PROD-32751 |
| 191 | salt.cmd_run("cfg01*", "cd /srv/salt/reclass; git add -u && \ |
| 192 | git commit --allow-empty -m 'Cluster model update'") |
| 193 | |
| 194 | # ################### Downstream mk-pipelines ######################### |
| 195 | show_step(2) |
| 196 | job_name = 'git-mirror-downstream-mk-pipelines' |
| 197 | job_parameters = { |
| 198 | 'BRANCHES': 'release/proposed/2019.2.0' |
| 199 | } |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 200 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 201 | job_name=job_name, |
Hanna Arhipova | c3c5929 | 2020-04-23 16:29:09 +0300 | [diff] [blame] | 202 | job_parameters=job_parameters, |
| 203 | verbose=True) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 204 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 205 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 206 | |
| 207 | # ################### Downstream pipeline-library #################### |
| 208 | show_step(3) |
| 209 | job_name = 'git-mirror-downstream-pipeline-library' |
| 210 | job_parameters = { |
| 211 | 'BRANCHES': 'release/proposed/2019.2.0' |
| 212 | } |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 213 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 214 | job_name=job_name, |
Hanna Arhipova | c3c5929 | 2020-04-23 16:29:09 +0300 | [diff] [blame] | 215 | job_parameters=job_parameters, |
| 216 | verbose=True) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 217 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 218 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 219 | |
| 220 | # ################### Start 'Deploy - upgrade MCP Drivetrain' job ##### |
| 221 | show_step(4) |
| 222 | |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 223 | job_name = 'upgrade-mcp-release' |
| 224 | job_parameters = { |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 225 | 'GIT_REFSPEC': 'release/proposed/2019.2.0', |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 226 | 'MK_PIPELINES_REFSPEC': 'release/proposed/2019.2.0', |
| 227 | 'TARGET_MCP_VERSION': '2019.2.0' |
| 228 | } |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 229 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 230 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 231 | job_parameters=job_parameters, |
Hanna Arhipova | c3c5929 | 2020-04-23 16:29:09 +0300 | [diff] [blame] | 232 | verbose=True, |
Hanna Arhipova | e7f2e32 | 2021-02-25 13:53:18 +0200 | [diff] [blame^] | 233 | build_timeout=4 * 60 * 60) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 234 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 235 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 236 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 237 | @pytest.mark.grab_versions |
| 238 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 239 | @pytest.mark.run_mcp_update |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 240 | def test_update_glusterfs(self, salt_actions, reclass_actions, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 241 | drivetrain_actions, show_step, _): |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 242 | """ Upgrade GlusterFS |
| 243 | Scenario: |
| 244 | 1. In infra/init.yml in Reclass, add the glusterfs_version parameter |
| 245 | 2. Start linux.system.repo state |
| 246 | 3. Start "update-glusterfs" job |
| 247 | 4. Check version for GlusterFS servers |
| 248 | 5. Check version for GlusterFS clients |
| 249 | |
| 250 | """ |
| 251 | salt = salt_actions |
| 252 | reclass = reclass_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 253 | dt = drivetrain_actions |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 254 | |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 255 | # ############## Change reclass ###################################### |
| 256 | show_step(1) |
| 257 | reclass.add_key( |
| 258 | "parameters._param.linux_system_repo_mcp_glusterfs_version_number", |
| 259 | "5", |
| 260 | "cluster/*/infra/init.yml" |
| 261 | ) |
| 262 | # ################# Run linux.system state ########################### |
| 263 | show_step(2) |
| 264 | salt.enforce_state("*", "linux.system.repo") |
| 265 | |
| 266 | # ############## Start deploy-upgrade-galera job ##################### |
| 267 | show_step(3) |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 268 | job_name = 'update-glusterfs' |
| 269 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 270 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 271 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 272 | build_timeout=40 * 60) |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 273 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 274 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 275 | |
| 276 | # ################ Check GlusterFS version for servers ############## |
| 277 | show_step(4) |
| 278 | gluster_server_versions_by_nodes = salt.cmd_run( |
| 279 | "I@glusterfs:server", |
| 280 | "glusterd --version|head -n1")[0] |
| 281 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 282 | assert has_only_similar(gluster_server_versions_by_nodes), \ |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 283 | gluster_server_versions_by_nodes |
| 284 | |
| 285 | # ################ Check GlusterFS version for clients ############## |
| 286 | show_step(5) |
| 287 | gluster_client_versions_by_nodes = salt.cmd_run( |
| 288 | "I@glusterfs:client", |
| 289 | "glusterfs --version|head -n1")[0] |
| 290 | |
| 291 | assert has_only_similar(gluster_client_versions_by_nodes), \ |
| 292 | gluster_client_versions_by_nodes |
| 293 | |
| 294 | @pytest.mark.grab_versions |
| 295 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 296 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 297 | def test_update_galera(self, salt_actions, reclass_actions, |
| 298 | drivetrain_actions, show_step, _): |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 299 | """ Upgrade Galera automatically |
| 300 | |
| 301 | Scenario: |
| 302 | 1. Include the Galera upgrade pipeline job to DriveTrain |
| 303 | 2. Apply the jenkins.client state on the Jenkins nodes |
| 304 | 3. set the openstack_upgrade_enabled parameter to true |
| 305 | 4. Refresh pillars |
| 306 | 5. Add repositories with new Galera packages |
| 307 | 6. Start job from Jenkins |
| 308 | """ |
| 309 | salt = salt_actions |
| 310 | reclass = reclass_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 311 | dt = drivetrain_actions |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 312 | # ################### Enable pipeline ################################# |
| 313 | show_step(1) |
| 314 | reclass.add_class( |
| 315 | "system.jenkins.client.job.deploy.update.upgrade_galera", |
| 316 | "cluster/*/cicd/control/leader.yml") |
| 317 | show_step(2) |
| 318 | salt.enforce_state("I@jenkins:client", "jenkins.client") |
| 319 | |
| 320 | # ############### Enable automatic upgrade ############################ |
| 321 | show_step(3) |
| 322 | reclass.add_bool_key("parameters._param.openstack_upgrade_enabled", |
| 323 | "True", |
| 324 | "cluster/*/infra/init.yml") |
| 325 | |
| 326 | show_step(4) |
Hanna Arhipova | 7cfeb07 | 2019-10-11 15:04:10 +0300 | [diff] [blame] | 327 | salt.run_state("dbs*", "saltutil.refresh_pillar") |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 328 | |
| 329 | # ############# Add repositories with new Galera packages ####### |
| 330 | show_step(5) |
| 331 | salt.enforce_state("dbs*", "linux.system.repo") |
| 332 | salt.enforce_state("cfg*", "salt.master") |
| 333 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 334 | # #################### Login Jenkins on cid01 node ################### |
| 335 | show_step(6) |
| 336 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 337 | job_name = 'deploy-upgrade-galera' |
| 338 | job_parameters = { |
| 339 | 'INTERACTIVE': 'false' |
| 340 | } |
| 341 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 342 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 343 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 344 | job_parameters=job_parameters, |
| 345 | build_timeout=40 * 60) |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 346 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 347 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 348 | |
| 349 | @pytest.fixture |
| 350 | def disable_automatic_failover_neutron_for_test(self, salt_actions): |
| 351 | """ |
| 352 | On each OpenStack controller node, modify the neutron.conf file |
| 353 | Restart the neutron-server service |
| 354 | """ |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 355 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 356 | def comment_line(node, file_name, word): |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 357 | """ |
| 358 | Adds '#' before the specific line in specific file |
| 359 | |
| 360 | :param node: string, salt target of node where the file locates |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 361 | :param file_name: string, full path to the file |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 362 | :param word: string, the begin of line which should be commented |
| 363 | :return: None |
| 364 | """ |
| 365 | salt_actions.cmd_run(node, |
| 366 | "sed -i 's/^{word}/#{word}/' {file}". |
| 367 | format(word=word, |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 368 | file=file_name)) |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 369 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 370 | def add_line(node, file_name, line): |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 371 | """ |
| 372 | Appends line to the end of file |
| 373 | |
| 374 | :param node: string, salt target of node where the file locates |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 375 | :param file_name: string, full path to the file |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 376 | :param line: string, line that should be added |
| 377 | :return: None |
| 378 | """ |
| 379 | salt_actions.cmd_run(node, "echo {line} >> {file}".format( |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 380 | line=line, |
| 381 | file=file_name)) |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 382 | |
| 383 | neutron_conf = '/etc/neutron/neutron.conf' |
| 384 | neutron_server = "I@neutron:server" |
| 385 | # ######## Create backup for config file ####################### |
| 386 | salt_actions.cmd_run( |
| 387 | neutron_server, |
| 388 | "cp -p {file} {file}.backup".format(file=neutron_conf)) |
| 389 | |
| 390 | # ## Change parameters in neutron.conf' |
| 391 | comment_line(neutron_server, neutron_conf, |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 392 | "allow_automatic_l3agent_failover", ) |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 393 | comment_line(neutron_server, neutron_conf, |
| 394 | "allow_automatic_dhcp_failover") |
| 395 | add_line(neutron_server, neutron_conf, |
| 396 | "allow_automatic_dhcp_failover = false") |
| 397 | add_line(neutron_server, neutron_conf, |
| 398 | "allow_automatic_l3agent_failover = false") |
| 399 | |
| 400 | # ## Apply changed config to the neutron-server service |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 401 | result = salt_actions.cmd_run(neutron_server, |
| 402 | "service neutron-server restart") |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 403 | # TODO: add check that neutron-server is up and running |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 404 | yield result |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 405 | # ## Revert file changes |
| 406 | salt_actions.cmd_run( |
| 407 | neutron_server, |
| 408 | "cp -p {file}.backup {file}".format(file=neutron_conf)) |
| 409 | salt_actions.cmd_run(neutron_server, |
| 410 | "service neutron-server restart") |
| 411 | |
| 412 | @pytest.fixture |
| 413 | def disable_neutron_agents_for_test(self, salt_actions): |
| 414 | """ |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 415 | Disable the neutron services before the test and |
| 416 | enable it after test |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 417 | """ |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 418 | result = salt_actions.cmd_run("I@neutron:server", """ |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 419 | service neutron-dhcp-agent stop && \ |
| 420 | service neutron-l3-agent stop && \ |
| 421 | service neutron-metadata-agent stop && \ |
| 422 | service neutron-openvswitch-agent stop |
| 423 | """) |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 424 | yield result |
| 425 | # |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 426 | salt_actions.cmd_run("I@neutron:server", """ |
| 427 | service neutron-dhcp-agent start && \ |
| 428 | service neutron-l3-agent start && \ |
| 429 | service neutron-metadata-agent start && \ |
| 430 | service neutron-openvswitch-agent start |
| 431 | """) |
| 432 | # TODO: add check that all services are UP and running |
| 433 | |
| 434 | @pytest.mark.grab_versions |
| 435 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 436 | @pytest.mark.run_mcp_update |
| 437 | def test_update_rabbit(self, salt_actions, reclass_actions, |
| 438 | drivetrain_actions, show_step, _, |
| 439 | disable_automatic_failover_neutron_for_test, |
| 440 | disable_neutron_agents_for_test): |
| 441 | """ Updates RabbitMQ |
| 442 | Scenario: |
| 443 | 1. Include the RabbitMQ upgrade pipeline job to DriveTrain |
| 444 | 2. Add repositories with new RabbitMQ packages |
| 445 | 3. Start Deploy - upgrade RabbitMQ pipeline |
| 446 | |
| 447 | Updating RabbitMq should be completed before the OpenStack updating |
| 448 | process starts |
| 449 | """ |
| 450 | salt = salt_actions |
| 451 | reclass = reclass_actions |
| 452 | dt = drivetrain_actions |
| 453 | |
| 454 | # ####### Include the RabbitMQ upgrade pipeline job to DriveTrain #### |
| 455 | show_step(1) |
| 456 | reclass.add_class( |
| 457 | "system.jenkins.client.job.deploy.update.upgrade_rabbitmq", |
| 458 | "cluster/*/cicd/control/leader.yml") |
| 459 | salt.enforce_state("I@jenkins:client", "jenkins.client") |
| 460 | |
| 461 | reclass.add_bool_key("parameters._param.openstack_upgrade_enabled", |
| 462 | "True", |
| 463 | "cluster/*/infra/init.yml") |
| 464 | salt.run_state("I@rabbitmq:server", "saltutil.refresh_pillar") |
| 465 | |
| 466 | # ########### Add repositories with new RabbitMQ packages ############ |
| 467 | show_step(2) |
| 468 | salt.enforce_state("I@rabbitmq:server", "linux.system.repo") |
| 469 | |
| 470 | # ########### Start Deploy - upgrade RabbitMQ pipeline ############ |
| 471 | show_step(3) |
| 472 | job_parameters = { |
| 473 | 'INTERACTIVE': 'false' |
| 474 | } |
| 475 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 476 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | 1fcaf44 | 2019-09-06 15:30:45 +0300 | [diff] [blame] | 477 | job_name='deploy-upgrade-rabbitmq', |
| 478 | job_parameters=job_parameters, |
| 479 | build_timeout=40 * 60 |
| 480 | ) |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 481 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 482 | |
| 483 | @pytest.mark.grab_versions |
| 484 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 485 | @pytest.mark.run_mcp_update |
| 486 | def test_update_ceph(self, salt_actions, drivetrain_actions, show_step, _): |
| 487 | """ Updates Ceph to the latest minor version |
| 488 | |
| 489 | Scenario: |
| 490 | 1. Add workaround for unhealth Ceph |
| 491 | 2. Start ceph-upgrade job with default parameters |
| 492 | 3. Check Ceph version for all nodes |
| 493 | |
| 494 | https://docs.mirantis.com/mcp/master/mcp-operations-guide/update-upgrade/minor-update/ceph-update.html |
| 495 | """ |
| 496 | salt = salt_actions |
| 497 | dt = drivetrain_actions |
| 498 | |
| 499 | # ###################### Add workaround for unhealth Ceph ############ |
| 500 | show_step(1) |
| 501 | salt.cmd_run("I@ceph:radosgw", |
| 502 | "ceph config set 'mon pg warn max object skew' 20") |
| 503 | # ###################### Start ceph-upgrade pipeline ################# |
| 504 | show_step(2) |
| 505 | job_parameters = {} |
| 506 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 507 | job_result, job_description = dt.start_job_on_jenkins( |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 508 | job_name='ceph-update', |
| 509 | job_parameters=job_parameters) |
| 510 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 511 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 512 | |
| 513 | # ########## Verify Ceph version ##################################### |
| 514 | show_step(3) |
| 515 | |
| 516 | ceph_version_by_nodes = salt.cmd_run( |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 517 | "I@ceph:* and not I@ceph:monitoring and not I@ceph:backup:server", |
| 518 | "ceph version")[0] |
Hanna Arhipova | d35a29b | 2019-09-04 13:24:06 +0300 | [diff] [blame] | 519 | |
| 520 | assert has_only_similar(ceph_version_by_nodes), ceph_version_by_nodes |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 521 | |
Hanna Arhipova | ac00856 | 2019-10-17 11:54:23 +0300 | [diff] [blame] | 522 | @pytest.mark.grab_versions |
| 523 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 524 | @pytest.mark.run_mcp_update |
| 525 | def test_update_stacklight(self, _, drivetrain_actions): |
| 526 | """ Update packages for Stacklight |
| 527 | Scenario: |
| 528 | 1. Start Deploy - upgrade Stacklight job |
| 529 | """ |
| 530 | drivetrain = drivetrain_actions |
| 531 | |
| 532 | job_parameters = { |
| 533 | "STAGE_UPGRADE_DOCKER_COMPONENTS": True, |
| 534 | "STAGE_UPGRADE_ES_KIBANA": True, |
| 535 | "STAGE_UPGRADE_SYSTEM_PART": True |
| 536 | } |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 537 | job_result, job_description = drivetrain.start_job_on_jenkins( |
Hanna Arhipova | ac00856 | 2019-10-17 11:54:23 +0300 | [diff] [blame] | 538 | job_name="stacklight-upgrade", |
| 539 | job_parameters=job_parameters) |
| 540 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 541 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | ac00856 | 2019-10-17 11:54:23 +0300 | [diff] [blame] | 542 | |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 543 | |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 544 | @pytest.mark.usefixtures("switch_to_proposed_pipelines", |
| 545 | "enable_openstack_update") |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 546 | class TestOpenstackUpdate(object): |
| 547 | |
| 548 | @pytest.mark.grab_versions |
| 549 | @pytest.mark.run_mcp_update |
| 550 | def test__pre_update__enable_pipeline_job(self, |
| 551 | reclass_actions, salt_actions, |
| 552 | show_step): |
| 553 | """ Enable pipeline in the Drivetrain |
| 554 | |
| 555 | Scenario: |
| 556 | 1. Add deploy.update.* classes to the reclass |
| 557 | 2. Start jenkins.client salt state |
| 558 | |
| 559 | """ |
| 560 | salt = salt_actions |
| 561 | reclass = reclass_actions |
| 562 | show_step(1) |
| 563 | reclass.add_class("system.jenkins.client.job.deploy.update.upgrade", |
| 564 | "cluster/*/cicd/control/leader.yml") |
| 565 | |
| 566 | reclass.add_class( |
| 567 | "system.jenkins.client.job.deploy.update.upgrade_ovs_gateway", |
| 568 | "cluster/*/cicd/control/leader.yml") |
| 569 | |
| 570 | reclass.add_class( |
| 571 | "system.jenkins.client.job.deploy.update.upgrade_compute", |
| 572 | "cluster/*/cicd/control/leader.yml") |
| 573 | |
| 574 | show_step(2) |
| 575 | r, errors = salt.enforce_state("I@jenkins:client", "jenkins.client") |
| 576 | assert errors is None |
| 577 | |
| 578 | @pytest.mark.grab_versions |
| 579 | @pytest.mark.parametrize('target', get_control_plane_targets()) |
| 580 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 581 | def test__update__control_plane(self, drivetrain_actions, target): |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 582 | """Start 'Deploy - upgrade control VMs' for specific node |
| 583 | """ |
| 584 | job_parameters = { |
| 585 | "TARGET_SERVERS": target, |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 586 | "OS_DIST_UPGRADE": True, |
PGlazov | ed19b35 | 2020-05-21 16:42:27 +0400 | [diff] [blame] | 587 | "UPGRADE_SALTSTACK": False, |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 588 | "OS_UPGRADE": True, |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 589 | "INTERACTIVE": False} |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 590 | job_result, job_description = drivetrain_actions.start_job_on_jenkins( |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 591 | job_name="deploy-upgrade-control", |
| 592 | job_parameters=job_parameters) |
| 593 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 594 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 595 | |
| 596 | @pytest.mark.grab_versions |
| 597 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 598 | def test__update__data_plane(self, drivetrain_actions, salt_actions): |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 599 | """Start 'Deploy - upgrade OVS gateway' |
| 600 | """ |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 601 | if not salt_actions.cmd_run("gtw*", "test.ping")[0].keys(): |
| 602 | pytest.skip("This deployment doesn't have gtw* nodes") |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 603 | job_parameters = { |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 604 | "OS_DIST_UPGRADE": True, |
| 605 | "OS_UPGRADE": True, |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 606 | "INTERACTIVE": False} |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 607 | job_result, job_description = drivetrain_actions.start_job_on_jenkins( |
Hanna Arhipova | eb3a211 | 2019-09-13 18:45:21 +0300 | [diff] [blame] | 608 | job_name="deploy-upgrade-ovs-gateway", |
| 609 | job_parameters=job_parameters) |
| 610 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 611 | assert job_result == 'SUCCESS', job_description |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 612 | |
| 613 | @pytest.mark.grab_versions |
| 614 | @pytest.mark.run_mcp_update |
| 615 | def test__update__computes(self, drivetrain_actions): |
| 616 | """Start 'Deploy - upgrade computes' |
| 617 | """ |
| 618 | job_parameters = { |
Hanna Arhipova | 606d518 | 2019-12-13 13:23:55 +0200 | [diff] [blame] | 619 | "OS_DIST_UPGRADE": True, |
| 620 | "OS_UPGRADE": True, |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 621 | "INTERACTIVE": False} |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 622 | job_result, job_description = drivetrain_actions.start_job_on_jenkins( |
Hanna Arhipova | 1942996 | 2019-10-17 15:16:49 +0300 | [diff] [blame] | 623 | job_name="deploy-upgrade-compute", |
| 624 | job_parameters=job_parameters) |
| 625 | |
Hanna Arhipova | 508f653 | 2021-01-27 15:52:45 +0200 | [diff] [blame] | 626 | assert job_result == 'SUCCESS', job_description |