blob: 17b770f29502107711df3d661725738dbdeddedc [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
Hanna Arhipova5173aad2019-11-11 12:42:31 +020014 * TCP_QA_REFS Reference to the tcp-qa change on Gerrit, like refs/changes/46/418546/41
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030015 */
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
Hanna Arhipova705a2892020-09-25 12:40:39 +030029def find_latest(search_pattern) {
30 return "find ${PARENT_WORKSPACE} -name \"${search_pattern}\" -printf \"'%T@ %p \\n'\" | sort -r |head -n1|awk -F' ' '{ print \$2 }'"
31}
32
Dennis Dmitriev1f08b0c2019-05-27 17:03:53 +030033timeout(time: 2, unit: 'HOURS') {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030034node ("${PARENT_NODE_NAME}") {
35 if (! fileExists("${PARENT_WORKSPACE}")) {
36 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
37 }
38 dir("${PARENT_WORKSPACE}") {
Hanna Arhipova705a2892020-09-25 12:40:39 +030039 if (env.REPORT_FILE_URL) {
40 print "Download report from '${env.REPORT_FILE_URL}'"
41 file_text = new URL ("${env.REPORT_FILE_URL}").getText()
42 print "Copy downloaded file to workspace as ${REPORT_FILE_NAME}"
43 writeFile file: "${REPORT_FILE_NAME}", text: file_text
44 }
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030045 def description = ''
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030046 def exception_message = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030047 try {
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030048
49 if (env.TCP_QA_REFS) {
50 stage("Update working dir to patch ${TCP_QA_REFS}") {
51 shared.update_working_dir()
52 }
53 }
54
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030055 def report_name = ''
56 def testSuiteName = ''
57 def methodname = ''
58 def testrail_name_template = ''
59 def reporter_extra_options = []
60
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030061 def report_url = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030062
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020063 // deployment_report_name = "deployment_${ENV_NAME}.xml"
Hanna Arhipova705a2892020-09-25 12:40:39 +030064 def deployment_report_name = sh(script: find_latest("deployment_${ENV_NAME}.xml"), returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020065 // tcpqa_report_name =~ "nosetests.xml"
Hanna Arhipova705a2892020-09-25 12:40:39 +030066 def tcpqa_report_name = sh(script: find_latest("nosetests.xml"), returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020067 // tempest_report_name =~ "report_*.xml"
Hanna Arhipova705a2892020-09-25 12:40:39 +030068 def tempest_report_name = sh(script: find_latest("report_*.xml"), returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020069 // stacklight_report_name =~ "stacklight_report.xml" or "report.xml"
Hanna Arhipova705a2892020-09-25 12:40:39 +030070 def stacklight_report_name = sh(script: find_latest("*report.xml"), returnStdout: true).trim()
Dennis Dmitriev8565c342019-02-11 23:45:03 +020071 // cvp_sanity_report_name =~ cvp_sanity_report.xml
Hanna Arhipova705a2892020-09-25 12:40:39 +030072 def cvp_sanity_report_name = sh(script: find_latest("cvp_sanity_results.xml"), returnStdout: true).trim()
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030073 common.printMsg(deployment_report_name ? "Found deployment report: ${deployment_report_name}" : "Deployment report not found", deployment_report_name ? "blue" : "red")
74 common.printMsg(tcpqa_report_name ? "Found tcp-qa report: ${tcpqa_report_name}" : "tcp-qa report not found", tcpqa_report_name ? "blue" : "red")
75 common.printMsg(tempest_report_name ? "Found tempest report: ${tempest_report_name}" : "tempest report not found", tempest_report_name ? "blue" : "red")
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030076 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 +020077 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 +030078
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030079
80 if (deployment_report_name) {
81 stage("Deployment report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030082 testSuiteName = "[MCP] Integration automation"
83 methodname = '{methodname}'
84 testrail_name_template = '{title}'
85 reporter_extra_options = [
86 "--testrail-add-missing-cases",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030087 ]
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030088 ret = shared.upload_results_to_testrail(deployment_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
89 common.printMsg(ret.stdout, "blue")
90 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030091 if (it.contains("[TestRun URL]")) {
92 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +030093 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030094 }
95 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030096 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030097 }
98 }
99
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300100 if (tcpqa_report_name) {
101 stage("tcp-qa cases report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300102 testSuiteName = "[MCP_X] integration cases"
103 methodname = "{methodname}"
104 testrail_name_template = "{title}"
105 reporter_extra_options = [
106 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200107// "--testrail_configuration_name tcp-qa",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300108 ]
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300109 ret = shared.upload_results_to_testrail(tcpqa_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
110 common.printMsg(ret.stdout, "blue")
111 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300112 if (it.contains("[TestRun URL]")) {
113 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300114 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300115 }
116 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300117 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300118 }
119 }
120
121 if ('openstack' in stacks && tempest_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300122 stage("Tempest report") {
Tatyana Leontovichf3718442018-10-31 13:36:13 +0200123 testSuiteName = env.TEMPEST_TEST_SUITE_NAME
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300124 methodname = "{classname}.{methodname}"
125 testrail_name_template = "{title}"
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300126 reporter_extra_options = [
127 "--send-duplicates",
128 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200129// "--testrail_configuration_name tcp-qa",
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300130 ]
131 ret = shared.upload_results_to_testrail(tempest_report_name,
132 testSuiteName,
133 methodname,
134 testrail_name_template,
135 reporter_extra_options)
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300136 common.printMsg(ret.stdout, "blue")
137 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300138 if (it.contains("[TestRun URL]")) {
139 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300140 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300141 }
142 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300143 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300144 }
145 }
146
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300147 if ('stacklight' in stacks && stacklight_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300148 stage("stacklight-pytest report") {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300149 testSuiteName = "LMA2.0_Automated"
150 methodname = "{methodname}"
151 testrail_name_template = "{title}"
Hanna Arhipova40955d72019-11-04 14:38:42 +0200152 reporter_extra_options = [
153 "--testrail-add-missing-cases",
154 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
155 ]
156 ret = shared.upload_results_to_testrail(stacklight_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300157 common.printMsg(ret.stdout, "blue")
158 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300159 if (it.contains("[TestRun URL]")) {
160 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300161 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300162 }
163 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300164 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300165 }
166 }
167
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200168 if ('cicd' in stacks && cvp_sanity_report_name) {
169 stage("CVP Sanity report") {
170 testSuiteName = "[MCP] cvp sanity"
171 methodname = '{methodname}'
172 testrail_name_template = '{title}'
173 reporter_extra_options = [
174 "--send-duplicates",
175 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200176// "--testrail_configuration_name tcp-qa",
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200177 ]
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300178 ret = shared.upload_results_to_testrail(cvp_sanity_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
179 common.printMsg(ret.stdout, "blue")
180 report_url = ret.stdout.split("\n").each {
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200181 if (it.contains("[TestRun URL]")) {
182 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300183 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200184 }
185 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300186 exception_message += ret.exception
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200187 }
188 }
189
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300190 // Check if there were any exceptions during reporting
191 if (exception_message) {
192 throw new Exception(exception_message)
193 }
194
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300195 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300196 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300197 throw e
198 } finally {
199 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300200 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300201 }
202 }
203}
Dennis Dmitriev1f08b0c2019-05-27 17:03:53 +0300204} // timeout