blob: f9820f8add371dc2a29c93aa1a942301d52253d7 [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)
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +030022def testPlanNamePrefix = env.TEST_PLAN_NAME_PREFIX ?: "[2019.2.0-update]System"
23def testPlanName = env.TEST_PLAN_NAME ?: "${testPlanNamePrefix}-${MCP_VERSION}-${new Date().format('yyyy-MM-dd')}"
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030024
25if (! env.PARENT_NODE_NAME) {
26 error "'PARENT_NODE_NAME' must be set from the parent deployment job!"
27}
28
29currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
30
Hanna Arhipova705a2892020-09-25 12:40:39 +030031def find_latest(search_pattern) {
32 return "find ${PARENT_WORKSPACE} -name \"${search_pattern}\" -printf \"'%T@ %p \\n'\" | sort -r |head -n1|awk -F' ' '{ print \$2 }'"
33}
34
Dennis Dmitriev1f08b0c2019-05-27 17:03:53 +030035timeout(time: 2, unit: 'HOURS') {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030036node ("${PARENT_NODE_NAME}") {
37 if (! fileExists("${PARENT_WORKSPACE}")) {
38 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
39 }
40 dir("${PARENT_WORKSPACE}") {
Hanna Arhipova705a2892020-09-25 12:40:39 +030041 if (env.REPORT_FILE_URL) {
42 print "Download report from '${env.REPORT_FILE_URL}'"
43 file_text = new URL ("${env.REPORT_FILE_URL}").getText()
44 print "Copy downloaded file to workspace as ${REPORT_FILE_NAME}"
45 writeFile file: "${REPORT_FILE_NAME}", text: file_text
46 }
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030047 def description = ''
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030048 def exception_message = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030049 try {
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030050
51 if (env.TCP_QA_REFS) {
52 stage("Update working dir to patch ${TCP_QA_REFS}") {
53 shared.update_working_dir()
54 }
55 }
56
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030057 def report_name = ''
58 def testSuiteName = ''
59 def methodname = ''
60 def testrail_name_template = ''
61 def reporter_extra_options = []
62
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030063 def report_url = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030064
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020065 // deployment_report_name = "deployment_${ENV_NAME}.xml"
Hanna Arhipova705a2892020-09-25 12:40:39 +030066 def deployment_report_name = sh(script: find_latest("deployment_${ENV_NAME}.xml"), returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020067 // tcpqa_report_name =~ "nosetests.xml"
Hanna Arhipova705a2892020-09-25 12:40:39 +030068 def tcpqa_report_name = sh(script: find_latest("nosetests.xml"), returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020069 // tempest_report_name =~ "report_*.xml"
Hanna Arhipova705a2892020-09-25 12:40:39 +030070 def tempest_report_name = sh(script: find_latest("report_*.xml"), returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020071 // stacklight_report_name =~ "stacklight_report.xml" or "report.xml"
PGlazov271e7952022-01-13 16:11:31 +040072 def stacklight_report_name = sh(script: find_latest("cvp-stacklight*results.xml"), returnStdout: true).trim()
Dennis Dmitriev8565c342019-02-11 23:45:03 +020073 // cvp_sanity_report_name =~ cvp_sanity_report.xml
PGlazov271e7952022-01-13 16:11:31 +040074 def cvp_sanity_report_name = sh(script: find_latest("cvp-sanity*results.xml"), returnStdout: true).trim()
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030075 common.printMsg(deployment_report_name ? "Found deployment report: ${deployment_report_name}" : "Deployment report not found", deployment_report_name ? "blue" : "red")
76 common.printMsg(tcpqa_report_name ? "Found tcp-qa report: ${tcpqa_report_name}" : "tcp-qa report not found", tcpqa_report_name ? "blue" : "red")
77 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 +030078 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 +020079 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 +030080
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030081 if (deployment_report_name) {
82 stage("Deployment report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030083 testSuiteName = "[MCP] Integration automation"
84 methodname = '{methodname}'
85 testrail_name_template = '{title}'
86 reporter_extra_options = [
87 "--testrail-add-missing-cases",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030088 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +030089 ret = shared.upload_results_to_testrail(deployment_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030090 common.printMsg(ret.stdout, "blue")
Hanna Arhipovab4e74572021-04-14 21:25:23 +030091 marked = shared.mark_test_results(testPlanName, testSuiteName)
92 common.printMsg(marked.stdout, "blue")
93
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030094 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030095 if (it.contains("[TestRun URL]")) {
96 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +030097 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030098 }
99 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300100 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300101 }
102 }
103
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300104 if (tcpqa_report_name) {
105 stage("tcp-qa cases report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300106 testSuiteName = "[MCP_X] integration cases"
Hanna Arhipova7f2a1752021-04-22 09:59:11 +0300107 methodname = "{classname}.{methodname}"
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300108 testrail_name_template = "{title}"
109 reporter_extra_options = [
110 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200111// "--testrail_configuration_name tcp-qa",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300112 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300113 ret = shared.upload_results_to_testrail(tcpqa_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300114 common.printMsg(ret.stdout, "blue")
Hanna Arhipovab4e74572021-04-14 21:25:23 +0300115 marked = shared.mark_test_results(testPlanName, testSuiteName)
116 common.printMsg(marked.stdout, "blue")
117
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300118 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300119 if (it.contains("[TestRun URL]")) {
120 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300121 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300122 }
123 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300124 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300125 }
126 }
127
128 if ('openstack' in stacks && tempest_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300129 stage("Tempest report") {
Tatyana Leontovichf3718442018-10-31 13:36:13 +0200130 testSuiteName = env.TEMPEST_TEST_SUITE_NAME
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300131 methodname = "{classname}.{methodname}"
132 testrail_name_template = "{title}"
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300133 reporter_extra_options = [
134 "--send-duplicates",
135 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200136// "--testrail_configuration_name tcp-qa",
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300137 ]
138 ret = shared.upload_results_to_testrail(tempest_report_name,
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300139 testPlanName,
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300140 testSuiteName,
141 methodname,
142 testrail_name_template,
143 reporter_extra_options)
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300144 common.printMsg(ret.stdout, "blue")
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300145 marked = shared.mark_test_results(testPlanName, testSuiteName)
146 common.printMsg(marked.stdout, "blue")
147
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300148 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300149 if (it.contains("[TestRun URL]")) {
150 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300151 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300152 }
153 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300154 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300155 }
156 }
157
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300158 if ('stacklight' in stacks && stacklight_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300159 stage("stacklight-pytest report") {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300160 testSuiteName = "LMA2.0_Automated"
161 methodname = "{methodname}"
162 testrail_name_template = "{title}"
Hanna Arhipova40955d72019-11-04 14:38:42 +0200163 reporter_extra_options = [
164 "--testrail-add-missing-cases",
165 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
166 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300167 ret = shared.upload_results_to_testrail(stacklight_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300168 common.printMsg(ret.stdout, "blue")
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300169 marked = shared.mark_test_results(testPlanName, testSuiteName)
170 common.printMsg(marked.stdout, "blue")
171
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300172 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300173 if (it.contains("[TestRun URL]")) {
174 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300175 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300176 }
177 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300178 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300179 }
180 }
181
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200182 if ('cicd' in stacks && cvp_sanity_report_name) {
183 stage("CVP Sanity report") {
184 testSuiteName = "[MCP] cvp sanity"
185 methodname = '{methodname}'
186 testrail_name_template = '{title}'
187 reporter_extra_options = [
188 "--send-duplicates",
189 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200190// "--testrail_configuration_name tcp-qa",
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200191 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300192 uploaded = shared.upload_results_to_testrail(cvp_sanity_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
193 common.printMsg(uploaded.stdout, "blue")
194 marked = shared.mark_test_results(testPlanName, testSuiteName)
195 common.printMsg(marked.stdout, "blue")
196
197 report_url = uploaded.stdout.split("\n").each {
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200198 if (it.contains("[TestRun URL]")) {
199 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300200 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200201 }
202 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300203 exception_message += ret.exception
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200204 }
205 }
206
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300207
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300208 // Check if there were any exceptions during reporting
209 if (exception_message) {
210 throw new Exception(exception_message)
211 }
212
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300213 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300214 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300215 throw e
216 } finally {
217 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300218 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300219 }
220 }
221}
Dennis Dmitriev1f08b0c2019-05-27 17:03:53 +0300222} // timeout