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 |
| 14 | https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/update-upgrade/minor-update.html#minor-update |
| 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 | |
| 137 | @pytest.mark.run_mcp_update |
| 138 | def test_update_gluster(self): |
| 139 | pass |