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 |
Hanna Arhipova | 5173aad | 2019-11-11 12:42:31 +0200 | [diff] [blame] | 14 | * TCP_QA_REFS Reference to the tcp-qa change on Gerrit, like refs/changes/46/418546/41 |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | @Library('tcp-qa')_ |
| 18 | |
| 19 | def common = new com.mirantis.mk.Common() |
| 20 | def shared = new com.mirantis.system_qa.SharedPipeline() |
| 21 | def stacks = shared.get_steps_list(PASSED_STEPS) |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 22 | def testPlanNamePrefix = env.TEST_PLAN_NAME_PREFIX ?: "[2019.2.0-update]System" |
| 23 | def testPlanName = env.TEST_PLAN_NAME ?: "${testPlanNamePrefix}-${MCP_VERSION}-${new Date().format('yyyy-MM-dd')}" |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 24 | |
| 25 | if (! env.PARENT_NODE_NAME) { |
| 26 | error "'PARENT_NODE_NAME' must be set from the parent deployment job!" |
| 27 | } |
| 28 | |
| 29 | currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}" |
| 30 | |
Hanna Arhipova | 705a289 | 2020-09-25 12:40:39 +0300 | [diff] [blame] | 31 | def find_latest(search_pattern) { |
| 32 | return "find ${PARENT_WORKSPACE} -name \"${search_pattern}\" -printf \"'%T@ %p \\n'\" | sort -r |head -n1|awk -F' ' '{ print \$2 }'" |
| 33 | } |
| 34 | |
Dennis Dmitriev | 1f08b0c | 2019-05-27 17:03:53 +0300 | [diff] [blame] | 35 | timeout(time: 2, unit: 'HOURS') { |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 36 | node ("${PARENT_NODE_NAME}") { |
| 37 | if (! fileExists("${PARENT_WORKSPACE}")) { |
| 38 | error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'." |
| 39 | } |
| 40 | dir("${PARENT_WORKSPACE}") { |
Hanna Arhipova | 705a289 | 2020-09-25 12:40:39 +0300 | [diff] [blame] | 41 | if (env.REPORT_FILE_URL) { |
| 42 | print "Download report from '${env.REPORT_FILE_URL}'" |
| 43 | file_text = new URL ("${env.REPORT_FILE_URL}").getText() |
| 44 | print "Copy downloaded file to workspace as ${REPORT_FILE_NAME}" |
| 45 | writeFile file: "${REPORT_FILE_NAME}", text: file_text |
| 46 | } |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 47 | def description = '' |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 48 | def exception_message = '' |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 49 | try { |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 50 | |
| 51 | if (env.TCP_QA_REFS) { |
| 52 | stage("Update working dir to patch ${TCP_QA_REFS}") { |
| 53 | shared.update_working_dir() |
| 54 | } |
| 55 | } |
| 56 | |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 57 | def report_name = '' |
| 58 | def testSuiteName = '' |
| 59 | def methodname = '' |
| 60 | def testrail_name_template = '' |
| 61 | def reporter_extra_options = [] |
| 62 | |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 63 | def report_url = '' |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 64 | |
Dennis Dmitriev | 09ef69e | 2018-11-09 15:25:18 +0200 | [diff] [blame] | 65 | // deployment_report_name = "deployment_${ENV_NAME}.xml" |
Hanna Arhipova | 705a289 | 2020-09-25 12:40:39 +0300 | [diff] [blame] | 66 | def deployment_report_name = sh(script: find_latest("deployment_${ENV_NAME}.xml"), returnStdout: true).trim() |
Dennis Dmitriev | 09ef69e | 2018-11-09 15:25:18 +0200 | [diff] [blame] | 67 | // tcpqa_report_name =~ "nosetests.xml" |
Hanna Arhipova | 705a289 | 2020-09-25 12:40:39 +0300 | [diff] [blame] | 68 | def tcpqa_report_name = sh(script: find_latest("nosetests.xml"), returnStdout: true).trim() |
Dennis Dmitriev | 09ef69e | 2018-11-09 15:25:18 +0200 | [diff] [blame] | 69 | // tempest_report_name =~ "report_*.xml" |
Hanna Arhipova | 705a289 | 2020-09-25 12:40:39 +0300 | [diff] [blame] | 70 | def tempest_report_name = sh(script: find_latest("report_*.xml"), returnStdout: true).trim() |
Dennis Dmitriev | 09ef69e | 2018-11-09 15:25:18 +0200 | [diff] [blame] | 71 | // stacklight_report_name =~ "stacklight_report.xml" or "report.xml" |
PGlazov | 271e795 | 2022-01-13 16:11:31 +0400 | [diff] [blame] | 72 | def stacklight_report_name = sh(script: find_latest("cvp-stacklight*results.xml"), returnStdout: true).trim() |
Dennis Dmitriev | 8565c34 | 2019-02-11 23:45:03 +0200 | [diff] [blame] | 73 | // cvp_sanity_report_name =~ cvp_sanity_report.xml |
PGlazov | 271e795 | 2022-01-13 16:11:31 +0400 | [diff] [blame] | 74 | def cvp_sanity_report_name = sh(script: find_latest("cvp-sanity*results.xml"), returnStdout: true).trim() |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 75 | common.printMsg(deployment_report_name ? "Found deployment report: ${deployment_report_name}" : "Deployment report not found", deployment_report_name ? "blue" : "red") |
| 76 | common.printMsg(tcpqa_report_name ? "Found tcp-qa report: ${tcpqa_report_name}" : "tcp-qa report not found", tcpqa_report_name ? "blue" : "red") |
| 77 | common.printMsg(tempest_report_name ? "Found tempest report: ${tempest_report_name}" : "tempest report not found", tempest_report_name ? "blue" : "red") |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 78 | 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] | 79 | 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] | 80 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 81 | if (deployment_report_name) { |
| 82 | stage("Deployment report") { |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 83 | testSuiteName = "[MCP] Integration automation" |
| 84 | methodname = '{methodname}' |
| 85 | testrail_name_template = '{title}' |
| 86 | reporter_extra_options = [ |
| 87 | "--testrail-add-missing-cases", |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 88 | ] |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 89 | ret = shared.upload_results_to_testrail(deployment_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options) |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 90 | common.printMsg(ret.stdout, "blue") |
Hanna Arhipova | b4e7457 | 2021-04-14 21:25:23 +0300 | [diff] [blame] | 91 | marked = shared.mark_test_results(testPlanName, testSuiteName) |
| 92 | common.printMsg(marked.stdout, "blue") |
| 93 | |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 94 | report_url = ret.stdout.split("\n").each { |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 95 | if (it.contains("[TestRun URL]")) { |
| 96 | common.printMsg("Found report URL: " + it.trim().split().last(), "blue") |
Dennis Dmitriev | 2700732 | 2019-05-03 19:21:44 +0300 | [diff] [blame] | 97 | description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 98 | } |
| 99 | } |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 100 | exception_message += ret.exception |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 101 | } |
| 102 | } |
| 103 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 104 | if (tcpqa_report_name) { |
| 105 | stage("tcp-qa cases report") { |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 106 | testSuiteName = "[MCP_X] integration cases" |
Hanna Arhipova | 7f2a175 | 2021-04-22 09:59:11 +0300 | [diff] [blame] | 107 | methodname = "{classname}.{methodname}" |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 108 | testrail_name_template = "{title}" |
| 109 | reporter_extra_options = [ |
| 110 | "--testrail-add-missing-cases", |
Hanna Arhipova | c1912a6 | 2019-12-04 10:21:50 +0200 | [diff] [blame] | 111 | // "--testrail_configuration_name tcp-qa", |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 112 | ] |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 113 | ret = shared.upload_results_to_testrail(tcpqa_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options) |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 114 | common.printMsg(ret.stdout, "blue") |
Hanna Arhipova | b4e7457 | 2021-04-14 21:25:23 +0300 | [diff] [blame] | 115 | marked = shared.mark_test_results(testPlanName, testSuiteName) |
| 116 | common.printMsg(marked.stdout, "blue") |
| 117 | |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 118 | report_url = ret.stdout.split("\n").each { |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 119 | if (it.contains("[TestRun URL]")) { |
| 120 | common.printMsg("Found report URL: " + it.trim().split().last(), "blue") |
Dennis Dmitriev | 2700732 | 2019-05-03 19:21:44 +0300 | [diff] [blame] | 121 | description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 122 | } |
| 123 | } |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 124 | exception_message += ret.exception |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 125 | } |
| 126 | } |
| 127 | |
| 128 | if ('openstack' in stacks && tempest_report_name) { |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 129 | stage("Tempest report") { |
Tatyana Leontovich | f371844 | 2018-10-31 13:36:13 +0200 | [diff] [blame] | 130 | testSuiteName = env.TEMPEST_TEST_SUITE_NAME |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 131 | methodname = "{classname}.{methodname}" |
| 132 | testrail_name_template = "{title}" |
Ekaterina Chernova | 26d8523 | 2019-10-25 12:35:15 +0300 | [diff] [blame] | 133 | reporter_extra_options = [ |
| 134 | "--send-duplicates", |
| 135 | "--testrail-add-missing-cases", |
Hanna Arhipova | c1912a6 | 2019-12-04 10:21:50 +0200 | [diff] [blame] | 136 | // "--testrail_configuration_name tcp-qa", |
Ekaterina Chernova | 26d8523 | 2019-10-25 12:35:15 +0300 | [diff] [blame] | 137 | ] |
| 138 | ret = shared.upload_results_to_testrail(tempest_report_name, |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 139 | testPlanName, |
Ekaterina Chernova | 26d8523 | 2019-10-25 12:35:15 +0300 | [diff] [blame] | 140 | testSuiteName, |
| 141 | methodname, |
| 142 | testrail_name_template, |
| 143 | reporter_extra_options) |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 144 | common.printMsg(ret.stdout, "blue") |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 145 | marked = shared.mark_test_results(testPlanName, testSuiteName) |
| 146 | common.printMsg(marked.stdout, "blue") |
| 147 | |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 148 | report_url = ret.stdout.split("\n").each { |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 149 | if (it.contains("[TestRun URL]")) { |
| 150 | common.printMsg("Found report URL: " + it.trim().split().last(), "blue") |
Dennis Dmitriev | 2700732 | 2019-05-03 19:21:44 +0300 | [diff] [blame] | 151 | description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 152 | } |
| 153 | } |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 154 | exception_message += ret.exception |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 155 | } |
| 156 | } |
| 157 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 158 | if ('stacklight' in stacks && stacklight_report_name) { |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 159 | stage("stacklight-pytest report") { |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 160 | testSuiteName = "LMA2.0_Automated" |
| 161 | methodname = "{methodname}" |
| 162 | testrail_name_template = "{title}" |
Hanna Arhipova | 40955d7 | 2019-11-04 14:38:42 +0200 | [diff] [blame] | 163 | reporter_extra_options = [ |
| 164 | "--testrail-add-missing-cases", |
| 165 | "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}", |
| 166 | ] |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 167 | ret = shared.upload_results_to_testrail(stacklight_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options) |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 168 | common.printMsg(ret.stdout, "blue") |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 169 | marked = shared.mark_test_results(testPlanName, testSuiteName) |
| 170 | common.printMsg(marked.stdout, "blue") |
| 171 | |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 172 | report_url = ret.stdout.split("\n").each { |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 173 | if (it.contains("[TestRun URL]")) { |
| 174 | common.printMsg("Found report URL: " + it.trim().split().last(), "blue") |
Dennis Dmitriev | 2700732 | 2019-05-03 19:21:44 +0300 | [diff] [blame] | 175 | description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 176 | } |
| 177 | } |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 178 | exception_message += ret.exception |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |
Dennis Dmitriev | 8565c34 | 2019-02-11 23:45:03 +0200 | [diff] [blame] | 182 | if ('cicd' in stacks && cvp_sanity_report_name) { |
| 183 | stage("CVP Sanity report") { |
| 184 | testSuiteName = "[MCP] cvp sanity" |
| 185 | methodname = '{methodname}' |
| 186 | testrail_name_template = '{title}' |
| 187 | reporter_extra_options = [ |
| 188 | "--send-duplicates", |
| 189 | "--testrail-add-missing-cases", |
Hanna Arhipova | c1912a6 | 2019-12-04 10:21:50 +0200 | [diff] [blame] | 190 | // "--testrail_configuration_name tcp-qa", |
Dennis Dmitriev | 8565c34 | 2019-02-11 23:45:03 +0200 | [diff] [blame] | 191 | ] |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 192 | uploaded = shared.upload_results_to_testrail(cvp_sanity_report_name, testPlanName, testSuiteName, methodname, testrail_name_template, reporter_extra_options) |
| 193 | common.printMsg(uploaded.stdout, "blue") |
| 194 | marked = shared.mark_test_results(testPlanName, testSuiteName) |
| 195 | common.printMsg(marked.stdout, "blue") |
| 196 | |
| 197 | report_url = uploaded.stdout.split("\n").each { |
Dennis Dmitriev | 8565c34 | 2019-02-11 23:45:03 +0200 | [diff] [blame] | 198 | if (it.contains("[TestRun URL]")) { |
| 199 | common.printMsg("Found report URL: " + it.trim().split().last(), "blue") |
Dennis Dmitriev | 2700732 | 2019-05-03 19:21:44 +0300 | [diff] [blame] | 200 | description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>" |
Dennis Dmitriev | 8565c34 | 2019-02-11 23:45:03 +0200 | [diff] [blame] | 201 | } |
| 202 | } |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 203 | exception_message += ret.exception |
Dennis Dmitriev | 8565c34 | 2019-02-11 23:45:03 +0200 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
Hanna Arhipova | 1b92f9b | 2020-10-05 15:50:25 +0300 | [diff] [blame] | 207 | |
Dennis Dmitriev | fd0b78c | 2019-05-30 00:16:04 +0300 | [diff] [blame] | 208 | // Check if there were any exceptions during reporting |
| 209 | if (exception_message) { |
| 210 | throw new Exception(exception_message) |
| 211 | } |
| 212 | |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 213 | } catch (e) { |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 214 | common.printMsg("Job is failed", "purple") |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 215 | throw e |
| 216 | } finally { |
| 217 | // reporting is failed for some reason |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 218 | writeFile(file: "description.txt", text: description, encoding: "UTF-8") |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | } |
Dennis Dmitriev | 1f08b0c | 2019-05-27 17:03:53 +0300 | [diff] [blame] | 222 | } // timeout |