blob: b83dceccda313456469fb48180bbd2fc067959df [file] [log] [blame]
Hanna Arhipova4759ae42021-01-11 12:48:14 +02001/**
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 Gerrit, like refs/changes/46/418546/41
14 * SHUTDOWN_ENV_ON_TEARDOWN optional, shutdown fuel-devops environment at the end of the job
15 * TEMPEST_IMAGE_VERSION Tempest image version: pike by default, can be queens.
16 * TEMPEST_TARGET Node where tempest will be run
17 * MAKE_SNAPSHOT_STAGES optional, use "dos.py snapshot" to snapshot stages
18 */
19
20@Library('tcp-qa')_
21
22def common = new com.mirantis.mk.Common()
23def shared = new com.mirantis.system_qa.SharedPipeline()
24
25def steps = env.PASSED_STEPS
26def make_snapshot_stages = false
Hanna Arhipovaae83dd92021-03-10 12:11:21 +020027env.LAB_CONFIG_NAME = env.LAB_CONFIG_NAME ?: env.ENV_NAME
PGlazov560be2c2021-10-18 20:43:58 +040028env.TEST_PLAN_NAME_PREFIX = '[2019.2.0-update]Upgraded'
Hanna Arhipova4759ae42021-01-11 12:48:14 +020029
30timeout(time: 23, unit: 'HOURS') {
31 node ("${PARENT_NODE_NAME}") {
32 if (! fileExists("${PARENT_WORKSPACE}")) {
33 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
34 }
35 dir("${PARENT_WORKSPACE}") {
36 env.slave_workdir = pwd()
37 if (env.TCP_QA_REFS) {
38 stage("Update working dir to patch ${TCP_QA_REFS}") {
39 shared.update_working_dir()
40 }
41 }
42
43 stage("Run tests") {
44 try {
45 if (env.RUN_TEST_OPTS) {
46 shared.swarm_run_pytest(steps, "${PARENT_NODE_NAME}", make_snapshot_stages)
47 } else {
dtsapikovdc593a32021-06-30 13:18:10 +040048 common.infoMsg("RUN_TEST_OPTS is empty, skipping 'swarm-run-pytest' job", "green")
Hanna Arhipova4759ae42021-01-11 12:48:14 +020049 }
50 } catch (e) {
dtsapikovdc593a32021-06-30 13:18:10 +040051 common.infoMsg("Tests are failed: " + e.message, "purple")
Hanna Arhipovae92b66b2021-04-15 19:56:30 +030052 currentBuild.result = 'FAILURE'
Hanna Arhipova4759ae42021-01-11 12:48:14 +020053 }
54 } // stage("Run tests")
dtsapikovd1d6fe82021-11-19 17:45:06 +040055 if (fileExists("jenkins_agent_description.txt")) {
56 def String description = readFile("jenkins_agent_description.txt")
57 currentBuild.description = "${description}"
58 }
59 if (currentBuild.result != 'FAILURE') {
PGlazov560be2c2021-10-18 20:43:58 +040060 stage("Archive all xml reports") {
61 dir("${env.slave_workdir }") {
62 archiveArtifacts artifacts: "**/*.xml,**/*.log"
63 }
64 }
65 stage("report results to testrail from jenkins master") {
66 if ("${env.REPORT_TO_TESTRAIL}" != "false") {
67 common.infoMsg("Running on: " + env.PARENT_NODE_NAME, "blue")
PGlazov560be2c2021-10-18 20:43:58 +040068 shared.swarm_testrail_report(steps, env.PARENT_NODE_NAME)
69 } else {
70 common.infoMsg("REPORT_TO_TESTRAIL is set to FALSE. Skipped this step ")
Hanna Arhipova4759ae42021-01-11 12:48:14 +020071 }
PGlazov560be2c2021-10-18 20:43:58 +040072 } // stage("report results to testrail from jenkins master")
73 stage("Store TestRail reports to job description") {
74 if ("${env.REPORT_TO_TESTRAIL}" != "false") {
75 if (fileExists("description.txt")) {
76 def String description = readFile("description.txt")
77 currentBuild.description += "${description}"
78 }
79 } else {
80 common.infoMsg("REPORT_TO_TESTRAIL is set to FALSE. Skipped this step ")
81 println(currentBuild.result)
82 }
83 } // stage("Store TestRail reports to job description")
84 }//report if success
85 else{
86 common.infoMsg("Upgrade status different from successful. Skipped report steps.")
87 println("Current result is " + currentBuild.result)
Hanna Arhipova4759ae42021-01-11 12:48:14 +020088 }
Hanna Arhipova4759ae42021-01-11 12:48:14 +020089 } // dir
90 } // node
91} // timeout