blob: 408bc140ffc3d4af407892acb1851f434df0a6e5 [file] [log] [blame]
Dennis Dmitrievfde667f2018-07-23 16:26:50 +03001/**
2 *
3 * Deploy the product cluster using Jenkins master on CICD cluster
4 *
5 * Expected parameters:
6
7 * ENV_NAME Fuel-devops environment name
8 * PASSED_STEPS Steps passed to install components using Jenkins on CICD cluster: "salt,core,cicd,openstack:3200,stacklight:2400",
9 where 3200 and 2400 might be timeouts (not used in the testing pipeline)
10 * RUN_TEST_OPTS Pytest option -k or -m, with expression to select necessary tests. Additional pytest options are allowed.
11 * PARENT_NODE_NAME Name of the jenkins slave to create the environment
12 * PARENT_WORKSPACE Path to the workspace of the parent job to use tcp-qa repo
13 * TCP_QA_REFS Reference to the tcp-qa change on review.gerrithub.io, like refs/changes/46/418546/41
14 * SHUTDOWN_ENV_ON_TEARDOWN optional, shutdown fuel-devops environment at the end of the job
15 * LAB_CONFIG_NAME Not used (backward compatibility, for manual deployment steps only)
16 * REPOSITORY_SUITE Not used (backward compatibility, for manual deployment steps only)
17 * MCP_IMAGE_PATH1604 Not used (backward compatibility, for manual deployment steps only)
18 * IMAGE_PATH_CFG01_DAY01 Not used (backward compatibility, for manual deployment steps only)
Tatyana Leontovichf3718442018-10-31 13:36:13 +020019 * TEMPEST_IMAGE_VERSION Tempest image version: pike by default, can be queens.
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030020 */
21
22@Library('tcp-qa')_
23
24common = new com.mirantis.mk.Common()
25shared = new com.mirantis.system_qa.SharedPipeline()
26
27if (! env.PARENT_NODE_NAME) {
28 error "'PARENT_NODE_NAME' must be set from the parent deployment job!"
29}
30
Dennis Dmitriev201a35e2018-08-06 01:37:05 +030031currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
32
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030033node ("${PARENT_NODE_NAME}") {
34 if (! fileExists("${PARENT_WORKSPACE}")) {
35 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
36 }
37 dir("${PARENT_WORKSPACE}") {
38 try {
39
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030040 if (env.TCP_QA_REFS) {
41 stage("Update working dir to patch ${TCP_QA_REFS}") {
42 shared.update_working_dir()
43 }
44 }
45
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030046 stage("Run tests") {
47 def steps = shared.get_steps_list(PASSED_STEPS)
48 def sources = """\
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030049 cd ${PARENT_WORKSPACE}
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030050 export ENV_NAME=${ENV_NAME}
51 . ./tcp_tests/utils/env_salt"""
52 if (steps.contains('k8s')) {
53 sources += """
54 . ./tcp_tests/utils/env_k8s\n"""
55 }
56 if (steps.contains('openstack')) {
57 sources += """
Tatyana Leontovichf3718442018-10-31 13:36:13 +020058 export TEMPEST_IMAGE_VERSION=${TEMPEST_IMAGE_VERSION}
Tatyana Leontovichab8c3e02019-01-16 21:17:11 +020059 export TEMPEST_TARGET=${TEMPEST_TARGET}
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030060 # TODO: . ./tcp_tests/utils/env_keystonercv3\n"""
61 }
62 def installed = steps.collect {"""\
63 export ${it}_installed=true"""}.join("\n")
64
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030065 shared.run_sh(sources + installed + """
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030066 export TESTS_CONFIGS=${ENV_NAME}_salt_deployed.ini
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030067 export MANAGER=devops # use 'hardware' fixture to manage fuel-devops environment
68 export salt_master_host=\$SALT_MASTER_IP # skip salt_deployed fixture
69 export salt_master_port=6969
70 export SALT_USER=\$SALTAPI_USER
71 export SALT_PASSWORD=\$SALTAPI_PASS
72
73 py.test --junit-xml=nosetests.xml ${RUN_TEST_OPTS}
74
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030075 """)
Dennis Dmitrievb08c0772018-10-17 15:10:26 +030076
77 def snapshot_name = "test_completed"
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030078 shared.download_logs("test_completed")
Dennis Dmitrievb08c0772018-10-17 15:10:26 +030079 shared.run_cmd("""\
80 dos.py suspend ${ENV_NAME}
81 dos.py snapshot ${ENV_NAME} ${snapshot_name}
82 """)
83 if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "false") {
84 shared.run_cmd("""\
85 dos.py resume ${ENV_NAME}
86 """)
87 }
88 shared.devops_snapshot_info(snapshot_name)
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030089 }
90
91 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +030092 common.printMsg("Job is failed", "purple")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030093 // Downloading logs usually not needed here
94 // because tests should use the decorator @pytest.mark.grab_versions
95 // shared.download_logs("test_failed")
Dennis Dmitrievfde667f2018-07-23 16:26:50 +030096 throw e
97 } finally {
98 // TODO(ddmitriev): analyze the "def currentResult = currentBuild.result ?: 'SUCCESS'"
99 // and report appropriate data to TestRail
100 if ("${env.SHUTDOWN_ENV_ON_TEARDOWN}" == "true") {
101 shared.run_cmd("""\
102 dos.py destroy ${ENV_NAME}
103 """)
104 }
105 }
106 }
107}