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