blob: 42027f012e541c296f2a389724ce77e251de8394 [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
13 * TCP_QA_REFS Reference to the tcp-qa change on review.gerrithub.io, like refs/changes/46/418546/41
14 */
15
16@Library('tcp-qa')_
17
18def common = new com.mirantis.mk.Common()
19def shared = new com.mirantis.system_qa.SharedPipeline()
20def stacks = shared.get_steps_list(PASSED_STEPS)
21
22if (! env.PARENT_NODE_NAME) {
23 error "'PARENT_NODE_NAME' must be set from the parent deployment job!"
24}
25
26currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
27
28node ("${PARENT_NODE_NAME}") {
29 if (! fileExists("${PARENT_WORKSPACE}")) {
30 error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
31 }
32 dir("${PARENT_WORKSPACE}") {
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030033 def description = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030034 try {
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030035
36 if (env.TCP_QA_REFS) {
37 stage("Update working dir to patch ${TCP_QA_REFS}") {
38 shared.update_working_dir()
39 }
40 }
41
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030042 def report_name = ''
43 def testSuiteName = ''
44 def methodname = ''
45 def testrail_name_template = ''
46 def reporter_extra_options = []
47
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030048 def report_result = ''
49 def report_url = ''
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030050
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030051 def deployment_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"deployment_${ENV_NAME}.xml\"", returnStdout: true)
52 def tcpqa_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"nosetests.xml\"", returnStdout: true)
53 def tempest_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"report_*.xml\"", returnStdout: true)
54 def k8s_conformance_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_result.xml\"", returnStdout: true)
55 def stacklight_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"stacklight_report.xml\"", returnStdout: true)
56 common.printMsg(deployment_report_name ? "Found deployment report: ${deployment_report_name}" : "Deployment report not found", deployment_report_name ? "blue" : "red")
57 common.printMsg(tcpqa_report_name ? "Found tcp-qa report: ${tcpqa_report_name}" : "tcp-qa report not found", tcpqa_report_name ? "blue" : "red")
58 common.printMsg(tempest_report_name ? "Found tempest report: ${tempest_report_name}" : "tempest report not found", tempest_report_name ? "blue" : "red")
59 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")
60 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 +030061
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030062
63 if (deployment_report_name) {
64 stage("Deployment report") {
65// report_name = "deployment_${ENV_NAME}.xml"
66 testSuiteName = "[MCP] Integration automation"
67 methodname = '{methodname}'
68 testrail_name_template = '{title}'
69 reporter_extra_options = [
70 "--testrail-add-missing-cases",
71 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
72 "--testrail-case-section-name \'All\'",
73 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030074 report_result = shared.upload_results_to_testrail(deployment_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
75 common.printMsg(report_result, "blue")
76 report_url = report_result.split("\n").each {
77 if (it.contains("[TestRun URL]")) {
78 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030079 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030080 }
81 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030082 }
83 }
84
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030085 if (tcpqa_report_name) {
86 stage("tcp-qa cases report") {
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +030087 // tcpqa_report_name =~ "nosetests.xml"
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030088 testSuiteName = "[MCP_X] integration cases"
89 methodname = "{methodname}"
90 testrail_name_template = "{title}"
91 reporter_extra_options = [
92 "--testrail-add-missing-cases",
93 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
94 "--testrail-case-section-name \'All\'",
95 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030096 report_result = shared.upload_results_to_testrail(tcpqa_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
97 common.printMsg(report_result, "blue")
98 report_url = report_result.split("\n").each {
99 if (it.contains("[TestRun URL]")) {
100 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300101 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300102 }
103 }
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300104 }
105 }
106
107 if ('openstack' in stacks && tempest_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300108 stage("Tempest report") {
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300109 // tempest_report_name =~ "report_*.xml"
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300110 testSuiteName = "[MCP1.1_PIKE]Tempest"
111 methodname = "{classname}.{methodname}"
112 testrail_name_template = "{title}"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300113 report_result = shared.upload_results_to_testrail(tempest_report_name, testSuiteName, methodname, testrail_name_template)
114 common.printMsg(report_result, "blue")
115 report_url = report_result.split("\n").each {
116 if (it.contains("[TestRun URL]")) {
117 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300118 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300119 }
120 }
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300121 }
122 }
123
124 if ('k8s' in stacks && k8s_conformance_report_name) {
125 stage("K8s conformance report") {
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300126 // k8s_conformance_report_name =~ conformance_result.xml
127 // TODO(ddmitriev): it's better to get the k8s version right after deployment
128 // and store in some artifact that can be re-used here.
Dennis Dmitriev265a1c72018-09-29 05:08:47 +0300129 def k8s_version=shared.run_cmd_stdout("""\
Dennis Dmitrievcf866e72018-10-09 17:51:43 +0300130 . ./env_k8s_version;
131 echo "\$KUBE_SERVER_VERSION"
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300132 """).trim().split().last()
133 testSuiteName = "[MCP][k8s]Hyperkube ${k8s_version}.x"
134 methodname = "{methodname}"
135 testrail_name_template = "{title}"
136 reporter_extra_options = [
Dennis Dmitriev74d7e752018-10-01 17:37:49 +0300137 "--send-duplicates",
Dennis Dmitrieveb50ce12018-09-27 13:34:32 +0300138 "--testrail-add-missing-cases",
139 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
140 "--testrail-case-section-name \'Conformance\'",
141 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300142 report_result = shared.upload_results_to_testrail(k8s_conformance_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
143 common.printMsg(report_result, "blue")
144 report_url = report_result.split("\n").each {
145 if (it.contains("[TestRun URL]")) {
146 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300147 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300148 }
149 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +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 Dmitrieveb50ce12018-09-27 13:34:32 +0300155 // stacklight_report_name =~ "stacklight_report.xml"
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300156 testSuiteName = "LMA2.0_Automated"
157 methodname = "{methodname}"
158 testrail_name_template = "{title}"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300159 report_result = shared.upload_results_to_testrail(stacklight_report_name, testSuiteName, methodname, testrail_name_template)
160 common.printMsg(report_result, "blue")
161 report_url = report_result.split("\n").each {
162 if (it.contains("[TestRun URL]")) {
163 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300164 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300165 }
166 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300167 }
168 }
169
170 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300171 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300172 throw e
173 } finally {
174 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300175 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300176 }
177 }
178}