Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 1 | import pytest |
| 2 | |
| 3 | from tcp_tests import logger |
| 4 | from tcp_tests import settings |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 5 | |
| 6 | LOG = logger.logger |
| 7 | |
| 8 | |
| 9 | class TestUpdateMcpCluster(object): |
| 10 | """ |
| 11 | Following the steps in |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 12 | 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] | 13 | """ |
| 14 | |
| 15 | @pytest.mark.grab_versions |
| 16 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 17 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 18 | def test_update_drivetrain(self, salt_actions, drivetrain_actions, |
| 19 | show_step, _): |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 20 | """Updating DriveTrain component to release/proposed/2019.2.0 version |
| 21 | |
| 22 | Scenario: |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 23 | 1. Add workaround for PROD-32751 |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 24 | 2. Run job git-mirror-downstream-mk-pipelines |
| 25 | 3. Run job git-mirror-downstream-pipeline-library |
| 26 | 4. If jobs are passed then start 'Deploy - upgrade MCP Drivetrain' |
| 27 | |
| 28 | Duration: ~35 min |
| 29 | """ |
| 30 | salt = salt_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 31 | dt = drivetrain_actions |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 32 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 33 | # #################### Add workaround for PROD-32751 ################# |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 34 | show_step(1) |
| 35 | |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 36 | # FIXME: workaround for PROD-32751 |
| 37 | salt.cmd_run("cfg01*", "cd /srv/salt/reclass; git add -u && \ |
| 38 | git commit --allow-empty -m 'Cluster model update'") |
| 39 | |
| 40 | # ################### Downstream mk-pipelines ######################### |
| 41 | show_step(2) |
| 42 | job_name = 'git-mirror-downstream-mk-pipelines' |
| 43 | job_parameters = { |
| 44 | 'BRANCHES': 'release/proposed/2019.2.0' |
| 45 | } |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 46 | update_pipelines = dt.start_job_on_cid_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 47 | job_name=job_name, |
| 48 | job_parameters=job_parameters) |
| 49 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 50 | assert update_pipelines == 'SUCCESS' |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 51 | |
| 52 | # ################### Downstream pipeline-library #################### |
| 53 | show_step(3) |
| 54 | job_name = 'git-mirror-downstream-pipeline-library' |
| 55 | job_parameters = { |
| 56 | 'BRANCHES': 'release/proposed/2019.2.0' |
| 57 | } |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 58 | update_pipeline_library = dt.start_job_on_cid_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 59 | job_name=job_name, |
| 60 | job_parameters=job_parameters) |
| 61 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 62 | assert update_pipeline_library == 'SUCCESS' |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 63 | |
| 64 | # ################### Start 'Deploy - upgrade MCP Drivetrain' job ##### |
| 65 | show_step(4) |
| 66 | |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 67 | job_name = 'upgrade-mcp-release' |
| 68 | job_parameters = { |
| 69 | 'MK_PIPELINES_REFSPEC': 'release/proposed/2019.2.0', |
| 70 | 'TARGET_MCP_VERSION': '2019.2.0' |
| 71 | } |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 72 | update_drivetrain = dt.start_job_on_cid_jenkins( |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 73 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 74 | job_parameters=job_parameters, |
| 75 | build_timeout=3600) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 76 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 77 | assert update_drivetrain == 'SUCCESS' |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 78 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 79 | @pytest.mark.grab_versions |
| 80 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
Hanna Arhipova | 71ecc27 | 2019-08-20 14:54:22 +0300 | [diff] [blame] | 81 | @pytest.mark.run_mcp_update |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 82 | def test_update_glusterfs(self, salt_actions, reclass_actions, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 83 | drivetrain_actions, show_step, _): |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 84 | """ Upgrade GlusterFS |
| 85 | Scenario: |
| 86 | 1. In infra/init.yml in Reclass, add the glusterfs_version parameter |
| 87 | 2. Start linux.system.repo state |
| 88 | 3. Start "update-glusterfs" job |
| 89 | 4. Check version for GlusterFS servers |
| 90 | 5. Check version for GlusterFS clients |
| 91 | |
| 92 | """ |
| 93 | salt = salt_actions |
| 94 | reclass = reclass_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 95 | dt = drivetrain_actions |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 96 | |
| 97 | def has_only_similar(param_by_nodes): |
| 98 | """ |
| 99 | :param param_by_nodes: dict |
| 100 | :return: bool, True if all items in the dict have similar keys |
| 101 | """ |
| 102 | params = list(param_by_nodes.values()) |
| 103 | |
| 104 | def are_similar(x): return x == params[0] |
| 105 | |
| 106 | return all(map(are_similar, params)), |
| 107 | # ############## Change reclass ###################################### |
| 108 | show_step(1) |
| 109 | reclass.add_key( |
| 110 | "parameters._param.linux_system_repo_mcp_glusterfs_version_number", |
| 111 | "5", |
| 112 | "cluster/*/infra/init.yml" |
| 113 | ) |
| 114 | # ################# Run linux.system state ########################### |
| 115 | show_step(2) |
| 116 | salt.enforce_state("*", "linux.system.repo") |
| 117 | |
| 118 | # ############## Start deploy-upgrade-galera job ##################### |
| 119 | show_step(3) |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 120 | job_name = 'update-glusterfs' |
| 121 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 122 | update_glusterfs = dt.start_job_on_cid_jenkins( |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 123 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 124 | build_timeout=40 * 60) |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 125 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 126 | assert update_glusterfs == 'SUCCESS' |
Hanna Arhipova | cc3759b | 2019-08-28 16:01:11 +0300 | [diff] [blame] | 127 | |
| 128 | # ################ Check GlusterFS version for servers ############## |
| 129 | show_step(4) |
| 130 | gluster_server_versions_by_nodes = salt.cmd_run( |
| 131 | "I@glusterfs:server", |
| 132 | "glusterd --version|head -n1")[0] |
| 133 | |
| 134 | assert has_only_similar(gluster_server_versions_by_nodes),\ |
| 135 | gluster_server_versions_by_nodes |
| 136 | |
| 137 | # ################ Check GlusterFS version for clients ############## |
| 138 | show_step(5) |
| 139 | gluster_client_versions_by_nodes = salt.cmd_run( |
| 140 | "I@glusterfs:client", |
| 141 | "glusterfs --version|head -n1")[0] |
| 142 | |
| 143 | assert has_only_similar(gluster_client_versions_by_nodes), \ |
| 144 | gluster_client_versions_by_nodes |
| 145 | |
| 146 | @pytest.mark.grab_versions |
| 147 | @pytest.mark.parametrize("_", [settings.ENV_NAME]) |
| 148 | @pytest.mark.run_mcp_update |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 149 | def test_update_galera(self, salt_actions, reclass_actions, |
| 150 | drivetrain_actions, show_step, _): |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 151 | """ Upgrade Galera automatically |
| 152 | |
| 153 | Scenario: |
| 154 | 1. Include the Galera upgrade pipeline job to DriveTrain |
| 155 | 2. Apply the jenkins.client state on the Jenkins nodes |
| 156 | 3. set the openstack_upgrade_enabled parameter to true |
| 157 | 4. Refresh pillars |
| 158 | 5. Add repositories with new Galera packages |
| 159 | 6. Start job from Jenkins |
| 160 | """ |
| 161 | salt = salt_actions |
| 162 | reclass = reclass_actions |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 163 | dt = drivetrain_actions |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 164 | # ################### Enable pipeline ################################# |
| 165 | show_step(1) |
| 166 | reclass.add_class( |
| 167 | "system.jenkins.client.job.deploy.update.upgrade_galera", |
| 168 | "cluster/*/cicd/control/leader.yml") |
| 169 | show_step(2) |
| 170 | salt.enforce_state("I@jenkins:client", "jenkins.client") |
| 171 | |
| 172 | # ############### Enable automatic upgrade ############################ |
| 173 | show_step(3) |
| 174 | reclass.add_bool_key("parameters._param.openstack_upgrade_enabled", |
| 175 | "True", |
| 176 | "cluster/*/infra/init.yml") |
| 177 | |
| 178 | show_step(4) |
| 179 | salt.enforce_state("dbs*", "saltutil.refresh_pillar") |
| 180 | |
| 181 | # ############# Add repositories with new Galera packages ####### |
| 182 | show_step(5) |
| 183 | salt.enforce_state("dbs*", "linux.system.repo") |
| 184 | salt.enforce_state("cfg*", "salt.master") |
| 185 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 186 | # #################### Login Jenkins on cid01 node ################### |
| 187 | show_step(6) |
| 188 | |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 189 | job_name = 'deploy-upgrade-galera' |
| 190 | job_parameters = { |
| 191 | 'INTERACTIVE': 'false' |
| 192 | } |
| 193 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 194 | update_galera = dt.start_job_on_cid_jenkins( |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 195 | job_name=job_name, |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 196 | job_parameters=job_parameters, |
| 197 | build_timeout=40 * 60) |
Hanna Arhipova | 94a8abe | 2019-08-22 14:11:46 +0300 | [diff] [blame] | 198 | |
Hanna Arhipova | 17b2c10 | 2019-09-06 16:44:17 +0300 | [diff] [blame] | 199 | assert update_galera == 'SUCCESS' |