blob: 11679781caa18320d8769e4f025a504e6b7c6e77 [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
Vladimir Khlyunevcb4778f2022-07-01 20:43:56 +030081 stage("Prepare/update venvs for reporter/analyzer tools"){
Vladimir Khlyuneve5761ba2022-06-24 12:30:43 +040082 sshagent(credentials: ['maintenance-team-ssh']) {
83 shared.run_cmd("""\
84 . /home/jenkins/venv_testrail_reporter/bin/activate;
85 pip install git+ssh://maintenance-ci-robot@gerrit.mcp.mirantis.com:29418/mcp/testrail-reporter -U;
86 pip install --force-reinstall --no-deps git+ssh://maintenance-ci-robot@gerrit.mcp.mirantis.com:29418/mcp/testrail-reporter;""")
87 }
Vladimir Khlyunevcb4778f2022-07-01 20:43:56 +030088 shared.run_cmd("""\
89 if [ -f /home/jenkins/venv_testrail_analyzer/bin/python &&
90 $(/home/jenkins/venv_testrail_analyzer/bin/python -V | awk -F "." '{print \$2}') -lt 6 ] ; then
91 rm -rf /home/jenkins/venv_testrail_analyzer ;
92 fi
93 """)
94 shared.run_cmd("""\
95 [ -d /home/jenkins/venv_testrail_analyzer ] || virtualenv --python=python3.7 /home/jenkins/venv_testrail_analyzer ;
96 source /home/jenkins/venv_testrail_analyzer/bin/activate;
97 pip install git+https://review.gerrithub.io/ibumarskov/testrail-reporter@b9041b241f3364022cd0ad63510f02aab4352a6b
98 """)
Vladimir Khlyuneve5761ba2022-06-24 12:30:43 +040099 }
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300100
101 if (deployment_report_name) {
102 stage("Deployment report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300103 testSuiteName = "[MCP] Integration automation"
104 methodname = '{methodname}'
105 testrail_name_template = '{title}'
106 reporter_extra_options = [
107 "--testrail-add-missing-cases",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300108 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300109 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 +0300110 common.printMsg(ret.stdout, "blue")
Hanna Arhipovab4e74572021-04-14 21:25:23 +0300111 marked = shared.mark_test_results(testPlanName, testSuiteName)
112 common.printMsg(marked.stdout, "blue")
113
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300114 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300115 if (it.contains("[TestRun URL]")) {
116 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300117 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300118 }
119 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300120 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300121 }
122 }
123
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300124 if (tcpqa_report_name) {
125 stage("tcp-qa cases report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300126 testSuiteName = "[MCP_X] integration cases"
Hanna Arhipova7f2a1752021-04-22 09:59:11 +0300127 methodname = "{classname}.{methodname}"
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300128 testrail_name_template = "{title}"
129 reporter_extra_options = [
130 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200131// "--testrail_configuration_name tcp-qa",
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300132 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300133 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 +0300134 common.printMsg(ret.stdout, "blue")
Hanna Arhipovab4e74572021-04-14 21:25:23 +0300135 marked = shared.mark_test_results(testPlanName, testSuiteName)
136 common.printMsg(marked.stdout, "blue")
137
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300138 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300139 if (it.contains("[TestRun URL]")) {
140 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300141 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300142 }
143 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300144 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300145 }
146 }
147
148 if ('openstack' in stacks && tempest_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300149 stage("Tempest report") {
Tatyana Leontovichf3718442018-10-31 13:36:13 +0200150 testSuiteName = env.TEMPEST_TEST_SUITE_NAME
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300151 methodname = "{classname}.{methodname}"
152 testrail_name_template = "{title}"
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300153 reporter_extra_options = [
154 "--send-duplicates",
155 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200156// "--testrail_configuration_name tcp-qa",
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300157 ]
158 ret = shared.upload_results_to_testrail(tempest_report_name,
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300159 testPlanName,
Ekaterina Chernova26d85232019-10-25 12:35:15 +0300160 testSuiteName,
161 methodname,
162 testrail_name_template,
163 reporter_extra_options)
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300164 common.printMsg(ret.stdout, "blue")
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300165 marked = shared.mark_test_results(testPlanName, testSuiteName)
166 common.printMsg(marked.stdout, "blue")
167
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300168 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300169 if (it.contains("[TestRun URL]")) {
170 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300171 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300172 }
173 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300174 exception_message += ret.exception
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300175 }
176 }
177
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300178 if ('stacklight' in stacks && stacklight_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300179 stage("stacklight-pytest report") {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300180 testSuiteName = "LMA2.0_Automated"
181 methodname = "{methodname}"
182 testrail_name_template = "{title}"
Hanna Arhipova40955d72019-11-04 14:38:42 +0200183 reporter_extra_options = [
184 "--testrail-add-missing-cases",
185 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
186 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300187 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 +0300188 common.printMsg(ret.stdout, "blue")
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300189 marked = shared.mark_test_results(testPlanName, testSuiteName)
190 common.printMsg(marked.stdout, "blue")
191
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300192 report_url = ret.stdout.split("\n").each {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300193 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 Dmitrievfbf42272018-10-23 00:19:50 +0300196 }
197 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300198 exception_message += ret.exception
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300199 }
200 }
201
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200202 if ('cicd' in stacks && cvp_sanity_report_name) {
203 stage("CVP Sanity report") {
204 testSuiteName = "[MCP] cvp sanity"
205 methodname = '{methodname}'
206 testrail_name_template = '{title}'
207 reporter_extra_options = [
208 "--send-duplicates",
209 "--testrail-add-missing-cases",
Hanna Arhipovac1912a62019-12-04 10:21:50 +0200210// "--testrail_configuration_name tcp-qa",
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200211 ]
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300212 uploaded = shared.upload_results_to_testrail(cvp_sanity_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
213 common.printMsg(uploaded.stdout, "blue")
214 marked = shared.mark_test_results(testPlanName, testSuiteName)
215 common.printMsg(marked.stdout, "blue")
216
217 report_url = uploaded.stdout.split("\n").each {
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200218 if (it.contains("[TestRun URL]")) {
219 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitriev27007322019-05-03 19:21:44 +0300220 description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200221 }
222 }
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300223 exception_message += ret.exception
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200224 }
225 }
226
Hanna Arhipova1b92f9b2020-10-05 15:50:25 +0300227
Dennis Dmitrievfd0b78c2019-05-30 00:16:04 +0300228 // Check if there were any exceptions during reporting
229 if (exception_message) {
230 throw new Exception(exception_message)
231 }
232
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300233 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300234 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300235 throw e
236 } finally {
237 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300238 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300239 }
240 }
241}
Dennis Dmitriev1f08b0c2019-05-27 17:03:53 +0300242} // timeout