blob: 4af60af01f01f689affabc5be754b629740638da [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")
92 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030093 if (it.contains("[TestRun URL]")) {
94 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +030095 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030096 }
97 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +030098 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030099 }
100 }
101
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300102 if (tcpqa_report_name) {
103 stage("tcp-qa cases report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300104 testSuiteName = "[MCP_X] integration cases"
105 methodname = "{methodname}"
106 testrail_name_template = "{title}"
107 reporter_extra_options = [
108 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200109// "--testrail_configuration_name tcp-qa",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300110 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300111 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 +0300112 common.printMsg(ret.stdout, "blue")
113 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300114 if (it.contains("[TestRun URL]")) {
115 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300116 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300117 }
118 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300119 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300120 }
121 }
122
123 if ('openstack' in stacks && tempest_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300124 stage("Tempest report") {
Tatyana Leontovichf3718442018-10-31 13:36:13 +0200125 testSuiteName = env.TEMPEST_TEST_SUITE_NAME
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300126 methodname = "{classname}.{methodname}"
127 testrail_name_template = "{title}"
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300128 reporter_extra_options = [
129 "--send-duplicates",
130 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200131// "--testrail_configuration_name tcp-qa",
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300132 ]
133 ret = shared.upload_results_to_testrail(tempest_report_name,
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300134 testPlanName,
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300135 testSuiteName,
136 methodname,
137 testrail_name_template,
138 reporter_extra_options)
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300139 common.printMsg(ret.stdout, "blue")
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300140 marked = shared.mark_test_results(testPlanName, testSuiteName)
141 common.printMsg(marked.stdout, "blue")
142
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300143 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300144 if (it.contains("[TestRun URL]")) {
145 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300146 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300147 }
148 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300149 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300150 }
151 }
152
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300153 if ('stacklight' in stacks && stacklight_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300154 stage("stacklight-pytest report") {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300155 testSuiteName = "LMA2.0_Automated"
156 methodname = "{methodname}"
157 testrail_name_template = "{title}"
Hanna Arhipova40955d72019-11-04 14:38:42 +0200158 reporter_extra_options = [
159 "--testrail-add-missing-cases",
160 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
161 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300162 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 +0300163 common.printMsg(ret.stdout, "blue")
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300164 marked = shared.mark_test_results(testPlanName, testSuiteName)
165 common.printMsg(marked.stdout, "blue")
166
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300167 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300168 if (it.contains("[TestRun URL]")) {
169 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300170 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300171 }
172 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300173 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300174 }
175 }
176
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200177 if ('cicd' in stacks && cvp_sanity_report_name) {
178 stage("CVP Sanity report") {
179 testSuiteName = "[MCP] cvp sanity"
180 methodname = '{methodname}'
181 testrail_name_template = '{title}'
182 reporter_extra_options = [
183 "--send-duplicates",
184 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200185// "--testrail_configuration_name tcp-qa",
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200186 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300187 uploaded = shared.upload_results_to_testrail(cvp_sanity_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
188 common.printMsg(uploaded.stdout, "blue")
189 marked = shared.mark_test_results(testPlanName, testSuiteName)
190 common.printMsg(marked.stdout, "blue")
191
192 report_url = uploaded.stdout.split("\n").each {
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200193 if (it.contains("[TestRun URL]")) {
194 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300195 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200196 }
197 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300198 exception_message += ret.exception
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200199 }
200 }
201
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300202
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300203 // Check if there were any exceptions during reporting
204 if (exception_message) {
205 throw new Exception(exception_message)
206 }
207
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300208 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300209 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300210 throw e
211 } finally {
212 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300213 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300214 }
215 }
216}
Dennis Dmitriev1f08b0c2019-05-27 17:03:53 +0300217} // timeout