blob: 31aff06a2d849ca94b998d6a70e5d5db172fbe0f [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
Hanna Arhipova4759ae42021-01-11 12:48:14 +020028
29timeout(time: 23, unit: 'HOURS') {
30 node ("${PARENT_NODE_NAME}") {
31 if (! fileExists("${PARENT_WORKSPACE}")) {
32 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
33 }
34 dir("${PARENT_WORKSPACE}") {
35 env.slave_workdir = pwd()
36 if (env.TCP_QA_REFS) {
37 stage("Update working dir to patch ${TCP_QA_REFS}") {
38 shared.update_working_dir()
39 }
40 }
41
42 stage("Run tests") {
43 try {
44 if (env.RUN_TEST_OPTS) {
45 shared.swarm_run_pytest(steps, "${PARENT_NODE_NAME}", make_snapshot_stages)
46 } else {
47 common.printMsg("RUN_TEST_OPTS is empty, skipping 'swarm-run-pytest' job", "green")
48 }
49 } catch (e) {
50 common.printMsg("Tests are failed: " + e.message, "purple")
Hanna Arhipovae92b66b2021-04-15 19:56:30 +030051 currentBuild.result = 'FAILURE'
Hanna Arhipova4759ae42021-01-11 12:48:14 +020052 }
53 } // stage("Run tests")
54
55 stage("Archive all xml reports") {
56 dir("${env.slave_workdir }") {
Hanna Arhipovae92b66b2021-04-15 19:56:30 +030057 archiveArtifacts artifacts: "**/*.xml,**/*.log"
Hanna Arhipova4759ae42021-01-11 12:48:14 +020058 }
59 }
60
61 stage("report results to testrail from jenkins master") {
62 if ("${env.REPORT_TO_TESTRAIL}" != "false") {
63 common.printMsg("Running on: " + env.PARENT_NODE_NAME, "blue")
64 shared.verbose_sh("""\
65 [ -d /home/jenkins/venv_testrail_reporter ] || virtualenv --python=python3.7 /home/jenkins/venv_testrail_reporter""", true, false, true)
66 shared.run_cmd("""\
67 . /home/jenkins/venv_testrail_reporter/bin/activate; pip install git+https://github.com/dis-xcom/testrail_reporter -U""")
68 shared.swarm_testrail_report(steps, env.PARENT_NODE_NAME)
69 } else {
70 common.printMsg("REPORT_TO_TESTRAIL is set to FALSE. Skipped this step ")
71 }
72 } // 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.printMsg("REPORT_TO_TESTRAIL is set to FALSE. Skipped this step ")
81 }
82 } // stage("Store TestRail reports to job description")
83 } // dir
84 } // node
85} // timeout