blob: 3849e16ede61133e39e4b14bd797defdc73a638c [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
15 */
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)
22
23if (! env.PARENT_NODE_NAME) {
24 error "'PARENT_NODE_NAME' must be set from the parent deployment job!"
25}
26
27currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
28
29node ("${PARENT_NODE_NAME}") {
30 if (! fileExists("${PARENT_WORKSPACE}")) {
31 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
32 }
33 dir("${PARENT_WORKSPACE}") {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030034 def description = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030035 try {
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030036
37 if (env.TCP_QA_REFS) {
38 stage("Update working dir to patch ${TCP_QA_REFS}") {
39 shared.update_working_dir()
40 }
41 }
42
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030043 def report_name = ''
44 def testSuiteName = ''
45 def methodname = ''
46 def testrail_name_template = ''
47 def reporter_extra_options = []
48
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030049 def report_result = ''
50 def report_url = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030051
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020052 // deployment_report_name = "deployment_${ENV_NAME}.xml"
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030053 def deployment_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"deployment_${ENV_NAME}.xml\"", returnStdout: true)
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020054 // tcpqa_report_name =~ "nosetests.xml"
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030055 def tcpqa_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"nosetests.xml\"", returnStdout: true)
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020056 // tempest_report_name =~ "report_*.xml"
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030057 def tempest_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"report_*.xml\"", returnStdout: true)
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020058 // k8s_conformance_report_name =~ conformance_result.xml
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030059 def k8s_conformance_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_result.xml\"", returnStdout: true)
Dennis Dmitriev34fd3002018-11-15 18:25:16 +020060 // k8s_conformance_report_name =~ conformance_virtlet_result.xml
61 def k8s_conformance_virtlet_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_virtlet_result.xml\"", returnStdout: true)
Dennis Dmitriev09ef69e2018-11-09 15:25:18 +020062 // stacklight_report_name =~ "stacklight_report.xml" or "report.xml"
63 def stacklight_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"*report.xml\"", returnStdout: true)
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030064 common.printMsg(deployment_report_name ? "Found deployment report: ${deployment_report_name}" : "Deployment report not found", deployment_report_name ? "blue" : "red")
65 common.printMsg(tcpqa_report_name ? "Found tcp-qa report: ${tcpqa_report_name}" : "tcp-qa report not found", tcpqa_report_name ? "blue" : "red")
66 common.printMsg(tempest_report_name ? "Found tempest report: ${tempest_report_name}" : "tempest report not found", tempest_report_name ? "blue" : "red")
67 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 +020068 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 +030069 common.printMsg(stacklight_report_name ? "Found stacklight-pytest report: ${stacklight_report_name}" : "stacklight-pytest report not found", stacklight_report_name ? "blue" : "red")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030070
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030071
72 if (deployment_report_name) {
73 stage("Deployment report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030074 testSuiteName = "[MCP] Integration automation"
75 methodname = '{methodname}'
76 testrail_name_template = '{title}'
77 reporter_extra_options = [
78 "--testrail-add-missing-cases",
79 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
80 "--testrail-case-section-name \'All\'",
81 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030082 report_result = shared.upload_results_to_testrail(deployment_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
83 common.printMsg(report_result, "blue")
84 report_url = report_result.split("\n").each {
85 if (it.contains("[TestRun URL]")) {
86 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030087 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030088 }
89 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030090 }
91 }
92
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030093 if (tcpqa_report_name) {
94 stage("tcp-qa cases report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030095 testSuiteName = "[MCP_X] integration cases"
96 methodname = "{methodname}"
97 testrail_name_template = "{title}"
98 reporter_extra_options = [
99 "--testrail-add-missing-cases",
100 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
101 "--testrail-case-section-name \'All\'",
102 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300103 report_result = shared.upload_results_to_testrail(tcpqa_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
104 common.printMsg(report_result, "blue")
105 report_url = report_result.split("\n").each {
106 if (it.contains("[TestRun URL]")) {
107 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300108 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300109 }
110 }
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300111 }
112 }
113
114 if ('openstack' in stacks && tempest_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300115 stage("Tempest report") {
Tatyana Leontovichf3718442018-10-31 13:36:13 +0200116 testSuiteName = env.TEMPEST_TEST_SUITE_NAME
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300117 methodname = "{classname}.{methodname}"
118 testrail_name_template = "{title}"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300119 report_result = shared.upload_results_to_testrail(tempest_report_name, testSuiteName, methodname, testrail_name_template)
120 common.printMsg(report_result, "blue")
121 report_url = report_result.split("\n").each {
122 if (it.contains("[TestRun URL]")) {
123 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300124 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300125 }
126 }
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300127 }
128 }
129
130 if ('k8s' in stacks && k8s_conformance_report_name) {
131 stage("K8s conformance report") {
Dennis Dmitriev265a1c72018-09-29 05:08:47 +0300132 def k8s_version=shared.run_cmd_stdout("""\
Dennis Dmitrievcf866e72018-10-09 17:51:43 +0300133 . ./env_k8s_version;
134 echo "\$KUBE_SERVER_VERSION"
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300135 """).trim().split().last()
136 testSuiteName = "[MCP][k8s]Hyperkube ${k8s_version}.x"
137 methodname = "{methodname}"
138 testrail_name_template = "{title}"
139 reporter_extra_options = [
Dennis Dmitriev74d7e752018-10-01 17:37:49 +0300140 "--send-duplicates",
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300141 "--testrail-add-missing-cases",
142 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
143 "--testrail-case-section-name \'Conformance\'",
144 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300145 report_result = shared.upload_results_to_testrail(k8s_conformance_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
146 common.printMsg(report_result, "blue")
147 report_url = report_result.split("\n").each {
148 if (it.contains("[TestRun URL]")) {
149 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300150 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300151 }
152 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300153 }
154 }
155
Dennis Dmitriev34fd3002018-11-15 18:25:16 +0200156 if ('k8s' in stacks && k8s_conformance_virtlet_report_name) {
157 stage("K8s conformance virtlet report") {
158 testSuiteName = "[k8s] Virtlet"
159 methodname = "{methodname}"
160 testrail_name_template = "{title}"
161 reporter_extra_options = [
162 "--send-duplicates",
163 "--testrail-add-missing-cases",
164 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
165 "--testrail-case-section-name \'Conformance\'",
166 ]
167 report_result = shared.upload_results_to_testrail(k8s_conformance_virtlet_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
168 common.printMsg(report_result, "blue")
169 report_url = report_result.split("\n").each {
170 if (it.contains("[TestRun URL]")) {
171 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
172 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
173 }
174 }
175 }
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}"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300183 report_result = shared.upload_results_to_testrail(stacklight_report_name, testSuiteName, methodname, testrail_name_template)
184 common.printMsg(report_result, "blue")
185 report_url = report_result.split("\n").each {
186 if (it.contains("[TestRun URL]")) {
187 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300188 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300189 }
190 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300191 }
192 }
193
194 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300195 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300196 throw e
197 } finally {
198 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300199 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300200 }
201 }
202}