Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 1 | package com.mirantis.system_qa |
| 2 | |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 3 | import groovy.xml.XmlUtil |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 4 | |
Vladimir Jigulin | 6a1ef81 | 2019-03-21 19:34:07 +0400 | [diff] [blame] | 5 | def is_released_version(version) { |
| 6 | return Character.isDigit(version.charAt(0)) |
| 7 | } |
| 8 | |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 9 | def verbose_sh(String script, Boolean returnStatus=false, Boolean returnStdout=false, Boolean verboseStdout=false) { |
| 10 | def common = new com.mirantis.mk.Common() |
| 11 | common.printMsg("Run shell command:\n" + script, "blue") |
| 12 | def result = sh(script: script, returnStatus: returnStatus, returnStdout: returnStdout) |
| 13 | if (verboseStdout) { |
| 14 | common.printMsg("Output:\n" + result, "cyan") |
| 15 | } |
| 16 | return result |
| 17 | } |
| 18 | |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 19 | def run_sh(String cmd) { |
| 20 | // run shell script without catching any output |
| 21 | def common = new com.mirantis.mk.Common() |
| 22 | common.printMsg("Run shell command:\n" + cmd, "blue") |
| 23 | def VENV_PATH='/home/jenkins/fuel-devops30' |
Dmitry Tyzhnenko | b39de05 | 2019-03-21 17:05:07 +0200 | [diff] [blame] | 24 | def script = """\ |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 25 | set -ex; |
| 26 | . ${VENV_PATH}/bin/activate; |
| 27 | bash -c '${cmd.stripIndent()}' |
| 28 | """ |
| 29 | return sh(script: script) |
| 30 | } |
| 31 | |
Dennis Dmitriev | 8df3544 | 2018-07-31 08:40:20 +0300 | [diff] [blame] | 32 | def run_cmd(String cmd, Boolean returnStdout=false) { |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 33 | def common = new com.mirantis.mk.Common() |
| 34 | common.printMsg("Run shell command:\n" + cmd, "blue") |
| 35 | def VENV_PATH='/home/jenkins/fuel-devops30' |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 36 | def stderr_path = "/tmp/${JOB_NAME}_${BUILD_NUMBER}_stderr.log" |
Dmitry Tyzhnenko | b39de05 | 2019-03-21 17:05:07 +0200 | [diff] [blame] | 37 | def script = """#!/bin/bash |
| 38 | set +x |
| 39 | echo 'activate python virtualenv ${VENV_PATH}' |
| 40 | . ${VENV_PATH}/bin/activate |
| 41 | bash -c -e -x '${cmd.stripIndent()}' 2>${stderr_path} |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 42 | """ |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 43 | try { |
Dmitry Tyzhnenko | b39de05 | 2019-03-21 17:05:07 +0200 | [diff] [blame] | 44 | def stdout = sh(script: script, returnStdout: returnStdout) |
| 45 | def stderr = readFile("${stderr_path}") |
| 46 | def error_message = "\n<<<<<< STDERR: >>>>>>\n" + stderr |
| 47 | common.printMsg(error_message, "yellow") |
| 48 | common.printMsg("", "reset") |
| 49 | return stdout |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 50 | } catch (e) { |
Dennis Dmitriev | 8df3544 | 2018-07-31 08:40:20 +0300 | [diff] [blame] | 51 | def stderr = readFile("${stderr_path}") |
| 52 | def error_message = e.message + "\n<<<<<< STDERR: >>>>>>\n" + stderr |
Dmitry Tyzhnenko | b39de05 | 2019-03-21 17:05:07 +0200 | [diff] [blame] | 53 | common.printMsg(error_message, "red") |
| 54 | common.printMsg("", "reset") |
Dennis Dmitriev | 8df3544 | 2018-07-31 08:40:20 +0300 | [diff] [blame] | 55 | throw new Exception(error_message) |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 56 | } finally { |
Dennis Dmitriev | 8df3544 | 2018-07-31 08:40:20 +0300 | [diff] [blame] | 57 | sh(script: "rm ${stderr_path} || true") |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 58 | } |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | def run_cmd_stdout(cmd) { |
Dennis Dmitriev | 8df3544 | 2018-07-31 08:40:20 +0300 | [diff] [blame] | 62 | return run_cmd(cmd, true) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 63 | } |
| 64 | |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 65 | def build_pipeline_job(job_name, parameters) { |
| 66 | //Build a job, grab the results if failed and use the results in exception |
| 67 | def common = new com.mirantis.mk.Common() |
| 68 | common.printMsg("Start building job '${job_name}' with parameters:", "purple") |
| 69 | common.prettyPrint(parameters) |
| 70 | |
| 71 | def job_info = build job: "${job_name}", |
| 72 | parameters: parameters, |
| 73 | propagate: false |
| 74 | |
| 75 | if (job_info.getResult() != "SUCCESS") { |
| 76 | currentBuild.result = job_info.getResult() |
| 77 | def build_number = job_info.getNumber() |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 78 | common.printMsg("Job '${job_name}' failed, getting details", "purple") |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 79 | def workflow_details=run_cmd_stdout("""\ |
| 80 | export JOB_NAME=${job_name} |
| 81 | export BUILD_NUMBER=${build_number} |
| 82 | python ./tcp_tests/utils/get_jenkins_job_stages.py |
| 83 | """) |
| 84 | throw new Exception(workflow_details) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | def build_shell_job(job_name, parameters, junit_report_filename=null, junit_report_source_dir='**/') { |
| 89 | //Build a job, grab the results if failed and use the results in exception |
| 90 | //junit_report_filename: if not null, try to copy this JUnit report first from remote job |
| 91 | def common = new com.mirantis.mk.Common() |
| 92 | common.printMsg("Start building job '${job_name}' with parameters:", "purple") |
| 93 | common.prettyPrint(parameters) |
| 94 | |
| 95 | def job_info = build job: "${job_name}", |
| 96 | parameters: parameters, |
| 97 | propagate: false |
| 98 | |
Dennis Dmitriev | 4115ae7 | 2018-11-20 13:43:35 +0200 | [diff] [blame] | 99 | def build_number = job_info.getNumber() |
| 100 | def build_url = job_info.getAbsoluteUrl() |
| 101 | def build_status = job_info.getResult() |
| 102 | try { |
| 103 | // Try to grab 'tar.gz' articacts from the shell job' |
| 104 | step($class: 'hudson.plugins.copyartifact.CopyArtifact', |
| 105 | projectName: job_name, |
| 106 | selector: specific("${build_number}"), |
| 107 | filter: "**/*.tar.gz", |
| 108 | target: '.', |
| 109 | flatten: true, |
| 110 | fingerprintArtifacts: true) |
| 111 | } catch (none) { |
| 112 | common.printMsg("No *.tar.gz files found in artifacts of the build ${build_url}", "purple") |
| 113 | } |
| 114 | |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 115 | if (job_info.getResult() != "SUCCESS") { |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 116 | def job_url = "${build_url}" |
| 117 | currentBuild.result = build_status |
| 118 | if (junit_report_filename) { |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 119 | common.printMsg("Job '${job_url}' failed with status ${build_status}, getting details", "purple") |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 120 | step($class: 'hudson.plugins.copyartifact.CopyArtifact', |
| 121 | projectName: job_name, |
| 122 | selector: specific("${build_number}"), |
| 123 | filter: "${junit_report_source_dir}/${junit_report_filename}", |
| 124 | target: '.', |
| 125 | flatten: true, |
| 126 | fingerprintArtifacts: true) |
| 127 | |
| 128 | def String junit_report_xml = readFile("${junit_report_filename}") |
| 129 | def String junit_report_xml_pretty = new XmlUtil().serialize(junit_report_xml) |
| 130 | def String msg = "Job '${job_url}' failed with status ${build_status}, JUnit report:\n" |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 131 | throw new Exception(msg + junit_report_xml_pretty) |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 132 | } else { |
| 133 | throw new Exception("Job '${job_url}' failed with status ${build_status}, please check the console output.") |
| 134 | } |
| 135 | } |
| 136 | } |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 137 | |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 138 | def prepare_working_dir(env_manager) { |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 139 | println "Clean the working directory ${env.WORKSPACE}" |
| 140 | deleteDir() |
| 141 | |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 142 | if (env_manager == 'devops') { |
| 143 | // do not fail if environment doesn't exists |
| 144 | println "Remove fuel-devops environment '${ENV_NAME}'" |
| 145 | run_cmd("""\ |
| 146 | dos.py erase ${ENV_NAME} || true |
| 147 | """) |
| 148 | } else if (env_manager == 'heat') { |
| 149 | // delete heat stack |
| 150 | println "Remove heat stack '${ENV_NAME}'" |
| 151 | withCredentials([ |
| 152 | [$class : 'UsernamePasswordMultiBinding', |
| 153 | credentialsId : env.OS_CREDENTIALS, |
| 154 | passwordVariable: 'OS_PASSWORD', |
| 155 | usernameVariable: 'OS_USERNAME'] |
| 156 | ]) { |
| 157 | run_cmd("""\ |
| 158 | export OS_IDENTITY_API_VERSION=3 |
| 159 | export OS_AUTH_URL=${OS_AUTH_URL} |
| 160 | export OS_USERNAME=${OS_USERNAME} |
| 161 | export OS_PASSWORD=${OS_PASSWORD} |
| 162 | export OS_PROJECT_NAME=${OS_PROJECT_NAME} |
| 163 | export OS_USER_DOMAIN_NAME=${OS_USER_DOMAIN_NAME} |
| 164 | openstack --insecure stack delete -y ${ENV_NAME} || true |
Hanna Arhipova | 8b45a71 | 2020-05-25 14:21:58 +0300 | [diff] [blame] | 165 | timeout 20m /bin/bash -c "while openstack --insecure stack show ${ENV_NAME} -f value -c stack_status; do sleep 10; done" |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 166 | """) |
| 167 | } |
| 168 | |
| 169 | } else { |
| 170 | throw new Exception("Unknown env_manager: '${env_manager}'") |
| 171 | } |
| 172 | |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 173 | println "Remove config drive ISO" |
| 174 | run_cmd("""\ |
| 175 | rm /home/jenkins/images/${CFG01_CONFIG_IMAGE_NAME} || true |
| 176 | """) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 177 | |
| 178 | run_cmd("""\ |
Hanna Arhipova | 5173aad | 2019-11-11 12:42:31 +0200 | [diff] [blame] | 179 | git clone https://gerrit.mcp.mirantis.com/mcp/tcp-qa ${env.WORKSPACE} |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 180 | if [ -n "$TCP_QA_REFS" ]; then |
| 181 | set -e |
Hanna Arhipova | 5173aad | 2019-11-11 12:42:31 +0200 | [diff] [blame] | 182 | git fetch https://gerrit.mcp.mirantis.com/mcp/tcp-qa $TCP_QA_REFS && git checkout FETCH_HEAD || exit \$? |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 183 | fi |
| 184 | pip install --upgrade --upgrade-strategy=only-if-needed -r tcp_tests/requirements.txt |
Dennis Dmitriev | 8df3544 | 2018-07-31 08:40:20 +0300 | [diff] [blame] | 185 | """) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 186 | } |
| 187 | |
Dennis Dmitriev | 056ecbf | 2019-05-20 15:36:29 +0300 | [diff] [blame] | 188 | def update_working_dir(Boolean updateRequirements=true) { |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 189 | // Use to fetch a patchset from gerrit to the working dir |
| 190 | run_cmd("""\ |
| 191 | if [ -n "$TCP_QA_REFS" ]; then |
| 192 | set -e |
Hanna Arhipova | 5173aad | 2019-11-11 12:42:31 +0200 | [diff] [blame] | 193 | git reset --hard && git fetch https://gerrit.mcp.mirantis.com/mcp/tcp-qa $TCP_QA_REFS && git checkout FETCH_HEAD || exit \$? |
Dennis Dmitriev | 056ecbf | 2019-05-20 15:36:29 +0300 | [diff] [blame] | 194 | fi""") |
| 195 | if (updateRequirements) { |
| 196 | run_cmd("""\ |
| 197 | pip install -r tcp_tests/requirements.txt |
| 198 | """) |
| 199 | } |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 200 | } |
| 201 | |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 202 | def swarm_bootstrap_salt_cluster_devops() { |
| 203 | def common = new com.mirantis.mk.Common() |
Hanna Arhipova | c2965a4 | 2020-01-21 12:27:33 +0200 | [diff] [blame] | 204 | def cookiecutter_template_commit = env.COOKIECUTTER_TEMPLATE_COMMIT ?: is_released_version(env.MCP_VERSION) ? "refs/tags/${env.MCP_VERSION}" : 'master' |
| 205 | def salt_models_system_commit = env.SALT_MODELS_SYSTEM_COMMIT ?: "refs/tags/${env.MCP_VERSION}" |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 206 | def jenkins_pipelines_branch = env.JENKINS_PIPELINE_BRANCH ?: '' |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 207 | def tcp_qa_refs = env.TCP_QA_REFS ?: '' |
| 208 | def mk_pipelines_ref = env.MK_PIPELINES_REF ?: '' |
| 209 | def pipeline_library_ref = env.PIPELINE_LIBRARY_REF ?: '' |
| 210 | def cookiecutter_ref_change = env.COOKIECUTTER_REF_CHANGE ?: '' |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 211 | def mcp_common_scripts_refs = env.MCP_COMMON_SCRIPTS_REFS ?: '' |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 212 | def environment_template_ref_change = env.ENVIRONMENT_TEMPLATE_REF_CHANGE ?: '' |
Dennis Dmitriev | d9168b5 | 2018-12-19 18:53:52 +0200 | [diff] [blame] | 213 | def mcp_salt_repo_url = env.MCP_SALT_REPO_URL ?: '' |
| 214 | def mcp_salt_repo_key = env.MCP_SALT_REPO_KEY ?: '' |
Tatyana Leontovich | 1f06916 | 2019-04-02 19:57:55 +0300 | [diff] [blame] | 215 | def deploy_network_mask = env.DEPLOY_NETWORK_NETMASK ?: '' |
Dennis Dmitriev | 6346004 | 2018-12-11 13:08:11 +0200 | [diff] [blame] | 216 | def env_ipmi_user = env.IPMI_USER ?: '' |
| 217 | def env_ipmi_pass = env.IPMI_PASS ?: '' |
Oleksii Butenko | ab538de | 2019-09-23 18:26:57 +0300 | [diff] [blame] | 218 | def env_cisco_pass = env.CISCO_PASS ?: '' |
Dennis Dmitriev | 6346004 | 2018-12-11 13:08:11 +0200 | [diff] [blame] | 219 | def env_lab_mgm_iface = env.LAB_MANAGEMENT_IFACE ?: '' |
| 220 | def env_lab_ctl_iface = env.LAB_CONTROL_IFACE ?: '' |
sgudz | b795338 | 2019-02-18 17:59:30 +0200 | [diff] [blame] | 221 | def update_repo_custom_tag = env.UPDATE_REPO_CUSTOM_TAG ?: '' |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 222 | def update_version = env.UPDATE_VERSION ?: '' |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 223 | def updates_mirantis_version = env.UPDATES_MIRANTIS_VERSION ?: '' |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 224 | def parameters = [ |
| 225 | string(name: 'PARENT_NODE_NAME', value: "${NODE_NAME}"), |
| 226 | string(name: 'PARENT_WORKSPACE', value: pwd()), |
| 227 | string(name: 'LAB_CONFIG_NAME', value: "${LAB_CONFIG_NAME}"), |
| 228 | string(name: 'ENV_NAME', value: "${ENV_NAME}"), |
| 229 | string(name: 'MCP_VERSION', value: "${MCP_VERSION}"), |
| 230 | string(name: 'MCP_IMAGE_PATH1604', value: "${MCP_IMAGE_PATH1604}"), |
| 231 | string(name: 'IMAGE_PATH_CFG01_DAY01', value: "${IMAGE_PATH_CFG01_DAY01}"), |
| 232 | string(name: 'CFG01_CONFIG_IMAGE_NAME', value: "${CFG01_CONFIG_IMAGE_NAME}"), |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 233 | string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"), |
| 234 | string(name: 'PIPELINE_LIBRARY_REF', value: "${pipeline_library_ref}"), |
| 235 | string(name: 'MK_PIPELINES_REF', value: "${mk_pipelines_ref}"), |
| 236 | string(name: 'COOKIECUTTER_TEMPLATE_COMMIT', value: "${cookiecutter_template_commit}"), |
| 237 | string(name: 'SALT_MODELS_SYSTEM_COMMIT', value: "${salt_models_system_commit}"), |
| 238 | string(name: 'COOKIECUTTER_REF_CHANGE', value: "${cookiecutter_ref_change}"), |
| 239 | string(name: 'ENVIRONMENT_TEMPLATE_REF_CHANGE', value: "${environment_template_ref_change}"), |
Dennis Dmitriev | d9168b5 | 2018-12-19 18:53:52 +0200 | [diff] [blame] | 240 | string(name: 'MCP_SALT_REPO_URL', value: "${mcp_salt_repo_url}"), |
| 241 | string(name: 'MCP_SALT_REPO_KEY', value: "${mcp_salt_repo_key}"), |
Tatyana Leontovich | 1f06916 | 2019-04-02 19:57:55 +0300 | [diff] [blame] | 242 | string(name: 'DEPLOY_NETWORK_NETMASK', value: "${deploy_network_mask}"), |
Dennis Dmitriev | 6346004 | 2018-12-11 13:08:11 +0200 | [diff] [blame] | 243 | string(name: 'IPMI_USER', value: env_ipmi_user), |
| 244 | string(name: 'IPMI_PASS', value: env_ipmi_pass), |
Oleksii Butenko | ab538de | 2019-09-23 18:26:57 +0300 | [diff] [blame] | 245 | string(name: 'CISCO_PASS', value: env_cisco_pass), |
Dennis Dmitriev | 6346004 | 2018-12-11 13:08:11 +0200 | [diff] [blame] | 246 | string(name: 'LAB_MANAGEMENT_IFACE', value: env_lab_mgm_iface), |
| 247 | string(name: 'LAB_CONTROL_IFACE', value: env_lab_ctl_iface), |
sgudz | b795338 | 2019-02-18 17:59:30 +0200 | [diff] [blame] | 248 | string(name: 'UPDATE_REPO_CUSTOM_TAG', value: "${update_repo_custom_tag}"), |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 249 | string(name: 'JENKINS_PIPELINE_BRANCH', value: "${jenkins_pipelines_branch}"), |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 250 | string(name: 'MCP_COMMON_SCRIPTS_REFS', value: "${mcp_common_scripts_refs}"), |
| 251 | string(name: 'UPDATE_VERSION', value: "${update_version}"), |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 252 | string(name: 'UPDATES_MIRANTIS_VERSION', value: "${updates_mirantis_version}"), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 253 | booleanParam(name: 'SHUTDOWN_ENV_ON_TEARDOWN', value: false), |
| 254 | ] |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 255 | |
| 256 | build_pipeline_job('swarm-bootstrap-salt-cluster-devops', parameters) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 257 | } |
| 258 | |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 259 | def swarm_bootstrap_salt_cluster_heat(String jenkins_slave_node_name) { |
| 260 | // jenkins_slave_node_name |
| 261 | def common = new com.mirantis.mk.Common() |
Hanna Arhipova | c2965a4 | 2020-01-21 12:27:33 +0200 | [diff] [blame] | 262 | def cookiecutter_template_commit = env.COOKIECUTTER_TEMPLATE_COMMIT ?: "refs/tags/${env.MCP_VERSION}" |
| 263 | def salt_models_system_commit = env.SALT_MODELS_SYSTEM_COMMIT ?: "refs/tags/${env.MCP_VERSION}" |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 264 | def mcp_common_scripts_refs = env.MCP_COMMON_SCRIPTS_REFS ?: '' |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 265 | def tcp_qa_refs = env.TCP_QA_REFS ?: '' |
| 266 | def mk_pipelines_ref = env.MK_PIPELINES_REF ?: '' |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 267 | def jenkins_pipelines_branch = env.JENKINS_PIPELINE_BRANCH ?: '' |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 268 | def pipeline_library_ref = env.PIPELINE_LIBRARY_REF ?: '' |
| 269 | def cookiecutter_ref_change = env.COOKIECUTTER_REF_CHANGE ?: '' |
| 270 | def environment_template_ref_change = env.ENVIRONMENT_TEMPLATE_REF_CHANGE ?: '' |
| 271 | def mcp_salt_repo_url = env.MCP_SALT_REPO_URL ?: '' |
| 272 | def mcp_salt_repo_key = env.MCP_SALT_REPO_KEY ?: '' |
| 273 | def env_ipmi_user = env.IPMI_USER ?: '' |
| 274 | def env_ipmi_pass = env.IPMI_PASS ?: '' |
Oleksii Butenko | ab538de | 2019-09-23 18:26:57 +0300 | [diff] [blame] | 275 | def env_cisco_pass = env.CISCO_PASS ?: '' |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 276 | def env_lab_mgm_iface = env.LAB_MANAGEMENT_IFACE ?: '' |
| 277 | def env_lab_ctl_iface = env.LAB_CONTROL_IFACE ?: '' |
| 278 | def update_repo_custom_tag = env.UPDATE_REPO_CUSTOM_TAG ?: '' |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 279 | def update_version = env.UPDATE_VERSION ?: '' |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 280 | def updates_mirantis_version = env.UPDATES_MIRANTIS_VERSION ?: '' |
Hanna Arhipova | 258094b | 2021-02-11 14:49:52 +0200 | [diff] [blame] | 281 | def deploy_empty_node = env.DEPLOY_EMPTY_NODE ?: false |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 282 | def parameters = [ |
| 283 | string(name: 'PARENT_NODE_NAME', value: "${NODE_NAME}"), |
| 284 | string(name: 'JENKINS_SLAVE_NODE_NAME', value: jenkins_slave_node_name), |
| 285 | string(name: 'PARENT_WORKSPACE', value: pwd()), |
| 286 | string(name: 'LAB_CONFIG_NAME', value: "${LAB_CONFIG_NAME}"), |
| 287 | string(name: 'ENV_NAME', value: "${ENV_NAME}"), |
| 288 | string(name: 'MCP_VERSION', value: "${MCP_VERSION}"), |
| 289 | string(name: 'MCP_IMAGE_PATH1604', value: "${MCP_IMAGE_PATH1604}"), |
| 290 | string(name: 'IMAGE_PATH_CFG01_DAY01', value: "${IMAGE_PATH_CFG01_DAY01}"), |
| 291 | string(name: 'CFG01_CONFIG_IMAGE_NAME', value: "${CFG01_CONFIG_IMAGE_NAME}"), |
| 292 | string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"), |
| 293 | string(name: 'PIPELINE_LIBRARY_REF', value: "${pipeline_library_ref}"), |
| 294 | string(name: 'MK_PIPELINES_REF', value: "${mk_pipelines_ref}"), |
Hanna Arhipova | 6fc7ec9 | 2021-09-22 20:34:52 +0300 | [diff] [blame] | 295 | string(name: 'SALT_MODELS_SYSTEM_REF_CHANGE', value: env.SALT_MODELS_SYSTEM_REF_CHANGE ?: ''), |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 296 | string(name: 'COOKIECUTTER_TEMPLATE_COMMIT', value: "${cookiecutter_template_commit}"), |
| 297 | string(name: 'SALT_MODELS_SYSTEM_COMMIT', value: "${salt_models_system_commit}"), |
| 298 | string(name: 'COOKIECUTTER_REF_CHANGE', value: "${cookiecutter_ref_change}"), |
| 299 | string(name: 'ENVIRONMENT_TEMPLATE_REF_CHANGE', value: "${environment_template_ref_change}"), |
| 300 | string(name: 'MCP_SALT_REPO_URL', value: "${mcp_salt_repo_url}"), |
| 301 | string(name: 'MCP_SALT_REPO_KEY', value: "${mcp_salt_repo_key}"), |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 302 | string(name: 'MCP_COMMON_SCRIPTS_REFS', value: "${mcp_common_scripts_refs}"), |
| 303 | string(name: 'UPDATE_VERSION', value: "${update_version}"), |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 304 | string(name: 'UPDATES_MIRANTIS_VERSION', value: "${updates_mirantis_version}"), |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 305 | string(name: 'IPMI_USER', value: env_ipmi_user), |
| 306 | string(name: 'IPMI_PASS', value: env_ipmi_pass), |
Oleksii Butenko | ab538de | 2019-09-23 18:26:57 +0300 | [diff] [blame] | 307 | string(name: 'CISCO_PASS', value: env_cisco_pass), |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 308 | string(name: 'LAB_MANAGEMENT_IFACE', value: env_lab_mgm_iface), |
| 309 | string(name: 'LAB_CONTROL_IFACE', value: env_lab_ctl_iface), |
| 310 | string(name: 'UPDATE_REPO_CUSTOM_TAG', value: "${update_repo_custom_tag}"), |
| 311 | string(name: 'OS_AUTH_URL', value: "${OS_AUTH_URL}"), |
| 312 | string(name: 'OS_PROJECT_NAME', value: "${OS_PROJECT_NAME}"), |
| 313 | string(name: 'OS_USER_DOMAIN_NAME', value: "${OS_USER_DOMAIN_NAME}"), |
| 314 | string(name: 'OS_CREDENTIALS', value: "${OS_CREDENTIALS}"), |
| 315 | string(name: 'LAB_PARAM_DEFAULTS', value: "${LAB_PARAM_DEFAULTS}"), |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 316 | string(name: 'JENKINS_PIPELINE_BRANCH', value: "${jenkins_pipelines_branch}"), |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 317 | booleanParam(name: 'SHUTDOWN_ENV_ON_TEARDOWN', value: false), |
Hanna Arhipova | 258094b | 2021-02-11 14:49:52 +0200 | [diff] [blame] | 318 | booleanParam(name: 'DEPLOY_EMPTY_NODE', value: deploy_empty_node), |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 319 | ] |
| 320 | |
Pavel Glazov | f82cd53 | 2022-10-19 21:36:13 +0400 | [diff] [blame] | 321 | build_pipeline_job('swarm-bootstrap-salt-cluster-heat-jjb', parameters) |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 322 | } |
| 323 | |
PGlazov | ed19b35 | 2020-05-21 16:42:27 +0400 | [diff] [blame] | 324 | def swarm_deploy_cicd(String stack_to_install, String install_timeout, String jenkins_slave_node_name, Boolean make_snapshot_stages, String batch_size, Boolean dist_upgrade_nodes, Boolean upgrade_saltstack) { |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 325 | // Run openstack_deploy job on cfg01 Jenkins for specified stacks |
| 326 | def common = new com.mirantis.mk.Common() |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 327 | def tcp_qa_refs = env.TCP_QA_REFS ?: '' |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 328 | def parameters = [ |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 329 | string(name: 'PARENT_NODE_NAME', value: jenkins_slave_node_name), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 330 | string(name: 'PARENT_WORKSPACE', value: pwd()), |
| 331 | string(name: 'ENV_NAME', value: "${ENV_NAME}"), |
| 332 | string(name: 'STACK_INSTALL', value: stack_to_install), |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 333 | string(name: 'STACK_INSTALL_TIMEOUT', value: install_timeout), |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 334 | string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"), |
Hanna Arhipova | 6f49352 | 2019-12-25 04:23:28 +0200 | [diff] [blame] | 335 | string(name: 'BATCH_SIZE', value: batch_size), |
Dmitriy Kruglov | 758f99c | 2020-02-04 12:04:31 +0100 | [diff] [blame] | 336 | booleanParam(name: 'DIST_UPGRADE_NODES', value: dist_upgrade_nodes), |
PGlazov | ed19b35 | 2020-05-21 16:42:27 +0400 | [diff] [blame] | 337 | booleanParam(name: 'UPGRADE_SALTSTACK', value: upgrade_saltstack), |
Dennis Dmitriev | 0244741 | 2019-04-17 18:02:46 +0300 | [diff] [blame] | 338 | booleanParam(name: 'MAKE_SNAPSHOT_STAGES', value: make_snapshot_stages), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 339 | booleanParam(name: 'SHUTDOWN_ENV_ON_TEARDOWN', value: false), |
| 340 | ] |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 341 | build_pipeline_job('swarm-deploy-cicd', parameters) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 342 | } |
| 343 | |
Hanna Arhipova | ddd35a2 | 2020-05-27 12:39:26 +0300 | [diff] [blame] | 344 | def swarm_deploy_platform(String stack_to_install, String install_timeout, String jenkins_slave_node_name, Boolean make_snapshot_stages, String batch_size, Boolean dist_upgrade_nodes, Boolean upgrade_saltstack) { |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 345 | // Run openstack_deploy job on CICD Jenkins for specified stacks |
| 346 | def common = new com.mirantis.mk.Common() |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 347 | def tcp_qa_refs = env.TCP_QA_REFS ?: '' |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 348 | def parameters = [ |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 349 | string(name: 'PARENT_NODE_NAME', value: jenkins_slave_node_name), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 350 | string(name: 'PARENT_WORKSPACE', value: pwd()), |
| 351 | string(name: 'ENV_NAME', value: "${ENV_NAME}"), |
| 352 | string(name: 'STACK_INSTALL', value: stack_to_install), |
Dennis Dmitriev | 07d5b8a | 2018-10-29 19:43:00 +0200 | [diff] [blame] | 353 | string(name: 'STACK_INSTALL_TIMEOUT', value: install_timeout), |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 354 | string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"), |
Hanna Arhipova | 6f49352 | 2019-12-25 04:23:28 +0200 | [diff] [blame] | 355 | string(name: 'BATCH_SIZE', value: batch_size), |
Dmitriy Kruglov | 758f99c | 2020-02-04 12:04:31 +0100 | [diff] [blame] | 356 | booleanParam(name: 'DIST_UPGRADE_NODES', value: dist_upgrade_nodes), |
PGlazov | ed19b35 | 2020-05-21 16:42:27 +0400 | [diff] [blame] | 357 | booleanParam(name: 'UPGRADE_SALTSTACK', value: upgrade_saltstack), |
Dennis Dmitriev | 0244741 | 2019-04-17 18:02:46 +0300 | [diff] [blame] | 358 | booleanParam(name: 'MAKE_SNAPSHOT_STAGES', value: make_snapshot_stages), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 359 | booleanParam(name: 'SHUTDOWN_ENV_ON_TEARDOWN', value: false), |
| 360 | ] |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 361 | build_pipeline_job('swarm-deploy-platform', parameters) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 362 | } |
| 363 | |
sgudz | 2ed9585 | 2019-03-01 14:48:52 +0200 | [diff] [blame] | 364 | def swarm_deploy_platform_non_cicd(String stack_to_install, String install_timeout) { |
| 365 | // Run openstack_deploy job on day01 Jenkins for specified stacks |
| 366 | def common = new com.mirantis.mk.Common() |
| 367 | def tcp_qa_refs = env.TCP_QA_REFS ?: '' |
| 368 | def parameters = [ |
| 369 | string(name: 'PARENT_NODE_NAME', value: "${NODE_NAME}"), |
| 370 | string(name: 'PARENT_WORKSPACE', value: pwd()), |
| 371 | string(name: 'ENV_NAME', value: "${ENV_NAME}"), |
| 372 | string(name: 'STACK_INSTALL', value: stack_to_install), |
| 373 | string(name: 'STACK_INSTALL_TIMEOUT', value: install_timeout), |
| 374 | string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"), |
| 375 | booleanParam(name: 'SHUTDOWN_ENV_ON_TEARDOWN', value: false), |
| 376 | ] |
| 377 | build_pipeline_job('swarm-deploy-platform-without-cicd', parameters) |
| 378 | } |
| 379 | |
Dennis Dmitriev | 0244741 | 2019-04-17 18:02:46 +0300 | [diff] [blame] | 380 | def swarm_run_pytest(String passed_steps, String jenkins_slave_node_name, Boolean make_snapshot_stages) { |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 381 | // Run pytest tests |
| 382 | def common = new com.mirantis.mk.Common() |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 383 | def tcp_qa_refs = env.TCP_QA_REFS ?: '' |
Oleksii Butenko | ec78c9f | 2019-04-04 16:26:20 +0300 | [diff] [blame] | 384 | def tempest_extra_args = env.TEMPEST_EXTRA_ARGS ?: '' |
Tatyana Leontovich | 05f7940 | 2018-11-16 15:04:02 +0200 | [diff] [blame] | 385 | def tempest_image_version = env.TEMPEST_IMAGE_VERSION ?: 'pike' |
Tatyana Leontovich | bfbc483 | 2018-12-27 12:47:23 +0200 | [diff] [blame] | 386 | def tempest_target=env.TEMPEST_TARGET ?: 'gtw01' |
Andrew Baraniuk | d158634 | 2019-06-12 11:41:20 +0300 | [diff] [blame] | 387 | def tempest_pattern=env.TEMPEST_PATTERN ?: 'tempest' |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 388 | def parameters = [ |
| 389 | string(name: 'ENV_NAME', value: "${ENV_NAME}"), |
Anna Arhipova | 37739ee | 2022-08-10 11:46:45 +0200 | [diff] [blame] | 390 | string(name: 'LAB_CONFIG_NAME', value: "${LAB_CONFIG_NAME}"), |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 391 | string(name: 'PASSED_STEPS', value: passed_steps), |
Hanna Arhipova | 798759d | 2020-02-19 14:07:50 +0200 | [diff] [blame] | 392 | text(name: 'RUN_TEST_OPTS', value: "${RUN_TEST_OPTS}"), |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 393 | string(name: 'PARENT_NODE_NAME', value: jenkins_slave_node_name), |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 394 | string(name: 'PARENT_WORKSPACE', value: pwd()), |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 395 | string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"), |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 396 | booleanParam(name: 'SHUTDOWN_ENV_ON_TEARDOWN', value: false), |
Tatyana Leontovich | 05f7940 | 2018-11-16 15:04:02 +0200 | [diff] [blame] | 397 | string(name: 'TEMPEST_IMAGE_VERSION', value: "${tempest_image_version}"), |
Tatyana Leontovich | bfbc483 | 2018-12-27 12:47:23 +0200 | [diff] [blame] | 398 | string(name: 'TEMPEST_TARGET', value: "${tempest_target}"), |
Hanna Arhipova | c887544 | 2020-07-10 13:22:59 +0300 | [diff] [blame] | 399 | string(name: 'TEMPEST_PATTERN', value: "${tempest_pattern}"), |
| 400 | string(name: 'TEMPEST_EXTRA_ARGS', value: "${tempest_extra_args}"), |
Dennis Dmitriev | 0244741 | 2019-04-17 18:02:46 +0300 | [diff] [blame] | 401 | booleanParam(name: 'MAKE_SNAPSHOT_STAGES', value: make_snapshot_stages), |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 402 | ] |
| 403 | common.printMsg("Start building job 'swarm-run-pytest' with parameters:", "purple") |
| 404 | common.prettyPrint(parameters) |
dtsapikov | 269f519 | 2021-08-12 13:35:43 +0400 | [diff] [blame] | 405 | swarm_run_pytest_build = build(job: 'swarm-run-pytest', parameters: parameters) |
| 406 | copyArtifacts(projectName: 'swarm-run-pytest', selector: specific(swarm_run_pytest_build.getId())) |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 407 | } |
| 408 | |
Tatyana Leontovich | c18c814 | 2019-05-16 15:20:33 +0300 | [diff] [blame] | 409 | def swarm_testrail_report(String passed_steps, String node_with_reports) { |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 410 | // Run pytest tests |
| 411 | def common = new com.mirantis.mk.Common() |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 412 | def tcp_qa_refs = env.TCP_QA_REFS ?: '' |
Tatyana Leontovich | f371844 | 2018-10-31 13:36:13 +0200 | [diff] [blame] | 413 | def tempest_test_suite_name = env.TEMPEST_TEST_SUITE_NAME |
Vladimir Jigulin | 91bb7c9 | 2019-04-04 18:15:45 +0400 | [diff] [blame] | 414 | def test_plan_name_prefix = env.TEST_PLAN_NAME_PREFIX ?: '' |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 415 | def parameters = [ |
| 416 | string(name: 'ENV_NAME', value: "${ENV_NAME}"), |
Tatyana Leontovich | bfbc483 | 2018-12-27 12:47:23 +0200 | [diff] [blame] | 417 | string(name: 'LAB_CONFIG_NAME', value: "${LAB_CONFIG_NAME}"), |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 418 | string(name: 'MCP_VERSION', value: "${MCP_VERSION}"), |
| 419 | string(name: 'PASSED_STEPS', value: passed_steps), |
Tatyana Leontovich | c18c814 | 2019-05-16 15:20:33 +0300 | [diff] [blame] | 420 | string(name: 'PARENT_NODE_NAME', value: node_with_reports), |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 421 | string(name: 'PARENT_WORKSPACE', value: pwd()), |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 422 | string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"), |
Tatyana Leontovich | f371844 | 2018-10-31 13:36:13 +0200 | [diff] [blame] | 423 | string(name: 'TEMPEST_TEST_SUITE_NAME', value: "${tempest_test_suite_name}"), |
Hanna Arhipova | 705a289 | 2020-09-25 12:40:39 +0300 | [diff] [blame] | 424 | string(name: 'TEST_PLAN_NAME_PREFIX', value: "${test_plan_name_prefix}") |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 425 | ] |
Pavel Glazov | d7f47c0 | 2022-10-12 14:46:42 +0400 | [diff] [blame] | 426 | common.printMsg("Start building job 'swarm-testrail-report-jjb' with parameters:", "purple") |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 427 | common.prettyPrint(parameters) |
Pavel Glazov | d7f47c0 | 2022-10-12 14:46:42 +0400 | [diff] [blame] | 428 | build job: 'swarm-testrail-report-jjb', |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 429 | parameters: parameters |
| 430 | } |
| 431 | |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 432 | def generate_cookied_model(IPV4_NET_ADMIN, IPV4_NET_CONTROL, IPV4_NET_TENANT, IPV4_NET_EXTERNAL) { |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 433 | def common = new com.mirantis.mk.Common() |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 434 | println("IPV4_NET_ADMIN=" + IPV4_NET_ADMIN) |
| 435 | println("IPV4_NET_CONTROL=" + IPV4_NET_CONTROL) |
| 436 | println("IPV4_NET_TENANT=" + IPV4_NET_TENANT) |
| 437 | println("IPV4_NET_EXTERNAL=" + IPV4_NET_EXTERNAL) |
| 438 | |
Hanna Arhipova | c2965a4 | 2020-01-21 12:27:33 +0200 | [diff] [blame] | 439 | def cookiecuttertemplate_commit = env.COOKIECUTTER_TEMPLATE_COMMIT ?: is_released_version(env.MCP_VERSION) ? "refs/tags/${env.MCP_VERSION}" : 'master' |
| 440 | def saltmodels_system_commit = env.SALT_MODELS_SYSTEM_COMMIT ?: "refs/tags/${env.MCP_VERSION}" |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 441 | def tcp_qa_refs = env.TCP_QA_REFS ?: '' |
| 442 | def environment_template_ref_change = env.ENVIRONMENT_TEMPLATE_REF_CHANGE ?: '' |
| 443 | def cookiecutter_ref_change = env.COOKIECUTTER_REF_CHANGE ?: '' |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 444 | def jenkins_pipelines_branch=env.JENKINS_PIPELINE_BRANCH ?: '' |
sgudz | b795338 | 2019-02-18 17:59:30 +0200 | [diff] [blame] | 445 | def update_repo_custom_tag = env.UPDATE_REPO_CUSTOM_TAG ?: '' |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 446 | def update_version = env.UPDATE_VERSION ?: '' |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 447 | def updates_mirantis_version = env.UPDATES_MIRANTIS_VERSION ?: '' |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 448 | |
| 449 | def parameters = [ |
| 450 | string(name: 'LAB_CONTEXT_NAME', value: "${LAB_CONFIG_NAME}"), |
| 451 | string(name: 'CLUSTER_NAME', value: "${LAB_CONFIG_NAME}"), |
| 452 | string(name: 'DOMAIN_NAME', value: "${LAB_CONFIG_NAME}.local"), |
| 453 | string(name: 'REPOSITORY_SUITE', value: "${env.MCP_VERSION}"), |
| 454 | string(name: 'SALT_MODELS_SYSTEM_COMMIT', value: "${saltmodels_system_commit}"), |
Hanna Arhipova | 6fc7ec9 | 2021-09-22 20:34:52 +0300 | [diff] [blame] | 455 | string(name: 'SALT_MODELS_SYSTEM_REF_CHANGE', value: env.SALT_MODELS_SYSTEM_REF_CHANGE ?: ''), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 456 | string(name: 'COOKIECUTTER_TEMPLATE_COMMIT', value: "${cookiecuttertemplate_commit}"), |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 457 | string(name: 'COOKIECUTTER_REF_CHANGE', value: "${cookiecutter_ref_change}"), |
| 458 | string(name: 'ENVIRONMENT_TEMPLATE_REF_CHANGE', value: "${environment_template_ref_change}"), |
Anna Arhipova | d2ced49 | 2022-09-28 10:02:56 +0200 | [diff] [blame] | 459 | string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 460 | string(name: 'IPV4_NET_ADMIN', value: IPV4_NET_ADMIN), |
| 461 | string(name: 'IPV4_NET_CONTROL', value: IPV4_NET_CONTROL), |
| 462 | string(name: 'IPV4_NET_TENANT', value: IPV4_NET_TENANT), |
| 463 | string(name: 'IPV4_NET_EXTERNAL', value: IPV4_NET_EXTERNAL), |
sgudz | c97385a | 2018-11-29 17:01:53 +0200 | [diff] [blame] | 464 | string(name: 'IPMI_USER', value: env.IPMI_USER), |
| 465 | string(name: 'IPMI_PASS', value: env.IPMI_PASS), |
Oleksii Butenko | ab538de | 2019-09-23 18:26:57 +0300 | [diff] [blame] | 466 | string(name: 'CISCO_PASS', value: env.CISCO_PASS), |
sgudz | b795338 | 2019-02-18 17:59:30 +0200 | [diff] [blame] | 467 | string(name: 'UPDATE_REPO_CUSTOM_TAG', value: "${update_repo_custom_tag}"), |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 468 | string(name: 'JENKINS_PIPELINE_BRANCH', value: "${jenkins_pipelines_branch}"), |
sgudz | c97385a | 2018-11-29 17:01:53 +0200 | [diff] [blame] | 469 | string(name: 'IMAGE_PATH_CFG01_DAY01', value: env.IMAGE_PATH_CFG01_DAY01), |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 470 | string(name: 'UPDATE_VERSION', value: "${update_version}"), |
Vladimir Khlyunev | 0ca3ba8 | 2022-10-31 12:12:30 +0400 | [diff] [blame] | 471 | string(name: 'UPDATES_MIRANTIS_VERSION', value: "${updates_mirantis_version}"), |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 472 | |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 473 | ] |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 474 | |
| 475 | build_shell_job('swarm-cookied-model-generator', parameters, "deploy_generate_model.xml") |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 476 | } |
| 477 | |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 478 | def generate_configdrive_iso(SALT_MASTER_IP, ADMIN_NETWORK_GW) { |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 479 | def common = new com.mirantis.mk.Common() |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 480 | println("SALT_MASTER_IP=" + SALT_MASTER_IP) |
Dennis Dmitriev | f220d97 | 2018-10-10 15:19:14 +0300 | [diff] [blame] | 481 | println("ADMIN_NETWORK_GW=" + ADMIN_NETWORK_GW) |
| 482 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 483 | def mk_pipelines_ref = env.MK_PIPELINES_REF ?: '' |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 484 | def mcp_common_scripts_ref = env.MCP_COMMON_SCRIPTS_REFS ?: '' |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 485 | def pipeline_library_ref = env.PIPELINE_LIBRARY_REF ?: '' |
Dennis Dmitriev | f220d97 | 2018-10-10 15:19:14 +0300 | [diff] [blame] | 486 | def tcp_qa_refs = env.TCP_QA_REFS ?: '' |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 487 | def update_version = env.UPDATE_VERSION?: 'proposed' |
Dennis Dmitriev | d9168b5 | 2018-12-19 18:53:52 +0200 | [diff] [blame] | 488 | def mcp_salt_repo_url = env.MCP_SALT_REPO_URL ?: '' |
| 489 | def mcp_salt_repo_key = env.MCP_SALT_REPO_KEY ?: '' |
Tatyana Leontovich | 1f06916 | 2019-04-02 19:57:55 +0300 | [diff] [blame] | 490 | def deploy_network_mask = env.DEPLOY_NETWORK_NETMASK ?: '' |
Vladimir Khlyunev | 5361ad7 | 2023-06-28 00:26:01 +0400 | [diff] [blame] | 491 | def jenkins_host = env.SCRIPT_JENKINS_IP ?: 'sre-ci.scc.mirantis.net' |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 492 | |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 493 | def parameters = [ |
| 494 | string(name: 'CLUSTER_NAME', value: "${LAB_CONFIG_NAME}"), |
Vladimir Khlyunev | 5361ad7 | 2023-06-28 00:26:01 +0400 | [diff] [blame] | 495 | string(name: 'MODEL_URL', value: "http://${jenkins_host}:8098/${LAB_CONFIG_NAME}.git"), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 496 | string(name: 'MODEL_URL_OBJECT_TYPE', value: "git"), |
| 497 | booleanParam(name: 'DOWNLOAD_CONFIG_DRIVE', value: true), |
| 498 | string(name: 'MCP_VERSION', value: "${MCP_VERSION}"), |
Hanna Arhipova | c2965a4 | 2020-01-21 12:27:33 +0200 | [diff] [blame] | 499 | string(name: 'COMMON_SCRIPTS_COMMIT', value: "refs/tags/${env.MCP_VERSION}"), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 500 | string(name: 'NODE_NAME', value: "${NODE_NAME}"), |
| 501 | string(name: 'CONFIG_DRIVE_ISO_NAME', value: "${CFG01_CONFIG_IMAGE_NAME}"), |
| 502 | string(name: 'SALT_MASTER_DEPLOY_IP', value: SALT_MASTER_IP), |
Dennis Dmitriev | f220d97 | 2018-10-10 15:19:14 +0300 | [diff] [blame] | 503 | string(name: 'DEPLOY_NETWORK_GW', value: "${ADMIN_NETWORK_GW}"), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 504 | string(name: 'PIPELINE_REPO_URL', value: "https://github.com/Mirantis"), |
| 505 | booleanParam(name: 'PIPELINES_FROM_ISO', value: true), |
Dennis Dmitriev | d9168b5 | 2018-12-19 18:53:52 +0200 | [diff] [blame] | 506 | string(name: 'MCP_SALT_REPO_URL', value: "${mcp_salt_repo_url}"), |
| 507 | string(name: 'MCP_SALT_REPO_KEY', value: "${mcp_salt_repo_key}"), |
Tatyana Leontovich | 1f06916 | 2019-04-02 19:57:55 +0300 | [diff] [blame] | 508 | string(name: 'DEPLOY_NETWORK_NETMASK', value: "${deploy_network_mask}"), |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 509 | string(name: 'PIPELINE_LIBRARY_REF', value: "${pipeline_library_ref}"), |
| 510 | string(name: 'MK_PIPELINES_REF', value: "${mk_pipelines_ref}"), |
Hanna Arhipova | 6fc7ec9 | 2021-09-22 20:34:52 +0300 | [diff] [blame] | 511 | string(name: 'SALT_MODELS_SYSTEM_REF_CHANGE', value: env.SALT_MODELS_SYSTEM_REF_CHANGE ?: ''), |
Dennis Dmitriev | f220d97 | 2018-10-10 15:19:14 +0300 | [diff] [blame] | 512 | string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"), |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 513 | string(name: 'UPDATE_VERSION', value: "${update_version}"), |
| 514 | string(name: 'MCP_COMMON_SCRIPTS_REFS', value: "${mcp_common_scripts_ref}"), |
| 515 | string(name: 'MCP_SALT_REPO_UPDATES', value: "'deb [arch=amd64] http://mirror.mirantis.com/update/${UPDATE_VERSION}/salt-formulas/xenial xenial main'"), |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 516 | ] |
dtsapikov | f707506 | 2023-01-16 14:29:37 +0400 | [diff] [blame] | 517 | build_pipeline_job('swarm-create-cfg-config-drive-jjb', parameters) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 518 | } |
| 519 | |
Dennis Dmitriev | 13e804b | 2018-10-09 19:25:14 +0300 | [diff] [blame] | 520 | def run_job_on_day01_node(stack_to_install, timeout=2400) { |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 521 | // stack_to_install="core,cicd" |
Dennis Dmitriev | 44f6db2 | 2018-10-31 16:07:56 +0200 | [diff] [blame] | 522 | def common = new com.mirantis.mk.Common() |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 523 | def stack = "${stack_to_install}" |
Dennis Dmitriev | 44f6db2 | 2018-10-31 16:07:56 +0200 | [diff] [blame] | 524 | common.printMsg("Deploy DriveTrain CICD components: ${stack_to_install}", "blue") |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 525 | try { |
| 526 | run_cmd("""\ |
| 527 | export ENV_NAME=${ENV_NAME} |
| 528 | . ./tcp_tests/utils/env_salt |
| 529 | . ./tcp_tests/utils/env_jenkins_day01 |
| 530 | export JENKINS_BUILD_TIMEOUT=${timeout} |
| 531 | JOB_PARAMETERS=\"{ |
| 532 | \\\"SALT_MASTER_URL\\\": \\\"\${SALTAPI_URL}\\\", |
Hanna Arhipova | 6f49352 | 2019-12-25 04:23:28 +0200 | [diff] [blame] | 533 | \\\"BATCH_SIZE\\\": \\\"\${BATCH_SIZE}\\\", |
Dmitriy Kruglov | 758f99c | 2020-02-04 12:04:31 +0100 | [diff] [blame] | 534 | \\\"STACK_INSTALL\\\": \\\"${stack}\\\", |
PGlazov | ed19b35 | 2020-05-21 16:42:27 +0400 | [diff] [blame] | 535 | \\\"DIST_UPGRADE_NODES\\\": \\\"\${DIST_UPGRADE_NODES}\\\", |
| 536 | \\\"UPGRADE_SALTSTACK\\\": \\\"\${UPGRADE_SALTSTACK}\\\" |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 537 | }\" |
Dennis Dmitriev | 44f6db2 | 2018-10-31 16:07:56 +0200 | [diff] [blame] | 538 | JOB_PREFIX="[ ${ENV_NAME}/{build_number}:drivetrain {time} ] " |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 539 | python ./tcp_tests/utils/run_jenkins_job.py --verbose --job-name=deploy_openstack --job-parameters="\$JOB_PARAMETERS" --job-output-prefix="\$JOB_PREFIX" |
| 540 | """) |
Dennis Dmitriev | 44f6db2 | 2018-10-31 16:07:56 +0200 | [diff] [blame] | 541 | // Wait for IO calm down on cluster nodes |
| 542 | sleep(60) |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 543 | } catch (e) { |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 544 | common.printMsg("Product job 'deploy_openstack' failed, getting details", "purple") |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 545 | def workflow_details=run_cmd_stdout("""\ |
| 546 | . ./tcp_tests/utils/env_salt |
| 547 | . ./tcp_tests/utils/env_jenkins_day01 |
| 548 | export JOB_NAME=deploy_openstack |
| 549 | export BUILD_NUMBER=lastBuild |
| 550 | python ./tcp_tests/utils/get_jenkins_job_stages.py |
| 551 | """) |
| 552 | throw new Exception(workflow_details) |
| 553 | } |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 554 | } |
| 555 | |
Dennis Dmitriev | 13e804b | 2018-10-09 19:25:14 +0300 | [diff] [blame] | 556 | def run_job_on_cicd_nodes(stack_to_install, timeout=2400) { |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 557 | // stack_to_install="k8s,calico,stacklight" |
Dennis Dmitriev | 44f6db2 | 2018-10-31 16:07:56 +0200 | [diff] [blame] | 558 | def common = new com.mirantis.mk.Common() |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 559 | def stack = "${stack_to_install}" |
Dennis Dmitriev | 44f6db2 | 2018-10-31 16:07:56 +0200 | [diff] [blame] | 560 | common.printMsg("Deploy Platform components: ${stack_to_install}", "blue") |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 561 | try { |
| 562 | run_cmd("""\ |
| 563 | export ENV_NAME=${ENV_NAME} |
| 564 | . ./tcp_tests/utils/env_salt |
| 565 | . ./tcp_tests/utils/env_jenkins_cicd |
| 566 | export JENKINS_BUILD_TIMEOUT=${timeout} |
| 567 | JOB_PARAMETERS=\"{ |
| 568 | \\\"SALT_MASTER_URL\\\": \\\"\${SALTAPI_URL}\\\", |
Hanna Arhipova | 6f49352 | 2019-12-25 04:23:28 +0200 | [diff] [blame] | 569 | \\\"BATCH_SIZE\\\": \\\"\${BATCH_SIZE}\\\", |
Dmitriy Kruglov | 758f99c | 2020-02-04 12:04:31 +0100 | [diff] [blame] | 570 | \\\"STACK_INSTALL\\\": \\\"${stack}\\\", |
PGlazov | ed19b35 | 2020-05-21 16:42:27 +0400 | [diff] [blame] | 571 | \\\"DIST_UPGRADE_NODES\\\": \\\"\${DIST_UPGRADE_NODES}\\\", |
| 572 | \\\"UPGRADE_SALTSTACK\\\": \\\"\${UPGRADE_SALTSTACK}\\\" |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 573 | }\" |
Dennis Dmitriev | 44f6db2 | 2018-10-31 16:07:56 +0200 | [diff] [blame] | 574 | JOB_PREFIX="[ ${ENV_NAME}/{build_number}:platform {time} ] " |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 575 | python ./tcp_tests/utils/run_jenkins_job.py --verbose --job-name=deploy_openstack --job-parameters="\$JOB_PARAMETERS" --job-output-prefix="\$JOB_PREFIX" |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 576 | """) |
Dennis Dmitriev | 44f6db2 | 2018-10-31 16:07:56 +0200 | [diff] [blame] | 577 | // Wait for IO calm down on cluster nodes |
| 578 | sleep(60) |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 579 | } catch (e) { |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 580 | common.printMsg("Product job 'deploy_openstack' failed, getting details", "purple") |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 581 | def workflow_details=run_cmd_stdout("""\ |
| 582 | . ./tcp_tests/utils/env_salt |
| 583 | . ./tcp_tests/utils/env_jenkins_cicd |
| 584 | export JOB_NAME=deploy_openstack |
| 585 | export BUILD_NUMBER=lastBuild |
| 586 | python ./tcp_tests/utils/get_jenkins_job_stages.py |
| 587 | """) |
| 588 | throw new Exception(workflow_details) |
| 589 | } |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | def sanity_check_component(stack) { |
| 593 | // Run sanity check for the component ${stack}. |
| 594 | // Result will be stored in JUnit XML file deploy_${stack}.xml |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 595 | try { |
| 596 | run_cmd("""\ |
Dennis Dmitriev | 2700732 | 2019-05-03 19:21:44 +0300 | [diff] [blame] | 597 | export LOG_NAME=deploy_${stack}_test.log |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 598 | py.test --junit-xml=deploy_${stack}.xml -m check_${stack} |
| 599 | """) |
| 600 | } catch (e) { |
| 601 | def String junit_report_xml = readFile("deploy_${stack}.xml") |
| 602 | def String junit_report_xml_pretty = new XmlUtil().serialize(junit_report_xml) |
| 603 | def String msg = "Sanity check for '${stack}' failed, JUnit report:\n" |
| 604 | throw new Exception(msg + junit_report_xml_pretty) |
| 605 | } |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 606 | } |
| 607 | |
Dennis Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 608 | def download_logs(archive_name_prefix) { |
| 609 | // Archive and download logs and debug info from salt nodes in the lab |
| 610 | // Do not fail in case of error to not lose the original error from the parent exception. |
| 611 | def common = new com.mirantis.mk.Common() |
| 612 | common.printMsg("Downloading nodes logs by ${archive_name_prefix}", "blue") |
| 613 | run_cmd("""\ |
| 614 | export TESTS_CONFIGS=\$(pwd)/${ENV_NAME}_salt_deployed.ini |
| 615 | ./tcp_tests/utils/get_logs.py --archive-name-prefix ${archive_name_prefix} || true |
| 616 | """) |
| 617 | } |
| 618 | |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 619 | def devops_snapshot_info(snapshot_name) { |
| 620 | // Print helper message after snapshot |
| 621 | def common = new com.mirantis.mk.Common() |
| 622 | |
| 623 | def SALT_MASTER_IP=run_cmd_stdout("""\ |
| 624 | . ./tcp_tests/utils/env_salt |
| 625 | echo \$SALT_MASTER_IP |
| 626 | """).trim().split().last() |
| 627 | def login = "root" // set fixed 'root' login for now |
| 628 | def password = "r00tme" // set fixed 'root' login for now |
| 629 | def key_file = "${env.WORKSPACE}/id_rsa" // set fixed path in the WORKSPACE |
| 630 | def VENV_PATH='/home/jenkins/fuel-devops30' |
| 631 | |
| 632 | common.printMsg("""\ |
| 633 | ######################### |
| 634 | # To revert the snapshot: |
| 635 | ######################### |
| 636 | . ${VENV_PATH}/bin/activate; |
| 637 | dos.py revert ${ENV_NAME} ${snapshot_name}; |
| 638 | dos.py resume ${ENV_NAME}; |
| 639 | # dos.py time-sync ${ENV_NAME}; # Optional\n |
| 640 | ssh -i ${key_file} ${login}@${SALT_MASTER_IP} # Optional password: ${password} |
| 641 | """, "cyan") |
| 642 | } |
| 643 | |
Dennis Dmitriev | 2bacadf | 2019-05-03 17:26:11 +0300 | [diff] [blame] | 644 | def devops_snapshot(stacks) { |
| 645 | // Make snapshots with names "${stack}_deployed" for each stack |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 646 | // for all VMs in the environment. |
Dennis Dmitriev | 2bacadf | 2019-05-03 17:26:11 +0300 | [diff] [blame] | 647 | |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 648 | run_cmd("""\ |
| 649 | dos.py suspend ${ENV_NAME} |
Dennis Dmitriev | 2bacadf | 2019-05-03 17:26:11 +0300 | [diff] [blame] | 650 | """) |
| 651 | |
| 652 | for (stack in "${stacks}".split(",")) { |
| 653 | run_cmd("""\ |
| 654 | dos.py snapshot ${ENV_NAME} ${stack}_deployed |
| 655 | """) |
| 656 | devops_snapshot_info("${stack}_deployed") |
| 657 | } |
| 658 | |
| 659 | run_cmd("""\ |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 660 | dos.py resume ${ENV_NAME} |
Dennis Dmitriev | 1fed666 | 2018-07-27 18:22:13 +0300 | [diff] [blame] | 661 | sleep 20 # Wait for I/O on the host calms down |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 662 | |
| 663 | CFG01_NAME=\$(dos.py show-resources ${ENV_NAME} | grep ^cfg01 | cut -d" " -f1) |
| 664 | dos.py time-sync ${ENV_NAME} --skip-sync \${CFG01_NAME} |
Dennis Dmitriev | 8df3544 | 2018-07-31 08:40:20 +0300 | [diff] [blame] | 665 | """) |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 666 | } |
| 667 | |
Dennis Dmitriev | fde667f | 2018-07-23 16:26:50 +0300 | [diff] [blame] | 668 | def get_steps_list(steps) { |
| 669 | // Make a list from comma separated string |
| 670 | return steps.split(',').collect { it.split(':')[0] } |
| 671 | } |
| 672 | |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 673 | def create_xml_report(String filename, String classname, String name, String status='success', String status_message='', String text='', String stdout='', String stderr='') { |
| 674 | // <filename> is name of the XML report file that will be created |
| 675 | // <status> is one of the 'success', 'skipped', 'failure' or 'error' |
| 676 | // 'error' status is assumed as 'Blocker' in TestRail reporter |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 677 | |
| 678 | // Replace '<' and '>' to '<' and '>' to avoid conflicts between xml tags in the message and JUnit report |
Hanna Arhipova | 7068507 | 2021-01-25 16:11:57 +0200 | [diff] [blame] | 679 | def String text_filtered = text.replaceAll("&", "&"). |
| 680 | replaceAll("<","<"). |
Hanna Arhipova | 413c1db | 2020-02-11 15:37:48 +0200 | [diff] [blame] | 681 | replaceAll(">", ">"). |
| 682 | replaceAll("[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+", "") |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 683 | |
Dennis Dmitriev | 3966608 | 2018-08-29 15:30:45 +0300 | [diff] [blame] | 684 | def script = """\ |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 685 | <?xml version=\"1.0\" encoding=\"utf-8\"?> |
| 686 | <testsuite> |
| 687 | <testcase classname=\"${classname}\" name=\"${name}\" time=\"0\"> |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 688 | <${status} message=\"${status_message}\">${text_filtered}</${status}> |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 689 | <system-out>${stdout}</system-out> |
| 690 | <system-err>${stderr}</system-err> |
| 691 | </testcase> |
| 692 | </testsuite> |
Dennis Dmitriev | 3966608 | 2018-08-29 15:30:45 +0300 | [diff] [blame] | 693 | """ |
| 694 | writeFile(file: filename, text: script, encoding: "UTF-8") |
Dennis Dmitriev | b3b3749 | 2018-07-08 21:23:00 +0300 | [diff] [blame] | 695 | } |
| 696 | |
Anna Arhipova | e2cf751 | 2022-07-21 14:03:54 +0200 | [diff] [blame] | 697 | |
| 698 | def withVirtualEnv(name, pythonVersion, installRepo = "", command = "") { |
| 699 | /// name - str, name of virtualenv, name of folder which will be located in /home/jenkins |
| 700 | /// pythonVersion - str, version of python defined through the ShiningPanda settings in the Jenkins (Jenkins -> |
| 701 | //Manage Jenkins -> Global Tool Configuration -> Python Installations) |
| 702 | /// installRepo - repo with tool which should be installed in that virtualenv |
| 703 | def homeDir = "/home/jenkins" |
| 704 | venvPath = "${homeDir}/${name}" |
| 705 | // check if venv exists |
| 706 | |
| 707 | withPythonEnv("${pythonVersion}") { |
| 708 | if (!fileExists(venvPath)) { |
| 709 | sh """ |
| 710 | virtualenv --python=\$(which python) ${venvPath} |
| 711 | . ${venvPath}/bin/activate |
| 712 | pip install -U ${installRepo} |
| 713 | """ |
| 714 | } |
Anna Arhipova | 9bcf42f | 2022-08-01 10:58:13 +0200 | [diff] [blame] | 715 | return sh(script: """ |
Anna Arhipova | e2cf751 | 2022-07-21 14:03:54 +0200 | [diff] [blame] | 716 | . ${venvPath}/bin/activate |
| 717 | ${command} |
| 718 | deactivate |
Anna Arhipova | 9bcf42f | 2022-08-01 10:58:13 +0200 | [diff] [blame] | 719 | """, returnStdout: true) |
Anna Arhipova | e2cf751 | 2022-07-21 14:03:54 +0200 | [diff] [blame] | 720 | } |
| 721 | } |
| 722 | |
| 723 | |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 724 | def upload_results_to_testrail(report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options=[]) { |
Tatyana Leontovich | bfbc483 | 2018-12-27 12:47:23 +0200 | [diff] [blame] | 725 | def testPlanDesc = env.LAB_CONFIG_NAME |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 726 | def testrailURL = "https://mirantis.testrail.com" |
| 727 | def testrailProject = "Mirantis Cloud Platform" |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 728 | def testrailMilestone = "MCP1.1" |
Dennis Dmitriev | 707b215 | 2018-10-23 19:12:48 +0300 | [diff] [blame] | 729 | def testrailCaseMaxNameLenght = 250 |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 730 | def jobURL = env.BUILD_URL |
| 731 | |
| 732 | def reporterOptions = [ |
| 733 | "--verbose", |
| 734 | "--env-description \"${testPlanDesc}\"", |
| 735 | "--testrail-run-update", |
| 736 | "--testrail-url \"${testrailURL}\"", |
| 737 | "--testrail-user \"\${TESTRAIL_USER}\"", |
| 738 | "--testrail-password \"\${TESTRAIL_PASSWORD}\"", |
| 739 | "--testrail-project \"${testrailProject}\"", |
| 740 | "--testrail-plan-name \"${testPlanName}\"", |
| 741 | "--testrail-milestone \"${testrailMilestone}\"", |
| 742 | "--testrail-suite \"${testSuiteName}\"", |
| 743 | "--xunit-name-template \"${methodname}\"", |
| 744 | "--testrail-name-template \"${testrail_name_template}\"", |
| 745 | "--test-results-link \"${jobURL}\"", |
Dennis Dmitriev | 707b215 | 2018-10-23 19:12:48 +0300 | [diff] [blame] | 746 | "--testrail-case-max-name-lenght ${testrailCaseMaxNameLenght}", |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 747 | ] + reporter_extra_options |
| 748 | |
| 749 | def script = """ |
Ekaterina Chernova | 0d81efc | 2019-10-28 16:23:17 +0300 | [diff] [blame] | 750 | report ${reporterOptions.join(' ')} ${report_name} |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 751 | """ |
| 752 | |
| 753 | def testrail_cred_id = params.TESTRAIL_CRED ?: 'testrail_system_tests' |
| 754 | |
| 755 | withCredentials([ |
| 756 | [$class : 'UsernamePasswordMultiBinding', |
| 757 | credentialsId : testrail_cred_id, |
| 758 | passwordVariable: 'TESTRAIL_PASSWORD', |
| 759 | usernameVariable: 'TESTRAIL_USER'] |
| 760 | ]) { |
Anna Arhipova | e2cf751 | 2022-07-21 14:03:54 +0200 | [diff] [blame] | 761 | |
| 762 | def ret = [:] |
| 763 | ret.stdout = '' |
| 764 | ret.exception = '' |
| 765 | try { |
| 766 | sshagent(credentials: ['maintenance-team-ssh']) { |
Anna Arhipova | 9bcf42f | 2022-08-01 10:58:13 +0200 | [diff] [blame] | 767 | ret.stdout = withVirtualEnv( |
Anna Arhipova | e2cf751 | 2022-07-21 14:03:54 +0200 | [diff] [blame] | 768 | "venv_testrail_reporter", |
| 769 | "python3.7", |
| 770 | "git+ssh://maintenance-ci-robot@gerrit.mcp.mirantis.com:29418/mcp/testrail-reporter", |
| 771 | script |
| 772 | )} |
| 773 | // ret.stdout = run_cmd_stdout(script) |
| 774 | } catch (Exception ex) { |
| 775 | ret.exception = ("""\ |
| 776 | ##### Report to '${testSuiteName}' failed: #####\n""" + ex.message + "\n\n") |
| 777 | } |
| 778 | |
| 779 | return ret |
| 780 | } |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 781 | } |
| 782 | |
| 783 | |
| 784 | def create_deploy_result_report(deploy_expected_stacks, result, text) { |
| 785 | def STATUS_MAP = ['SUCCESS': 'success', 'FAILURE': 'failure', 'UNSTABLE': 'failure', 'ABORTED': 'error'] |
| 786 | def classname = "Deploy" |
| 787 | def name = "deployment_${ENV_NAME}" |
Dennis Dmitriev | 3966608 | 2018-08-29 15:30:45 +0300 | [diff] [blame] | 788 | def filename = "${name}.xml" |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 789 | def status = STATUS_MAP[result ?: 'FAILURE'] // currentBuild.result *must* be set at the finish of the try/catch |
| 790 | create_xml_report(filename, classname, name, status, "Deploy components: ${deploy_expected_stacks}", text, '', '') |
Dennis Dmitriev | 27a9679 | 2018-07-30 07:52:03 +0300 | [diff] [blame] | 791 | } |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 792 | |
| 793 | def mark_test_results(testPlanName, testSuiteName) { |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 794 | def testrailURL = "https://mirantis.testrail.com" |
| 795 | def testrailProject = "Mirantis Cloud Platform" |
| 796 | def configName = env.LAB_CONFIG_NAME |
| 797 | def testRunName = "${configName} <${testSuiteName}>" |
| 798 | |
| 799 | def script = """ |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 800 | export TESTRAIL_URL=${testrailURL} |
| 801 | testrail-reporter analyze -p "${testrailProject}" -t "${testPlanName}" -r "${testRunName}" checklist.yaml |
| 802 | """ |
| 803 | |
| 804 | def testrail_cred_id = params.TESTRAIL_CRED ?: 'testrail_system_tests' |
| 805 | |
| 806 | withCredentials([ |
| 807 | [$class : 'UsernamePasswordMultiBinding', |
| 808 | credentialsId : testrail_cred_id, |
| 809 | passwordVariable: 'TESTRAIL_PASSWORD', |
| 810 | usernameVariable: 'TESTRAIL_USER'] |
| 811 | ]) { |
| 812 | def ret = [:] |
| 813 | ret.stdout = '' |
| 814 | ret.exception = '' |
| 815 | try { |
Anna Arhipova | 9bcf42f | 2022-08-01 10:58:13 +0200 | [diff] [blame] | 816 | ret.stdout = withVirtualEnv("venv_testrail_analyzer", |
Anna Arhipova | e2cf751 | 2022-07-21 14:03:54 +0200 | [diff] [blame] | 817 | "python3.7", |
| 818 | "git+https://review.gerrithub.io/ibumarskov/testrail-reporter", |
| 819 | script) |
| 820 | // ret.stdout = run_cmd_stdout(script) |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 821 | } catch (Exception ex) { |
| 822 | ret.exception = ("""\ |
| 823 | ##### Report to '${testRunName}' failed: #####\n""" + ex.message + "\n\n") |
| 824 | } |
| 825 | return ret |
| 826 | } |
Hanna Arhipova | 3be5062 | 2021-01-11 13:11:45 +0200 | [diff] [blame] | 827 | } |
Anna Arhipova | e2cf751 | 2022-07-21 14:03:54 +0200 | [diff] [blame] | 828 | |
Hanna Arhipova | cd1bcdb | 2021-04-23 18:47:48 +0300 | [diff] [blame] | 829 | def reboot_hardware_nodes(creds_name) { |
| 830 | bm_ips_file = readFile("tcp_tests/templates/${creds_name}") |
| 831 | bm_ips = bm_ips_file.split("\n") |
| 832 | withCredentials([ |
| 833 | [$class : 'UsernamePasswordMultiBinding', |
| 834 | credentialsId : creds_name, |
| 835 | passwordVariable: 'lab_pass', |
| 836 | usernameVariable: 'lab_user'] |
| 837 | ]) { |
| 838 | for (String ip : bm_ips) { sh ("ipmitool -H ${ip} -U ${lab_user} -P ${lab_pass} -I lanplus chassis power off")} |
| 839 | for (String ip : bm_ips) { sh ("ipmitool -H ${ip} -U ${lab_user} -P ${lab_pass} -I lanplus chassis bootdev pxe")} |
| 840 | } |
| 841 | } |