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