blob: 1dfd597f77bd50a46542dda24c8617be80bd9696 [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
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030014 * TCP_QA_REFS Reference to the tcp-qa change on review.gerrithub.io, like refs/changes/46/418546/41
Vladimir Jigulin151097d2019-03-21 18:39:47 +040015 * TEST_PLAN_NAME_PREFIX Prefix of test plan name
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030016 */
17
18@Library('tcp-qa')_
19
20def common = new com.mirantis.mk.Common()
21def shared = new com.mirantis.system_qa.SharedPipeline()
22def stacks = shared.get_steps_list(PASSED_STEPS)
23
24if (! env.PARENT_NODE_NAME) {
25 error "'PARENT_NODE_NAME' must be set from the parent deployment job!"
26}
27
28currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
29
30node ("${PARENT_NODE_NAME}") {
31 if (! fileExists("${PARENT_WORKSPACE}")) {
32 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
33 }
34 dir("${PARENT_WORKSPACE}") {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030035 def description = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030036 try {
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030037
38 if (env.TCP_QA_REFS) {
39 stage("Update working dir to patch ${TCP_QA_REFS}") {
40 shared.update_working_dir()
41 }
42 }
43
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030044 def report_name = ''
Vladimir Jigulin151097d2019-03-21 18:39:47 +040045 def testPlanNamePrefix = env.TEST_PLAN_NAME_PREFIX ?: ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030046 def testSuiteName = ''
47 def methodname = ''
48 def testrail_name_template = ''
49 def reporter_extra_options = []
50
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030051 def report_result = ''
52 def report_url = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030053
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020054 // deployment_report_name = "deployment_${ENV_NAME}.xml"
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020055 def deployment_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"deployment_${ENV_NAME}.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020056 // tcpqa_report_name =~ "nosetests.xml"
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020057 def tcpqa_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"nosetests.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020058 // tempest_report_name =~ "report_*.xml"
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020059 def tempest_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"report_*.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020060 // k8s_conformance_report_name =~ conformance_result.xml
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020061 def k8s_conformance_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_result.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitriev34fd3002018-11-15 18:25:16 +020062 // k8s_conformance_report_name =~ conformance_virtlet_result.xml
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020063 def k8s_conformance_virtlet_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_virtlet_result.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020064 // stacklight_report_name =~ "stacklight_report.xml" or "report.xml"
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020065 def stacklight_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"*report.xml\"", returnStdout: true).trim()
Dennis Dmitriev8565c342019-02-11 23:45:03 +020066 // cvp_sanity_report_name =~ cvp_sanity_report.xml
Dennis Dmitrievec7ae972019-02-19 12:29:11 +020067 def cvp_sanity_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"cvp_sanity_results.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030068 common.printMsg(deployment_report_name ? "Found deployment report: ${deployment_report_name}" : "Deployment report not found", deployment_report_name ? "blue" : "red")
69 common.printMsg(tcpqa_report_name ? "Found tcp-qa report: ${tcpqa_report_name}" : "tcp-qa report not found", tcpqa_report_name ? "blue" : "red")
70 common.printMsg(tempest_report_name ? "Found tempest report: ${tempest_report_name}" : "tempest report not found", tempest_report_name ? "blue" : "red")
71 common.printMsg(k8s_conformance_report_name ? "Found k8s conformance report: ${k8s_conformance_report_name}" : "k8s conformance report not found", k8s_conformance_report_name ? "blue" : "red")
Dennis Dmitriev34fd3002018-11-15 18:25:16 +020072 common.printMsg(k8s_conformance_virtlet_report_name ? "Found k8s conformance virtlet report: ${k8s_conformance_virtlet_report_name}" : "k8s conformance virtlet report not found", k8s_conformance_virtlet_report_name ? "blue" : "red")
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030073 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 +020074 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 +030075
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030076
77 if (deployment_report_name) {
78 stage("Deployment report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030079 testSuiteName = "[MCP] Integration automation"
80 methodname = '{methodname}'
81 testrail_name_template = '{title}'
82 reporter_extra_options = [
83 "--testrail-add-missing-cases",
84 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
85 "--testrail-case-section-name \'All\'",
86 ]
Vladimir Jigulin151097d2019-03-21 18:39:47 +040087 report_result = shared.upload_results_to_testrail(
88 deployment_report_name, testSuiteName, methodname, testrail_name_template,
89 reporter_extra_options, testPlanNamePrefix=testPlanNamePrefix)
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030090 common.printMsg(report_result, "blue")
91 report_url = report_result.split("\n").each {
92 if (it.contains("[TestRun URL]")) {
93 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030094 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030095 }
96 }
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",
107 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
108 "--testrail-case-section-name \'All\'",
109 ]
Vladimir Jigulin151097d2019-03-21 18:39:47 +0400110 report_result = shared.upload_results_to_testrail(
111 tcpqa_report_name, testSuiteName, methodname, testrail_name_template,
112 reporter_extra_options, testPlanNamePrefix=testPlanNamePrefix)
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300113 common.printMsg(report_result, "blue")
114 report_url = report_result.split("\n").each {
115 if (it.contains("[TestRun URL]")) {
116 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300117 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300118 }
119 }
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}"
Vladimir Jigulin151097d2019-03-21 18:39:47 +0400128 report_result = shared.upload_results_to_testrail(
129 tempest_report_name, testSuiteName, methodname, testrail_name_template,
130 testPlanNamePrefix=testPlanNamePrefix)
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300131 common.printMsg(report_result, "blue")
132 report_url = report_result.split("\n").each {
133 if (it.contains("[TestRun URL]")) {
134 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300135 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300136 }
137 }
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300138 }
139 }
140
141 if ('k8s' in stacks && k8s_conformance_report_name) {
142 stage("K8s conformance report") {
Dennis Dmitriev265a1c72018-09-29 05:08:47 +0300143 def k8s_version=shared.run_cmd_stdout("""\
Dennis Dmitrievcf866e72018-10-09 17:51:43 +0300144 . ./env_k8s_version;
145 echo "\$KUBE_SERVER_VERSION"
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300146 """).trim().split().last()
147 testSuiteName = "[MCP][k8s]Hyperkube ${k8s_version}.x"
148 methodname = "{methodname}"
149 testrail_name_template = "{title}"
150 reporter_extra_options = [
Dennis Dmitriev74d7e752018-10-01 17:37:49 +0300151 "--send-duplicates",
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300152 "--testrail-add-missing-cases",
153 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
154 "--testrail-case-section-name \'Conformance\'",
155 ]
Vladimir Jigulin151097d2019-03-21 18:39:47 +0400156 report_result = shared.upload_results_to_testrail(
157 k8s_conformance_report_name, testSuiteName, methodname, testrail_name_template,
158 reporter_extra_options, testPlanNamePrefix=testPlanNamePrefix)
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300159 common.printMsg(report_result, "blue")
160 report_url = report_result.split("\n").each {
161 if (it.contains("[TestRun URL]")) {
162 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300163 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300164 }
165 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300166 }
167 }
168
Dennis Dmitriev34fd3002018-11-15 18:25:16 +0200169 if ('k8s' in stacks && k8s_conformance_virtlet_report_name) {
170 stage("K8s conformance virtlet report") {
171 testSuiteName = "[k8s] Virtlet"
172 methodname = "{methodname}"
173 testrail_name_template = "{title}"
174 reporter_extra_options = [
175 "--send-duplicates",
176 "--testrail-add-missing-cases",
177 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
178 "--testrail-case-section-name \'Conformance\'",
179 ]
Vladimir Jigulin151097d2019-03-21 18:39:47 +0400180 report_result = shared.upload_results_to_testrail(
181 k8s_conformance_virtlet_report_name, testSuiteName, methodname, testrail_name_template,
182 reporter_extra_options, testPlanNamePrefix=testPlanNamePrefix)
Dennis Dmitriev34fd3002018-11-15 18:25:16 +0200183 common.printMsg(report_result, "blue")
184 report_url = report_result.split("\n").each {
185 if (it.contains("[TestRun URL]")) {
186 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
187 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
188 }
189 }
190 }
191 }
192
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300193 if ('stacklight' in stacks && stacklight_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300194 stage("stacklight-pytest report") {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300195 testSuiteName = "LMA2.0_Automated"
196 methodname = "{methodname}"
197 testrail_name_template = "{title}"
Vladimir Jigulin151097d2019-03-21 18:39:47 +0400198 report_result = shared.upload_results_to_testrail(
199 stacklight_report_name, testSuiteName, methodname, testrail_name_template,
200 testPlanNamePrefix=testPlanNamePrefix)
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300201 common.printMsg(report_result, "blue")
202 report_url = report_result.split("\n").each {
203 if (it.contains("[TestRun URL]")) {
204 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300205 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300206 }
207 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300208 }
209 }
210
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200211 if ('cicd' in stacks && cvp_sanity_report_name) {
212 stage("CVP Sanity report") {
213 testSuiteName = "[MCP] cvp sanity"
214 methodname = '{methodname}'
215 testrail_name_template = '{title}'
216 reporter_extra_options = [
217 "--send-duplicates",
218 "--testrail-add-missing-cases",
219 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
220 "--testrail-case-section-name \'All\'",
221 ]
Vladimir Jigulin151097d2019-03-21 18:39:47 +0400222 report_result = shared.upload_results_to_testrail(
223 cvp_sanity_report_name, testSuiteName, methodname, testrail_name_template,
224 reporter_extra_options, testPlanNamePrefix=testPlanNamePrefix)
Dennis Dmitriev8565c342019-02-11 23:45:03 +0200225 common.printMsg(report_result, "blue")
226 report_url = report_result.split("\n").each {
227 if (it.contains("[TestRun URL]")) {
228 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
229 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
230 }
231 }
232 }
233 }
234
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300235 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300236 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300237 throw e
238 } finally {
239 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300240 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300241 }
242 }
243}