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