blob: 059eef7d9818515acf71a063f168bda0f35ec5a6 [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 Dmitriev09ef69e2018-11-09 15:25:18 +020060 // stacklight_report_name =~ "stacklight_report.xml" or "report.xml"
61 def stacklight_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"*report.xml\"", returnStdout: true)
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030062 common.printMsg(deployment_report_name ? "Found deployment report: ${deployment_report_name}" : "Deployment report not found", deployment_report_name ? "blue" : "red")
63 common.printMsg(tcpqa_report_name ? "Found tcp-qa report: ${tcpqa_report_name}" : "tcp-qa report not found", tcpqa_report_name ? "blue" : "red")
64 common.printMsg(tempest_report_name ? "Found tempest report: ${tempest_report_name}" : "tempest report not found", tempest_report_name ? "blue" : "red")
65 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")
66 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 +030067
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030068
69 if (deployment_report_name) {
70 stage("Deployment report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030071 testSuiteName = "[MCP] Integration automation"
72 methodname = '{methodname}'
73 testrail_name_template = '{title}'
74 reporter_extra_options = [
75 "--testrail-add-missing-cases",
76 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
77 "--testrail-case-section-name \'All\'",
78 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030079 report_result = shared.upload_results_to_testrail(deployment_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
80 common.printMsg(report_result, "blue")
81 report_url = report_result.split("\n").each {
82 if (it.contains("[TestRun URL]")) {
83 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +030084 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +030085 }
86 }
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +030087 }
88 }
89
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030090 if (tcpqa_report_name) {
91 stage("tcp-qa cases report") {
Dennis Dmitrievee5ef232018-08-31 13:53:18 +030092 testSuiteName = "[MCP_X] integration cases"
93 methodname = "{methodname}"
94 testrail_name_template = "{title}"
95 reporter_extra_options = [
96 "--testrail-add-missing-cases",
97 "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
98 "--testrail-case-section-name \'All\'",
99 ]
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300100 report_result = shared.upload_results_to_testrail(tcpqa_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
101 common.printMsg(report_result, "blue")
102 report_url = report_result.split("\n").each {
103 if (it.contains("[TestRun URL]")) {
104 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300105 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300106 }
107 }
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300108 }
109 }
110
111 if ('openstack' in stacks && tempest_report_name) {
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300112 stage("Tempest report") {
Tatyana Leontovichf3718442018-10-31 13:36:13 +0200113 testSuiteName = env.TEMPEST_TEST_SUITE_NAME
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300114 methodname = "{classname}.{methodname}"
115 testrail_name_template = "{title}"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300116 report_result = shared.upload_results_to_testrail(tempest_report_name, testSuiteName, methodname, testrail_name_template)
117 common.printMsg(report_result, "blue")
118 report_url = report_result.split("\n").each {
119 if (it.contains("[TestRun URL]")) {
120 common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
Dennis Dmitrievefe5c0b2018-10-24 20:35:26 +0300121 description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300122 }
123 }
Dennis Dmitrievee5ef232018-08-31 13:53:18 +0300124 }
125 }
126
127 if ('k8s' in stacks && k8s_conformance_report_name) {
128 stage("K8s conformance report") {
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 Dmitrieve4b831b2018-08-15 17:16:10 +0300155 testSuiteName = "LMA2.0_Automated"
156 methodname = "{methodname}"
157 testrail_name_template = "{title}"
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300158 report_result = shared.upload_results_to_testrail(stacklight_report_name, testSuiteName, methodname, testrail_name_template)
159 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
169 } catch (e) {
Dennis Dmitrievb08c0772018-10-17 15:10:26 +0300170 common.printMsg("Job is failed", "purple")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300171 throw e
172 } finally {
173 // reporting is failed for some reason
Dennis Dmitrievfbf42272018-10-23 00:19:50 +0300174 writeFile(file: "description.txt", text: description, encoding: "UTF-8")
Dennis Dmitrieve4b831b2018-08-15 17:16:10 +0300175 }
176 }
177}