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