Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Create fuel-devops environment, generate a model for it |
| 4 | * and bootstrap a salt cluster on the environment nodes |
| 5 | * |
| 6 | * Expected parameters: |
| 7 | |
| 8 | * PARENT_NODE_NAME Name of the jenkins slave to create the environment |
| 9 | * PARENT_WORKSPACE Path to the workspace of the parent job to use tcp-qa repo |
| 10 | * LAB_CONFIG_NAME Name of the tcp-qa deployment template |
| 11 | * ENV_NAME Fuel-devops environment name |
| 12 | * MCP_VERSION MCP version, like 2018.4 or proposed |
| 13 | * MCP_IMAGE_PATH1604 Local path to the image http://ci.mcp.mirantis.net:8085/images/ubuntu-16-04-x64-mcpproposed.qcow2 |
| 14 | * IMAGE_PATH_CFG01_DAY01 Local path to the image http://ci.mcp.mirantis.net:8085/images/cfg01-day01-proposed.qcow2 |
| 15 | * CFG01_CONFIG_IMAGE_NAME Name for the creating config drive image, like cfg01.${LAB_CONFIG_NAME}-config-drive.iso |
Hanna Arhipova | 5173aad | 2019-11-11 12:42:31 +0200 | [diff] [blame] | 16 | * TCP_QA_REFS Reference to the tcp-qa change on Gerrit, like refs/changes/46/418546/41 |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 17 | * PIPELINE_LIBRARY_REF Reference to the pipeline-library change |
| 18 | * MK_PIPELINES_REF Reference to the mk-pipelines change |
| 19 | * COOKIECUTTER_TEMPLATE_COMMIT Commit/tag/branch for cookiecutter-templates repository. If empty, then takes ${MCP_VERSION} value |
| 20 | * SALT_MODELS_SYSTEM_COMMIT Commit/tag/branch for reclass-system repository. If empty, then takes ${MCP_VERSION} value |
| 21 | * SHUTDOWN_ENV_ON_TEARDOWN optional, shutdown fuel-devops environment at the end of the job |
| 22 | * MCP_SALT_REPO_URL Base URL for MCP repositories required to bootstrap cfg01 node. Leave blank to use default |
| 23 | * (http://mirror.mirantis.com/ from mcp-common-scripts) |
| 24 | * MCP_SALT_REPO_KEY URL of the key file. Leave blank to use default |
| 25 | * (${MCP_SALT_REPO_URL}/${MCP_VERSION}/salt-formulas/xenial/archive-salt-formulas.key from mcp-common-scripts) |
| 26 | * OS_AUTH_URL OpenStack keystone catalog URL |
| 27 | * OS_PROJECT_NAME OpenStack project (tenant) name |
| 28 | * OS_USER_DOMAIN_NAME OpenStack user domain name |
| 29 | * OS_CREDENTIALS OpenStack username and password credentials ID in Jenkins |
Tatyana Leontovich | 8ac26d7 | 2019-05-15 23:33:38 +0300 | [diff] [blame] | 30 | * JENKINS_PIPELINE_BRANCH Should be set in release/proposed/2019.2.0 when we test non-released version |
Tatyana Leontovich | 4718bdf | 2019-05-24 12:37:06 +0300 | [diff] [blame] | 31 | * UPDATE_VERSION Version of update to deploy |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 32 | * LAB_PARAM_DEFAULTS Filename placed in tcp_tests/templates/_heat_environments, with default parameters for the heat template |
Hanna Arhipova | 31cb1d8 | 2021-01-27 09:41:11 +0200 | [diff] [blame] | 33 | * DEPLOY_EMPTY_NODE Add extra node to heat stack. Node without a role and with salt-minion |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 34 | * |
Dennis Dmitriev | 0244741 | 2019-04-17 18:02:46 +0300 | [diff] [blame] | 35 | * CREATE_JENKINS_NODE_CREDENTIALS Jenkins username and password with rights to add/delete Jenkins agents |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 36 | */ |
| 37 | |
| 38 | @Library('tcp-qa')_ |
| 39 | |
| 40 | import groovy.xml.XmlUtil |
| 41 | |
| 42 | common = new com.mirantis.mk.Common() |
| 43 | shared = new com.mirantis.system_qa.SharedPipeline() |
| 44 | |
| 45 | if (! env.PARENT_NODE_NAME) { |
| 46 | error "'PARENT_NODE_NAME' must be set from the parent deployment job!" |
| 47 | } |
| 48 | |
| 49 | currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}" |
Hanna Arhipova | c2965a4 | 2020-01-21 12:27:33 +0200 | [diff] [blame] | 50 | def cfg01_day01_image_name = "cfg01-day01-2019.2.0" |
| 51 | def ubuntu_vcp_image_name = "ubuntu-vcp-2019.2.0" |
| 52 | def ubuntu_foundation_image_name = "ubuntu-16.04-foundation-2019.2.0" |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 53 | |
Pavel Glazov | 65e842b | 2023-05-30 01:32:05 +0400 | [diff] [blame] | 54 | timeout(time: 3, unit: 'HOURS') { |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 55 | timestamps { |
| 56 | node ("${PARENT_NODE_NAME}") { |
| 57 | if (! fileExists("${PARENT_WORKSPACE}")) { |
| 58 | error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'." |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 59 | } |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 60 | dir("${PARENT_WORKSPACE}") { |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 61 | |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 62 | if (env.TCP_QA_REFS) { |
| 63 | stage("Update working dir to patch ${TCP_QA_REFS}") { |
| 64 | shared.update_working_dir() |
Dmitry Tyzhnenko | 819f5bf | 2019-05-29 14:45:09 +0300 | [diff] [blame] | 65 | } |
| 66 | } |
Dennis Dmitriev | 2700732 | 2019-05-03 19:21:44 +0300 | [diff] [blame] | 67 | |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 68 | withCredentials([ |
| 69 | [$class : 'UsernamePasswordMultiBinding', |
| 70 | credentialsId : env.OS_CREDENTIALS, |
| 71 | passwordVariable: 'OS_PASSWORD', |
| 72 | usernameVariable: 'OS_USERNAME'] |
| 73 | ]) { |
| 74 | env.OS_IDENTITY_API_VERSION = 3 |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 75 | |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 76 | stage("Cleanup: erase ${ENV_NAME} and remove config drive") { |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 77 | |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 78 | // delete heat stack |
| 79 | println "Remove heat stack '${ENV_NAME}'" |
| 80 | shared.run_cmd("""\ |
| 81 | # export OS_IDENTITY_API_VERSION=3 |
| 82 | # export OS_AUTH_URL=${OS_AUTH_URL} |
| 83 | # export OS_USERNAME=${OS_USERNAME} |
| 84 | # export OS_PASSWORD=${OS_PASSWORD} |
| 85 | # export OS_PROJECT_NAME=${OS_PROJECT_NAME} |
| 86 | openstack --insecure stack delete -y ${ENV_NAME} || true |
| 87 | timeout 20m /bin/bash -c "while openstack --insecure stack show ${ENV_NAME} -f value -c stack_status; do sleep 10; done" |
| 88 | """) |
Dennis Dmitriev | 2700732 | 2019-05-03 19:21:44 +0300 | [diff] [blame] | 89 | |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 90 | println "Remove config drive ISO" |
| 91 | shared.run_cmd("""\ |
| 92 | rm /home/jenkins/images/${CFG01_CONFIG_IMAGE_NAME} || true |
| 93 | """) |
| 94 | } |
| 95 | |
| 96 | stage("Generate the model") { |
| 97 | def IPV4_NET_ADMIN=shared.run_cmd_stdout("./tcp_tests/utils/get_param_heat_template.py management_subnet_cidr").trim().split().last() |
| 98 | def IPV4_NET_CONTROL=shared.run_cmd_stdout("./tcp_tests/utils/get_param_heat_template.py control_subnet_cidr").trim().split().last() |
| 99 | def IPV4_NET_TENANT=shared.run_cmd_stdout("./tcp_tests/utils/get_param_heat_template.py tenant_subnet_cidr").trim().split().last() |
| 100 | def IPV4_NET_EXTERNAL=shared.run_cmd_stdout("./tcp_tests/utils/get_param_heat_template.py external_subnet_cidr").trim().split().last() |
| 101 | shared.generate_cookied_model(IPV4_NET_ADMIN, IPV4_NET_CONTROL, IPV4_NET_TENANT, IPV4_NET_EXTERNAL) |
| 102 | } |
| 103 | |
| 104 | stage("Generate config drive ISO") { |
| 105 | SALT_MASTER_IP=shared.run_cmd_stdout("./tcp_tests/utils/get_param_heat_template.py management_subnet_cfg01_ip").trim().split().last() |
| 106 | def ADMIN_NETWORK_GW=shared.run_cmd_stdout("./tcp_tests/utils/get_param_heat_template.py management_subnet_gateway_ip").trim().split().last() |
| 107 | shared.generate_configdrive_iso(SALT_MASTER_IP, ADMIN_NETWORK_GW) |
| 108 | } |
| 109 | |
| 110 | stage("Upload Ubuntu image for foundation node") { |
| 111 | shared.run_cmd("""\ |
| 112 | if ! openstack --insecure image show ${ubuntu_foundation_image_name} -f value -c name; then |
| 113 | wget -O ./${ubuntu_foundation_image_name} https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img |
| 114 | openstack --insecure image create ${ubuntu_foundation_image_name} --file ./${ubuntu_foundation_image_name} --disk-format qcow2 --container-format bare |
| 115 | rm ./${ubuntu_foundation_image_name} |
| 116 | else |
| 117 | echo Image ${ubuntu_foundation_image_name} already exists |
| 118 | fi |
| 119 | """) |
| 120 | } |
| 121 | |
| 122 | stage("Upload cfg01-day01 and VCP images") { |
| 123 | shared.run_cmd("""\ |
| 124 | # export OS_IDENTITY_API_VERSION=3 |
| 125 | # export OS_AUTH_URL=${OS_AUTH_URL} |
| 126 | # export OS_USERNAME=${OS_USERNAME} |
| 127 | # export OS_PASSWORD=${OS_PASSWORD} |
| 128 | # export OS_PROJECT_NAME=${OS_PROJECT_NAME} |
| 129 | |
| 130 | openstack --insecure image show ${cfg01_day01_image_name} -f value -c name || openstack --insecure image create ${cfg01_day01_image_name} --file ${IMAGE_PATH_CFG01_DAY01} --disk-format qcow2 --container-format bare |
| 131 | openstack --insecure image show ${ubuntu_vcp_image_name} -f value -c name || openstack --insecure image create ${ubuntu_vcp_image_name} --file ${MCP_IMAGE_PATH1604} --disk-format qcow2 --container-format bare |
| 132 | """) |
| 133 | } |
| 134 | |
| 135 | stage("Upload generated config drive ISO into volume on cfg01 node") { |
| 136 | shared.run_cmd("""\ |
| 137 | # export OS_IDENTITY_API_VERSION=3 |
| 138 | # export OS_AUTH_URL=${OS_AUTH_URL} |
| 139 | # export OS_USERNAME=${OS_USERNAME} |
| 140 | # export OS_PASSWORD=${OS_PASSWORD} |
| 141 | # export OS_PROJECT_NAME=${OS_PROJECT_NAME} |
| 142 | |
| 143 | openstack --insecure image delete cfg01.${ENV_NAME}-config-drive.iso || true |
| 144 | sleep 3 |
| 145 | openstack --insecure image create cfg01.${ENV_NAME}-config-drive.iso --file /home/jenkins/images/${CFG01_CONFIG_IMAGE_NAME} --disk-format iso --container-format bare |
| 146 | """) |
| 147 | } |
| 148 | |
| 149 | stage("Create Heat stack '${ENV_NAME}'") { |
| 150 | // Create stack and wait for CREATE_COMPLETED status, manual analog: |
| 151 | // openstack --insecure stack create ${ENV_NAME} \ |
| 152 | // --template ./tcp_tests/templates/${LAB_CONFIG_NAME}/underlay.hot \ |
| 153 | // --environment ./tcp_tests/templates/_heat_environments/${LAB_PARAM_DEFAULTS} \ |
| 154 | // --parameter env_name=${ENV_NAME} --parameter mcp_version=${MCP_VERSION} |
| 155 | shared.run_cmd("""\ |
| 156 | export BOOTSTRAP_TIMEOUT=3600 |
| 157 | export ENV_MANAGER=heat |
| 158 | export TEST_GROUP=test_create_environment |
| 159 | export SHUTDOWN_ENV_ON_TEARDOWN=false |
| 160 | export PYTHONIOENCODING=UTF-8 |
| 161 | export REPOSITORY_SUITE=${MCP_VERSION} |
| 162 | export UPDATE_VERSION=${UPDATE_VERSION} |
| 163 | export ENV_NAME=${ENV_NAME} |
| 164 | export LAB_CONFIG_NAME=${LAB_CONFIG_NAME} |
| 165 | export LAB_PARAM_DEFAULTS=${LAB_PARAM_DEFAULTS} |
Hanna Arhipova | 31cb1d8 | 2021-01-27 09:41:11 +0200 | [diff] [blame] | 166 | export DEPLOY_EMPTY_NODE=${DEPLOY_EMPTY_NODE} |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 167 | export LOG_NAME=swarm_test_create_environment.log |
| 168 | py.test --cache-clear -vvv -s -p no:django -p no:ipdb --junit-xml=deploy_hardware.xml -k \${TEST_GROUP} |
| 169 | """) |
| 170 | } |
| 171 | |
| 172 | stage("Add the Jenkins slave node") { |
| 173 | def jenkins_slave_ip_value_name = "foundation_public_ip" |
| 174 | def jenkins_slave_ip = shared.run_cmd_stdout("openstack --insecure stack output show ${ENV_NAME} ${jenkins_slave_ip_value_name} -f value -c output_value").trim().split().last() |
| 175 | def jenkins_slave_executors = 2 |
| 176 | common.printMsg("JENKINS_SLAVE_NODE_NAME=${JENKINS_SLAVE_NODE_NAME}", "green") |
| 177 | common.printMsg("JENKINS_SLAVE_IP=${jenkins_slave_ip}", "green") |
| 178 | |
Vladimir Khlyunev | ddabf7c | 2023-06-28 05:14:32 +0400 | [diff] [blame^] | 179 | withCredentials([[$class : 'UsernamePasswordMultiBinding', |
| 180 | credentialsId : "${CREATE_JENKINS_NODE_CREDENTIALS}", |
| 181 | passwordVariable: 'JENKINS_PASS', |
| 182 | usernameVariable: 'JENKINS_USER']]) { |
| 183 | sh "curl ${JENKINS_URL}/jnlpJars/jenkins-cli.jar --output jenkins-cli.jar" |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 184 | |
Vladimir Khlyunev | ddabf7c | 2023-06-28 05:14:32 +0400 | [diff] [blame^] | 185 | sh "java -jar jenkins-cli.jar -s ${JENKINS_URL} -auth ${JENKINS_USER}:${JENKINS_PASS} delete-node ${JENKINS_SLAVE_NODE_NAME} || true" |
| 186 | create_node_xml="""\ |
| 187 | <slave> |
| 188 | <name>${JENKINS_SLAVE_NODE_NAME}</name> |
| 189 | <description>${ENV_NAME}</description> |
| 190 | <remoteFS>/home/jenkins/workspace</remoteFS> |
| 191 | <numExecutors>${jenkins_slave_executors}</numExecutors> |
| 192 | <mode>EXCLUSIVE</mode> |
| 193 | <retentionStrategy class="hudson.slaves.RetentionStrategy\$Always"/> |
| 194 | <launcher class="hudson.plugins.sshslaves.SSHLauncher"> |
| 195 | <host>${jenkins_slave_ip}</host> |
| 196 | <port>22</port> |
| 197 | <credentialsId>${ACCESS_JENKINS_NODE_CREDENTIALS}</credentialsId> |
| 198 | </launcher> |
| 199 | <label>${ENV_NAME}</label> |
| 200 | <nodeProperties/> |
| 201 | </slave>""".stripIndent().replaceAll("\\n", "") |
| 202 | sh "echo '${create_node_xml}' | java -jar jenkins-cli.jar -s ${JENKINS_URL} -auth ${JENKINS_USER}:${JENKINS_PASS} create-node ${JENKINS_SLAVE_NODE_NAME}" |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 203 | |
Vladimir Khlyunev | ddabf7c | 2023-06-28 05:14:32 +0400 | [diff] [blame^] | 204 | timeout(time: 30, unit: 'MINUTES') { |
| 205 | node("${JENKINS_SLAVE_NODE_NAME}") { |
| 206 | sh "echo 'ok'" |
| 207 | println "Jenkins agent is available now and can executes commands" |
| 208 | } |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 209 | } |
Vladimir Khlyunev | ddabf7c | 2023-06-28 05:14:32 +0400 | [diff] [blame^] | 210 | // Store jenkins agent IP address |
| 211 | jenkins_agent_description = "ssh jenkins@${jenkins_slave_ip} # foundation node with Jenkins agent <a href=${JENKINS_URL}/computer/${JENKINS_SLAVE_NODE_NAME}>${JENKINS_SLAVE_NODE_NAME}</a><br>ssh root@${SALT_MASTER_IP} # cfg01 node<br>" |
| 212 | writeFile(file: "jenkins_agent_description.txt", text: jenkins_agent_description, encoding: "UTF-8") |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 213 | |
Vladimir Khlyunev | ddabf7c | 2023-06-28 05:14:32 +0400 | [diff] [blame^] | 214 | } // withCredentials |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 215 | |
| 216 | }// stage |
| 217 | |
| 218 | } // withCredentials |
| 219 | |
| 220 | } // dir |
| 221 | } // node |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 222 | |
| 223 | |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 224 | node ("${JENKINS_SLAVE_NODE_NAME}") { |
| 225 | dir("${PARENT_WORKSPACE}") { |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 226 | |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 227 | stage("Clean the environment and clone tcp-qa") { |
| 228 | deleteDir() |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 229 | // Install TestRail reporter to upload test results to TestRail |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 230 | shared.verbose_sh("""\ |
Hanna Arhipova | 01bd032 | 2020-12-21 15:48:07 +0200 | [diff] [blame] | 231 | [ -d /home/jenkins/venv_testrail_reporter ] || virtualenv --python=python3.7 /home/jenkins/venv_testrail_reporter |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 232 | """, true, false, true) |
Vladimir Khlyunev | e4368bf | 2022-06-22 23:43:51 +0400 | [diff] [blame] | 233 | sshagent(credentials: ['maintenance-team-ssh']) { |
| 234 | shared.run_cmd("""\ |
Pavel Glazov | 6583fd5 | 2023-05-13 02:56:33 +0400 | [diff] [blame] | 235 | . /home/jenkins/venv_testrail_reporter/bin/activate; \ |
| 236 | pip install urllib3==1.26.6; \ |
| 237 | pip install git+ssh://maintenance-ci-robot@gerrit.mcp.mirantis.com:29418/mcp/testrail-reporter -U; |
Vladimir Khlyunev | e4368bf | 2022-06-22 23:43:51 +0400 | [diff] [blame] | 238 | """) |
| 239 | } |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 240 | // Install DEVOPS tools |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 241 | shared.verbose_sh("""\ |
| 242 | [ -d /home/jenkins/fuel-devops30 ] || virtualenv /home/jenkins/fuel-devops30 |
| 243 | """, true, false, true) |
| 244 | shared.run_cmd("""\ |
| 245 | git clone https://gerrit.mcp.mirantis.com/mcp/tcp-qa ${PARENT_WORKSPACE} |
| 246 | """) |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 247 | // Install TestRail reporter to mark known failures test results to TestRail |
| 248 | shared.verbose_sh("""\ |
Vladimir Khlyunev | 3725b67 | 2022-03-04 16:16:23 +0400 | [diff] [blame] | 249 | [ -d /home/jenkins/venv_testrail_analyzer ] || virtualenv --python=python3.7 /home/jenkins/venv_testrail_analyzer |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 250 | """, true, false, true) |
| 251 | shared.run_cmd("""\ |
Pavel Glazov | 6583fd5 | 2023-05-13 02:56:33 +0400 | [diff] [blame] | 252 | . /home/jenkins/venv_testrail_analyzer/bin/activate; \ |
| 253 | pip install urllib3==1.26.6; \ |
| 254 | pip install git+https://review.gerrithub.io/ibumarskov/testrail-reporter@b9041b241f3364022cd0ad63510f02aab4352a6b; |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 255 | """) |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 256 | shared.update_working_dir() |
dtsapikov | d1d6fe8 | 2021-11-19 17:45:06 +0400 | [diff] [blame] | 257 | // Add info about foundation node for description |
| 258 | writeFile(file: "jenkins_agent_description.txt", text: jenkins_agent_description, encoding: "UTF-8") |
Dennis Dmitriev | 4c38347 | 2019-04-12 13:58:06 +0300 | [diff] [blame] | 259 | } |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 260 | |
| 261 | withCredentials([ |
| 262 | [$class : 'UsernamePasswordMultiBinding', |
| 263 | credentialsId : env.OS_CREDENTIALS, |
| 264 | passwordVariable: 'OS_PASSWORD', |
| 265 | usernameVariable: 'OS_USERNAME'] |
| 266 | ]) { |
| 267 | |
| 268 | |
| 269 | stage("Run the 'underlay' and 'salt-deployed' fixtures to bootstrap salt cluster") { |
| 270 | def xml_report_name = "deploy_salt.xml" |
| 271 | try { |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 272 | // deploy_salt.xmli |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 273 | shared.run_sh("""\ |
| 274 | export ENV_NAME=${ENV_NAME} |
| 275 | export LAB_CONFIG_NAME=${LAB_CONFIG_NAME} |
| 276 | export LAB_PARAM_DEFAULTS=${LAB_PARAM_DEFAULTS} |
| 277 | export ENV_MANAGER=heat |
| 278 | export SHUTDOWN_ENV_ON_TEARDOWN=false |
| 279 | export BOOTSTRAP_TIMEOUT=3600 |
| 280 | export PYTHONIOENCODING=UTF-8 |
| 281 | export REPOSITORY_SUITE=${MCP_VERSION} |
| 282 | export UPDATE_VERSION=${UPDATE_VERSION} |
| 283 | export TEST_GROUP=test_bootstrap_salt |
| 284 | export LOG_NAME=swarm_test_bootstrap_salt.log |
| 285 | py.test -vvv -s -p no:django -p no:ipdb --junit-xml=${xml_report_name} -k \${TEST_GROUP} |
| 286 | """) |
| 287 | // Wait for jenkins to start and IO calm down |
| 288 | sleep(60) |
| 289 | |
| 290 | } catch (e) { |
| 291 | common.printMsg("Saltstack cluster deploy is failed", "purple") |
| 292 | if (fileExists(xml_report_name)) { |
| 293 | shared.download_logs("deploy_salt_${ENV_NAME}") |
| 294 | def String junit_report_xml = readFile(xml_report_name) |
| 295 | def String junit_report_xml_pretty = new XmlUtil().serialize(junit_report_xml) |
| 296 | throw new Exception(junit_report_xml_pretty) |
| 297 | } else { |
| 298 | throw e |
| 299 | } |
Pavel Glazov | 6bd42c6 | 2022-09-23 01:07:18 +0400 | [diff] [blame] | 300 | } // finally { |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 301 | // TODO(ddmitriev): add checks for salt cluster |
Pavel Glazov | 6bd42c6 | 2022-09-23 01:07:18 +0400 | [diff] [blame] | 302 | // } |
Hanna Arhipova | 6736dab | 2020-05-07 14:33:35 +0300 | [diff] [blame] | 303 | } // stage |
| 304 | } // withCredentials |
| 305 | } // dir |
| 306 | } // node |
| 307 | } // timestamps |
Dennis Dmitriev | 1f08b0c | 2019-05-27 17:03:53 +0300 | [diff] [blame] | 308 | } // timeout |