blob: 93995106dbb67305ebd9afecb69767ed38432512 [file] [log] [blame]
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +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 * MCP_VERSION MCP version, like 2018.4 or proposed
9 * PASSED_STEPS Steps passed to install components using Jenkins on CICD cluster: "salt,core,cicd,openstack:3200,stacklight:2400",
10 where 3200 and 2400 might be timeouts (not used in the testing pipeline)
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 */
15
16@Library('tcp-qa')_
17
18def common = new com.mirantis.mk.Common()
19def shared = new com.mirantis.system_qa.SharedPipeline()
20def stacks = shared.get_steps_list(PASSED_STEPS)
21
22if (! env.PARENT_NODE_NAME) {
23 error "'PARENT_NODE_NAME' must be set from the parent deployment job!"
24}
25
26currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
27
28node ("${PARENT_NODE_NAME}") {
29 if (! fileExists("${PARENT_WORKSPACE}")) {
30 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
31 }
32 dir("${PARENT_WORKSPACE}") {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030033 def description = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030034 try {
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030035
36 if (env.TCP_QA_REFS) {
37 stage("Update working dir to patch ${TCP_QA_REFS}") {
38 shared.update_working_dir()
39 }
40 }
41
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030042 def report_name = ''
43 def testSuiteName = ''
44 def methodname = ''
45 def testrail_name_template = ''
46 def reporter_extra_options = []
47
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030048 def report_result = ''
49 def report_url = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030050
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020051 // deployment_report_name = "deployment_${ENV_NAME}.xml"
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030052 def deployment_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"deployment_${ENV_NAME}.xml\"", returnStdout: true)
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020053 // tcpqa_report_name =~ "nosetests.xml"
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030054 def tcpqa_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"nosetests.xml\"", returnStdout: true)
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020055 // tempest_report_name =~ "report_*.xml"
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030056 def tempest_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"report_*.xml\"", returnStdout: true)
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020057 // k8s_conformance_report_name =~ conformance_result.xml
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030058 def k8s_conformance_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_result.xml\"", returnStdout: true)
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020059 // stacklight_report_name =~ "stacklight_report.xml" or "report.xml"
60 def stacklight_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"*report.xml\"", returnStdout: true)
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030061 common.printMsg(deployment_report_name ? "Found deployment report: ${deployment_report_name}" : "Deployment report not found", deployment_report_name ? "blue" : "red")
62 common.printMsg(tcpqa_report_name ? "Found tcp-qa report: ${tcpqa_report_name}" : "tcp-qa report not found", tcpqa_report_name ? "blue" : "red")
63 common.printMsg(tempest_report_name ? "Found tempest report: ${tempest_report_name}" : "tempest report not found", tempest_report_name ? "blue" : "red")
64 common.printMsg(k8s_conformance_report_name ? "Found k8s conformance report: ${k8s_conformance_report_name}" : "k8s conformance report not found", k8s_conformance_report_name ? "blue" : "red")
65 common.printMsg(stacklight_report_name ? "Found stacklight-pytest report: ${stacklight_report_name}" : "stacklight-pytest report not found", stacklight_report_name ? "blue" : "red")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030066
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030067
68 if (deployment_report_name) {
69 stage("Deployment report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030070 testSuiteName = "[MCP] Integration automation"
71 methodname = '{methodname}'
72 testrail_name_template = '{title}'
73 reporter_extra_options = [
74 "--testrail-add-missing-cases",
75 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
76 "--testrail-case-section-name \'All\'",
77 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030078 report_result = shared.upload_results_to_testrail(deployment_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
79 common.printMsg(report_result, "blue")
80 report_url = report_result.split("\n").each {
81 if (it.contains("[TestRun URL]")) {
82 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030083 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030084 }
85 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030086 }
87 }
88
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030089 if (tcpqa_report_name) {
90 stage("tcp-qa cases report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030091 testSuiteName = "[MCP_X] integration cases"
92 methodname = "{methodname}"
93 testrail_name_template = "{title}"
94 reporter_extra_options = [
95 "--testrail-add-missing-cases",
96 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
97 "--testrail-case-section-name \'All\'",
98 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030099 report_result = shared.upload_results_to_testrail(tcpqa_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
100 common.printMsg(report_result, "blue")
101 report_url = report_result.split("\n").each {
102 if (it.contains("[TestRun URL]")) {
103 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300104 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300105 }
106 }
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300107 }
108 }
109
110 if ('openstack' in stacks && tempest_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300111 stage("Tempest report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300112 testSuiteName = "[MCP1.1_PIKE]Tempest"
113 methodname = "{classname}.{methodname}"
114 testrail_name_template = "{title}"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300115 report_result = shared.upload_results_to_testrail(tempest_report_name, testSuiteName, methodname, testrail_name_template)
116 common.printMsg(report_result, "blue")
117 report_url = report_result.split("\n").each {
118 if (it.contains("[TestRun URL]")) {
119 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300120 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300121 }
122 }
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300123 }
124 }
125
126 if ('k8s' in stacks && k8s_conformance_report_name) {
127 stage("K8s conformance report") {
Dennis Dmitriev265a1c72018-09-29 05:08:47 +0300128 def k8s_version=shared.run_cmd_stdout("""\
Dennis Dmitrievcf866e72018-10-09 17:51:43 +0300129 . ./env_k8s_version;
130 echo "\$KUBE_SERVER_VERSION"
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300131 """).trim().split().last()
132 testSuiteName = "[MCP][k8s]Hyperkube ${k8s_version}.x"
133 methodname = "{methodname}"
134 testrail_name_template = "{title}"
135 reporter_extra_options = [
Dennis Dmitriev74d7e752018-10-01 17:37:49 +0300136 "--send-duplicates",
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300137 "--testrail-add-missing-cases",
138 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
139 "--testrail-case-section-name \'Conformance\'",
140 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300141 report_result = shared.upload_results_to_testrail(k8s_conformance_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
142 common.printMsg(report_result, "blue")
143 report_url = report_result.split("\n").each {
144 if (it.contains("[TestRun URL]")) {
145 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300146 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300147 }
148 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300149 }
150 }
151
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300152 if ('stacklight' in stacks && stacklight_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300153 stage("stacklight-pytest report") {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300154 testSuiteName = "LMA2.0_Automated"
155 methodname = "{methodname}"
156 testrail_name_template = "{title}"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300157 report_result = shared.upload_results_to_testrail(stacklight_report_name, testSuiteName, methodname, testrail_name_template)
158 common.printMsg(report_result, "blue")
159 report_url = report_result.split("\n").each {
160 if (it.contains("[TestRun URL]")) {
161 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300162 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300163 }
164 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300165 }
166 }
167
168 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300169 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300170 throw e
171 } finally {
172 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300173 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300174 }
175 }
176}