Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 1 | /** |
| 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 Leontovich | f371844 | 2018-10-31 13:36:13 +0200 | [diff] [blame] | 13 | * TEMPEST_TEST_SUITE_NAME Name of tempest suite |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 14 | * TCP_QA_REFS Reference to the tcp-qa change on review.gerrithub.io, like refs/changes/46/418546/41 |
Vladimir Jigulin | 151097d | 2019-03-21 18:39:47 +0400 | [diff] [blame] | 15 | * TEST_PLAN_NAME_PREFIX Prefix of test plan name |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | @Library('tcp-qa')_ |
| 19 | |
| 20 | def common = new com.mirantis.mk.Common() |
| 21 | def shared = new com.mirantis.system_qa.SharedPipeline() |
| 22 | def stacks = shared.get_steps_list(PASSED_STEPS) |
| 23 | |
| 24 | if (! env.PARENT_NODE_NAME) { |
| 25 | error "'PARENT_NODE_NAME' must be set from the parent deployment job!" |
| 26 | } |
| 27 | |
| 28 | currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}" |
| 29 | |
| 30 | node ("${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 Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 35 | def description = '' |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 36 | try { |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 37 | |
| 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 Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 44 | def report_name = '' |
Vladimir Jigulin | 151097d | 2019-03-21 18:39:47 +0400 | [diff] [blame] | 45 | def testPlanNamePrefix = env.TEST_PLAN_NAME_PREFIX ?: '' |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 46 | def testSuiteName = '' |
| 47 | def methodname = '' |
| 48 | def testrail_name_template = '' |
| 49 | def reporter_extra_options = [] |
| 50 | |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 51 | def report_result = '' |
| 52 | def report_url = '' |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 53 | |
Dennis Dmitriev | 09ef69e | 2018-11-09 15:25:18 +0200 | [diff] [blame] | 54 | // deployment_report_name = "deployment_${ENV_NAME}.xml" |
Dennis Dmitriev | ec7ae97 | 2019-02-19 12:29:11 +0200 | [diff] [blame] | 55 | def deployment_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"deployment_${ENV_NAME}.xml\" -printf \"'%p'\" ", returnStdout: true).trim() |
Dennis Dmitriev | 09ef69e | 2018-11-09 15:25:18 +0200 | [diff] [blame] | 56 | // tcpqa_report_name =~ "nosetests.xml" |
Dennis Dmitriev | ec7ae97 | 2019-02-19 12:29:11 +0200 | [diff] [blame] | 57 | def tcpqa_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"nosetests.xml\" -printf \"'%p'\" ", returnStdout: true).trim() |
Dennis Dmitriev | 09ef69e | 2018-11-09 15:25:18 +0200 | [diff] [blame] | 58 | // tempest_report_name =~ "report_*.xml" |
Dennis Dmitriev | ec7ae97 | 2019-02-19 12:29:11 +0200 | [diff] [blame] | 59 | def tempest_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"report_*.xml\" -printf \"'%p'\" ", returnStdout: true).trim() |
Dennis Dmitriev | 09ef69e | 2018-11-09 15:25:18 +0200 | [diff] [blame] | 60 | // k8s_conformance_report_name =~ conformance_result.xml |
Dennis Dmitriev | ec7ae97 | 2019-02-19 12:29:11 +0200 | [diff] [blame] | 61 | def k8s_conformance_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_result.xml\" -printf \"'%p'\" ", returnStdout: true).trim() |
Dennis Dmitriev | 34fd300 | 2018-11-15 18:25:16 +0200 | [diff] [blame] | 62 | // k8s_conformance_report_name =~ conformance_virtlet_result.xml |
Dennis Dmitriev | ec7ae97 | 2019-02-19 12:29:11 +0200 | [diff] [blame] | 63 | def k8s_conformance_virtlet_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_virtlet_result.xml\" -printf \"'%p'\" ", returnStdout: true).trim() |
Dennis Dmitriev | 09ef69e | 2018-11-09 15:25:18 +0200 | [diff] [blame] | 64 | // stacklight_report_name =~ "stacklight_report.xml" or "report.xml" |
Dennis Dmitriev | ec7ae97 | 2019-02-19 12:29:11 +0200 | [diff] [blame] | 65 | def stacklight_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"*report.xml\"", returnStdout: true).trim() |
Dennis Dmitriev | 8565c34 | 2019-02-11 23:45:03 +0200 | [diff] [blame] | 66 | // cvp_sanity_report_name =~ cvp_sanity_report.xml |
Dennis Dmitriev | ec7ae97 | 2019-02-19 12:29:11 +0200 | [diff] [blame] | 67 | def cvp_sanity_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"cvp_sanity_results.xml\" -printf \"'%p'\" ", returnStdout: true).trim() |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 68 | 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 Dmitriev | 34fd300 | 2018-11-15 18:25:16 +0200 | [diff] [blame] | 72 | 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 Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 73 | common.printMsg(stacklight_report_name ? "Found stacklight-pytest report: ${stacklight_report_name}" : "stacklight-pytest report not found", stacklight_report_name ? "blue" : "red") |
Dennis Dmitriev | 8565c34 | 2019-02-11 23:45:03 +0200 | [diff] [blame] | 74 | 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 Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 75 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 76 | |
| 77 | if (deployment_report_name) { |
| 78 | stage("Deployment report") { |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 79 | 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 Jigulin | 151097d | 2019-03-21 18:39:47 +0400 | [diff] [blame] | 87 | report_result = shared.upload_results_to_testrail( |
| 88 | deployment_report_name, testSuiteName, methodname, testrail_name_template, |
| 89 | reporter_extra_options, testPlanNamePrefix=testPlanNamePrefix) |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 90 | 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 Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 94 | description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 95 | } |
| 96 | } |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 97 | } |
| 98 | } |
| 99 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 100 | if (tcpqa_report_name) { |
| 101 | stage("tcp-qa cases report") { |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 102 | 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 Jigulin | 151097d | 2019-03-21 18:39:47 +0400 | [diff] [blame] | 110 | report_result = shared.upload_results_to_testrail( |
| 111 | tcpqa_report_name, testSuiteName, methodname, testrail_name_template, |
| 112 | reporter_extra_options, testPlanNamePrefix=testPlanNamePrefix) |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 113 | 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 Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 117 | description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 118 | } |
| 119 | } |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 120 | } |
| 121 | } |
| 122 | |
| 123 | if ('openstack' in stacks && tempest_report_name) { |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 124 | stage("Tempest report") { |
Tatyana Leontovich | f371844 | 2018-10-31 13:36:13 +0200 | [diff] [blame] | 125 | testSuiteName = env.TEMPEST_TEST_SUITE_NAME |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 126 | methodname = "{classname}.{methodname}" |
| 127 | testrail_name_template = "{title}" |
Vladimir Jigulin | 151097d | 2019-03-21 18:39:47 +0400 | [diff] [blame] | 128 | report_result = shared.upload_results_to_testrail( |
| 129 | tempest_report_name, testSuiteName, methodname, testrail_name_template, |
| 130 | testPlanNamePrefix=testPlanNamePrefix) |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 131 | 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 Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 135 | description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 136 | } |
| 137 | } |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 138 | } |
| 139 | } |
| 140 | |
| 141 | if ('k8s' in stacks && k8s_conformance_report_name) { |
| 142 | stage("K8s conformance report") { |
Dennis Dmitriev | 265a1c7 | 2018-09-29 05:08:47 +0300 | [diff] [blame] | 143 | def k8s_version=shared.run_cmd_stdout("""\ |
Dennis Dmitriev | cf866e7 | 2018-10-09 17:51:43 +0300 | [diff] [blame] | 144 | . ./env_k8s_version; |
| 145 | echo "\$KUBE_SERVER_VERSION" |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 146 | """).trim().split().last() |
| 147 | testSuiteName = "[MCP][k8s]Hyperkube ${k8s_version}.x" |
| 148 | methodname = "{methodname}" |
| 149 | testrail_name_template = "{title}" |
| 150 | reporter_extra_options = [ |
Dennis Dmitriev | 74d7e75 | 2018-10-01 17:37:49 +0300 | [diff] [blame] | 151 | "--send-duplicates", |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 152 | "--testrail-add-missing-cases", |
| 153 | "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}", |
| 154 | "--testrail-case-section-name \'Conformance\'", |
| 155 | ] |
Vladimir Jigulin | 151097d | 2019-03-21 18:39:47 +0400 | [diff] [blame] | 156 | report_result = shared.upload_results_to_testrail( |
| 157 | k8s_conformance_report_name, testSuiteName, methodname, testrail_name_template, |
| 158 | reporter_extra_options, testPlanNamePrefix=testPlanNamePrefix) |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 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 Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 163 | description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 164 | } |
| 165 | } |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
Dennis Dmitriev | 34fd300 | 2018-11-15 18:25:16 +0200 | [diff] [blame] | 169 | 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 Jigulin | 151097d | 2019-03-21 18:39:47 +0400 | [diff] [blame] | 180 | 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 Dmitriev | 34fd300 | 2018-11-15 18:25:16 +0200 | [diff] [blame] | 183 | 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 Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 193 | if ('stacklight' in stacks && stacklight_report_name) { |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 194 | stage("stacklight-pytest report") { |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 195 | testSuiteName = "LMA2.0_Automated" |
| 196 | methodname = "{methodname}" |
| 197 | testrail_name_template = "{title}" |
Vladimir Jigulin | 151097d | 2019-03-21 18:39:47 +0400 | [diff] [blame] | 198 | report_result = shared.upload_results_to_testrail( |
| 199 | stacklight_report_name, testSuiteName, methodname, testrail_name_template, |
| 200 | testPlanNamePrefix=testPlanNamePrefix) |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 201 | 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 Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 205 | description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 206 | } |
| 207 | } |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 208 | } |
| 209 | } |
| 210 | |
Dennis Dmitriev | 8565c34 | 2019-02-11 23:45:03 +0200 | [diff] [blame] | 211 | 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 Jigulin | 151097d | 2019-03-21 18:39:47 +0400 | [diff] [blame] | 222 | report_result = shared.upload_results_to_testrail( |
| 223 | cvp_sanity_report_name, testSuiteName, methodname, testrail_name_template, |
| 224 | reporter_extra_options, testPlanNamePrefix=testPlanNamePrefix) |
Dennis Dmitriev | 8565c34 | 2019-02-11 23:45:03 +0200 | [diff] [blame] | 225 | 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 Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 235 | } catch (e) { |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 236 | common.printMsg("Job is failed", "purple") |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 237 | throw e |
| 238 | } finally { |
| 239 | // reporting is failed for some reason |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 240 | writeFile(file: "description.txt", text: description, encoding: "UTF-8") |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | } |