blob: 067ddffdde573268b3374713006925dfb93356ab [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
Tatyana Leontovichf3718442018-10-31 13:36:13 +020013 * TEMPEST_TEST_SUITE_NAME Name of tempest suite
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030014 * TCP_QA_REFS Reference to the tcp-qa change on review.gerrithub.io, like refs/changes/46/418546/41
15 */
16
17@Library('tcp-qa')_
18
19def common = new com.mirantis.mk.Common()
20def shared = new com.mirantis.system_qa.SharedPipeline()
21def stacks = shared.get_steps_list(PASSED_STEPS)
22
23if (! env.PARENT_NODE_NAME) {
24 error "'PARENT_NODE_NAME' must be set from the parent deployment job!"
25}
26
27currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
28
Dennis Dmitriev1f08b0c2019-05-27 17:03:53 +030029timeout(time: 2, unit: 'HOURS') {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030030node ("${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}") {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030035 def description = ''
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030036 def exception_message = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030037 try {
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030038
39 if (env.TCP_QA_REFS) {
40 stage("Update working dir to patch ${TCP_QA_REFS}") {
41 shared.update_working_dir()
42 }
43 }
44
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030045 def report_name = ''
46 def testSuiteName = ''
47 def methodname = ''
48 def testrail_name_template = ''
49 def reporter_extra_options = []
50
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030051 def report_url = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030052
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020053 // deployment_report_name = "deployment_${ENV_NAME}.xml"
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020054 def deployment_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"deployment_${ENV_NAME}.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020055 // tcpqa_report_name =~ "nosetests.xml"
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020056 def tcpqa_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"nosetests.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020057 // tempest_report_name =~ "report_*.xml"
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020058 def tempest_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"report_*.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020059 // k8s_conformance_report_name =~ conformance_result.xml
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020060 def k8s_conformance_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_result.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitriev34fd3002018-11-15 18:25:16 +020061 // k8s_conformance_report_name =~ conformance_virtlet_result.xml
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020062 def k8s_conformance_virtlet_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_virtlet_result.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020063 // stacklight_report_name =~ "stacklight_report.xml" or "report.xml"
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020064 def stacklight_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"*report.xml\"", returnStdout: true).trim()
Dennis Dmitriev8565c342019-02-11 23:45:03 +020065 // cvp_sanity_report_name =~ cvp_sanity_report.xml
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020066 def cvp_sanity_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"cvp_sanity_results.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030067 common.printMsg(deployment_report_name ? "Found deployment report: ${deployment_report_name}" : "Deployment report not found", deployment_report_name ? "blue" : "red")
68 common.printMsg(tcpqa_report_name ? "Found tcp-qa report: ${tcpqa_report_name}" : "tcp-qa report not found", tcpqa_report_name ? "blue" : "red")
69 common.printMsg(tempest_report_name ? "Found tempest report: ${tempest_report_name}" : "tempest report not found", tempest_report_name ? "blue" : "red")
70 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")
Dennis Dmitriev34fd3002018-11-15 18:25:16 +020071 common.printMsg(k8s_conformance_virtlet_report_name ? "Found k8s conformance virtlet report: ${k8s_conformance_virtlet_report_name}" : "k8s conformance virtlet report not found", k8s_conformance_virtlet_report_name ? "blue" : "red")
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030072 common.printMsg(stacklight_report_name ? "Found stacklight-pytest report: ${stacklight_report_name}" : "stacklight-pytest report not found", stacklight_report_name ? "blue" : "red")
Dennis Dmitriev8565c342019-02-11 23:45:03 +020073 common.printMsg(cvp_sanity_report_name ? "Found CVP Sanity report: ${cvp_sanity_report_name}" : "CVP Sanity report not found", cvp_sanity_report_name ? "blue" : "red")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030074
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030075
76 if (deployment_report_name) {
77 stage("Deployment report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030078 testSuiteName = "[MCP] Integration automation"
79 methodname = '{methodname}'
80 testrail_name_template = '{title}'
81 reporter_extra_options = [
82 "--testrail-add-missing-cases",
Ekaterina Chernova0d81efc2019-10-28 16:23:17 +030083 "--testrail_configuration_name tcp-qa",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030084 ]
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030085 ret = shared.upload_results_to_testrail(deployment_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
86 common.printMsg(ret.stdout, "blue")
87 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030088 if (it.contains("[TestRun URL]")) {
89 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +030090 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030091 }
92 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030093 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030094 }
95 }
96
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030097 if (tcpqa_report_name) {
98 stage("tcp-qa cases report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030099 testSuiteName = "[MCP_X] integration cases"
100 methodname = "{methodname}"
101 testrail_name_template = "{title}"
102 reporter_extra_options = [
103 "--testrail-add-missing-cases",
Ekaterina Chernova0d81efc2019-10-28 16:23:17 +0300104 "--testrail_configuration_name tcp-qa",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300105 ]
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300106 ret = shared.upload_results_to_testrail(tcpqa_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
107 common.printMsg(ret.stdout, "blue")
108 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300109 if (it.contains("[TestRun URL]")) {
110 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300111 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300112 }
113 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300114 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300115 }
116 }
117
118 if ('openstack' in stacks && tempest_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300119 stage("Tempest report") {
Tatyana Leontovichf3718442018-10-31 13:36:13 +0200120 testSuiteName = env.TEMPEST_TEST_SUITE_NAME
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300121 methodname = "{classname}.{methodname}"
122 testrail_name_template = "{title}"
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300123 reporter_extra_options = [
124 "--send-duplicates",
125 "--testrail-add-missing-cases",
Ekaterina Chernova0d81efc2019-10-28 16:23:17 +0300126 "--testrail_configuration_name tcp-qa",
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300127 ]
128 ret = shared.upload_results_to_testrail(tempest_report_name,
129 testSuiteName,
130 methodname,
131 testrail_name_template,
132 reporter_extra_options)
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300133 common.printMsg(ret.stdout, "blue")
134 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300135 if (it.contains("[TestRun URL]")) {
136 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300137 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300138 }
139 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300140 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300141 }
142 }
143
144 if ('k8s' in stacks && k8s_conformance_report_name) {
145 stage("K8s conformance report") {
Dennis Dmitriev265a1c72018-09-29 05:08:47 +0300146 def k8s_version=shared.run_cmd_stdout("""\
Dennis Dmitrievcf866e72018-10-09 17:51:43 +0300147 . ./env_k8s_version;
148 echo "\$KUBE_SERVER_VERSION"
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300149 """).trim().split().last()
150 testSuiteName = "[MCP][k8s]Hyperkube ${k8s_version}.x"
151 methodname = "{methodname}"
152 testrail_name_template = "{title}"
153 reporter_extra_options = [
Dennis Dmitriev74d7e752018-10-01 17:37:49 +0300154 "--send-duplicates",
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300155 "--testrail-add-missing-cases",
156 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
157 "--testrail-case-section-name \'Conformance\'",
158 ]
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300159 ret = shared.upload_results_to_testrail(k8s_conformance_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
160 common.printMsg(ret.stdout, "blue")
161 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300162 if (it.contains("[TestRun URL]")) {
163 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300164 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300165 }
166 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300167 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300168 }
169 }
170
Dennis Dmitriev34fd3002018-11-15 18:25:16 +0200171 if ('k8s' in stacks && k8s_conformance_virtlet_report_name) {
172 stage("K8s conformance virtlet report") {
173 testSuiteName = "[k8s] Virtlet"
174 methodname = "{methodname}"
175 testrail_name_template = "{title}"
176 reporter_extra_options = [
177 "--send-duplicates",
178 "--testrail-add-missing-cases",
179 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
180 "--testrail-case-section-name \'Conformance\'",
181 ]
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300182 ret = shared.upload_results_to_testrail(k8s_conformance_virtlet_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
183 common.printMsg(ret.stdout, "blue")
184 report_url = ret.stdout.split("\n").each {
Dennis Dmitriev34fd3002018-11-15 18:25:16 +0200185 if (it.contains("[TestRun URL]")) {
186 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300187 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitriev34fd3002018-11-15 18:25:16 +0200188 }
189 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300190 exception_message += ret.exception
Dennis Dmitriev34fd3002018-11-15 18:25:16 +0200191 }
192 }
193
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300194 if ('stacklight' in stacks && stacklight_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300195 stage("stacklight-pytest report") {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300196 testSuiteName = "LMA2.0_Automated"
197 methodname = "{methodname}"
198 testrail_name_template = "{title}"
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300199 ret = shared.upload_results_to_testrail(stacklight_report_name, testSuiteName, methodname, testrail_name_template)
200 common.printMsg(ret.stdout, "blue")
201 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300202 if (it.contains("[TestRun URL]")) {
203 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300204 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300205 }
206 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300207 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300208 }
209 }
210
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200211 if ('cicd' in stacks && cvp_sanity_report_name) {
212 stage("CVP Sanity report") {
213 testSuiteName = "[MCP] cvp sanity"
214 methodname = '{methodname}'
215 testrail_name_template = '{title}'
216 reporter_extra_options = [
217 "--send-duplicates",
218 "--testrail-add-missing-cases",
Ekaterina Chernova0d81efc2019-10-28 16:23:17 +0300219 "--testrail_configuration_name tcp-qa",
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200220 ]
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300221 ret = shared.upload_results_to_testrail(cvp_sanity_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
222 common.printMsg(ret.stdout, "blue")
223 report_url = ret.stdout.split("\n").each {
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200224 if (it.contains("[TestRun URL]")) {
225 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300226 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200227 }
228 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300229 exception_message += ret.exception
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200230 }
231 }
232
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300233 // Check if there were any exceptions during reporting
234 if (exception_message) {
235 throw new Exception(exception_message)
236 }
237
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300238 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300239 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300240 throw e
241 } finally {
242 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300243 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300244 }
245 }
246}
Dennis Dmitriev1f08b0c2019-05-27 17:03:53 +0300247} // timeout