blob: 6ff52e627a61b85389f0a785b19458f5ee31b288 [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"
Hanna Arhipova705a2892020-09-25 12:40:39 +030072 def stacklight_report_name = sh(script: find_latest("*report.xml"), returnStdout: true).trim()
Dennis Dmitriev8565c342019-02-11 23:45:03 +020073 // cvp_sanity_report_name =~ cvp_sanity_report.xml
Hanna Arhipova705a2892020-09-25 12:40:39 +030074 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
82 if (deployment_report_name) {
83 stage("Deployment report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030084 testSuiteName = "[MCP] Integration automation"
85 methodname = '{methodname}'
86 testrail_name_template = '{title}'
87 reporter_extra_options = [
88 "--testrail-add-missing-cases",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030089 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +030090 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 +030091 common.printMsg(ret.stdout, "blue")
Hanna Arhipovab4e74572021-04-14 21:25:23 +030092 marked = shared.mark_test_results(testPlanName, testSuiteName)
93 common.printMsg(marked.stdout, "blue")
94
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030095 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030096 if (it.contains("[TestRun URL]")) {
97 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +030098 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030099 }
100 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300101 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300102 }
103 }
104
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300105 if (tcpqa_report_name) {
106 stage("tcp-qa cases report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300107 testSuiteName = "[MCP_X] integration cases"
108 methodname = "{methodname}"
109 testrail_name_template = "{title}"
110 reporter_extra_options = [
111 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200112// "--testrail_configuration_name tcp-qa",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300113 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300114 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 +0300115 common.printMsg(ret.stdout, "blue")
Hanna Arhipovab4e74572021-04-14 21:25:23 +0300116 marked = shared.mark_test_results(testPlanName, testSuiteName)
117 common.printMsg(marked.stdout, "blue")
118
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300119 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300120 if (it.contains("[TestRun URL]")) {
121 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300122 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300123 }
124 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300125 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300126 }
127 }
128
129 if ('openstack' in stacks && tempest_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300130 stage("Tempest report") {
Tatyana Leontovichf3718442018-10-31 13:36:13 +0200131 testSuiteName = env.TEMPEST_TEST_SUITE_NAME
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300132 methodname = "{classname}.{methodname}"
133 testrail_name_template = "{title}"
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300134 reporter_extra_options = [
135 "--send-duplicates",
136 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200137// "--testrail_configuration_name tcp-qa",
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300138 ]
139 ret = shared.upload_results_to_testrail(tempest_report_name,
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300140 testPlanName,
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300141 testSuiteName,
142 methodname,
143 testrail_name_template,
144 reporter_extra_options)
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300145 common.printMsg(ret.stdout, "blue")
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300146 marked = shared.mark_test_results(testPlanName, testSuiteName)
147 common.printMsg(marked.stdout, "blue")
148
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300149 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300150 if (it.contains("[TestRun URL]")) {
151 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300152 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300153 }
154 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300155 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300156 }
157 }
158
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300159 if ('stacklight' in stacks && stacklight_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300160 stage("stacklight-pytest report") {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300161 testSuiteName = "LMA2.0_Automated"
162 methodname = "{methodname}"
163 testrail_name_template = "{title}"
Hanna Arhipova40955d72019-11-04 14:38:42 +0200164 reporter_extra_options = [
165 "--testrail-add-missing-cases",
166 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
167 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300168 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 +0300169 common.printMsg(ret.stdout, "blue")
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300170 marked = shared.mark_test_results(testPlanName, testSuiteName)
171 common.printMsg(marked.stdout, "blue")
172
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300173 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300174 if (it.contains("[TestRun URL]")) {
175 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300176 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300177 }
178 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300179 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300180 }
181 }
182
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200183 if ('cicd' in stacks && cvp_sanity_report_name) {
184 stage("CVP Sanity report") {
185 testSuiteName = "[MCP] cvp sanity"
186 methodname = '{methodname}'
187 testrail_name_template = '{title}'
188 reporter_extra_options = [
189 "--send-duplicates",
190 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200191// "--testrail_configuration_name tcp-qa",
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200192 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300193 uploaded = shared.upload_results_to_testrail(cvp_sanity_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
194 common.printMsg(uploaded.stdout, "blue")
195 marked = shared.mark_test_results(testPlanName, testSuiteName)
196 common.printMsg(marked.stdout, "blue")
197
198 report_url = uploaded.stdout.split("\n").each {
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200199 if (it.contains("[TestRun URL]")) {
200 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300201 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200202 }
203 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300204 exception_message += ret.exception
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200205 }
206 }
207
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300208
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300209 // Check if there were any exceptions during reporting
210 if (exception_message) {
211 throw new Exception(exception_message)
212 }
213
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300214 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300215 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300216 throw e
217 } finally {
218 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300219 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300220 }
221 }
222}
Dennis Dmitriev1f08b0c2019-05-27 17:03:53 +0300223} // timeout