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