blob: c7697b9ed255adea8b8fdbf6aef6d46ca8a25fdb [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 }
Anna Arhipovac13051d2022-12-03 10:40:50 +010059 stage("Archive all xml reports") {
60 dir("${env.slave_workdir }") {
61 archiveArtifacts artifacts: "**/*.xml,**/*.log"
Hanna Arhipova4759ae42021-01-11 12:48:14 +020062 }
63 }
Anna Arhipovac13051d2022-12-03 10:40:50 +010064 stage("report results to testrail from jenkins master") {
65 if ("${env.REPORT_TO_TESTRAIL}" != "false") {
66 common.infoMsg("Running on: " + env.PARENT_NODE_NAME, "blue")
67 shared.swarm_testrail_report(steps, env.PARENT_NODE_NAME)
68 } else {
69 common.infoMsg("REPORT_TO_TESTRAIL is set to FALSE. Skipped this step ")
70 }
71 } // stage("report results to testrail from jenkins master")
72 stage("Store TestRail reports to job description") {
73 if ("${env.REPORT_TO_TESTRAIL}" != "false") {
74 if (fileExists("description.txt")) {
75 def String description = readFile("description.txt")
76 currentBuild.description += "${description}"
77 }
78 } else {
79 common.infoMsg("REPORT_TO_TESTRAIL is set to FALSE. Skipped this step ")
80 println(currentBuild.result)
81 }
82 } // stage("Store TestRail reports to job description")
Hanna Arhipova4759ae42021-01-11 12:48:14 +020083 } // dir
84 } // node
Anna Arhipovac13051d2022-12-03 10:40:50 +010085} // timeout