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 |
| 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 | |
| 18 | def common = new com.mirantis.mk.Common() |
| 19 | def shared = new com.mirantis.system_qa.SharedPipeline() |
| 20 | def stacks = shared.get_steps_list(PASSED_STEPS) |
| 21 | |
| 22 | if (! env.PARENT_NODE_NAME) { |
| 23 | error "'PARENT_NODE_NAME' must be set from the parent deployment job!" |
| 24 | } |
| 25 | |
| 26 | currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}" |
| 27 | |
| 28 | node ("${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 Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 33 | def description = '' |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 34 | try { |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 35 | |
| 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 Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 42 | def report_name = '' |
| 43 | def testSuiteName = '' |
| 44 | def methodname = '' |
| 45 | def testrail_name_template = '' |
| 46 | def reporter_extra_options = [] |
| 47 | |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 48 | def report_result = '' |
| 49 | def report_url = '' |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 50 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 51 | 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 Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 61 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 62 | |
| 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 Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 74 | 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 Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 79 | description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 80 | } |
| 81 | } |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 82 | } |
| 83 | } |
| 84 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 85 | if (tcpqa_report_name) { |
| 86 | stage("tcp-qa cases report") { |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 87 | // tcpqa_report_name =~ "nosetests.xml" |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 88 | 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 Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 96 | 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 Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 101 | description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 102 | } |
| 103 | } |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
| 107 | if ('openstack' in stacks && tempest_report_name) { |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 108 | stage("Tempest report") { |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 109 | // tempest_report_name =~ "report_*.xml" |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 110 | testSuiteName = "[MCP1.1_PIKE]Tempest" |
| 111 | methodname = "{classname}.{methodname}" |
| 112 | testrail_name_template = "{title}" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 113 | 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 Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 118 | description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 119 | } |
| 120 | } |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 121 | } |
| 122 | } |
| 123 | |
| 124 | if ('k8s' in stacks && k8s_conformance_report_name) { |
| 125 | stage("K8s conformance report") { |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 126 | // 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 Dmitriev | 265a1c7 | 2018-09-29 05:08:47 +0300 | [diff] [blame] | 129 | def k8s_version=shared.run_cmd_stdout("""\ |
Dennis Dmitriev | cf866e7 | 2018-10-09 17:51:43 +0300 | [diff] [blame] | 130 | . ./env_k8s_version; |
| 131 | echo "\$KUBE_SERVER_VERSION" |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 132 | """).trim().split().last() |
| 133 | testSuiteName = "[MCP][k8s]Hyperkube ${k8s_version}.x" |
| 134 | methodname = "{methodname}" |
| 135 | testrail_name_template = "{title}" |
| 136 | reporter_extra_options = [ |
Dennis Dmitriev | 74d7e75 | 2018-10-01 17:37:49 +0300 | [diff] [blame] | 137 | "--send-duplicates", |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 138 | "--testrail-add-missing-cases", |
| 139 | "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}", |
| 140 | "--testrail-case-section-name \'Conformance\'", |
| 141 | ] |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 142 | 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 Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 147 | description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 148 | } |
| 149 | } |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | |
Dennis Dmitriev | ee5ef23 | 2018-08-31 13:53:18 +0300 | [diff] [blame] | 153 | if ('stacklight' in stacks && stacklight_report_name) { |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 154 | stage("stacklight-pytest report") { |
Dennis Dmitriev | eb50ce1 | 2018-09-27 13:34:32 +0300 | [diff] [blame] | 155 | // stacklight_report_name =~ "stacklight_report.xml" |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 156 | testSuiteName = "LMA2.0_Automated" |
| 157 | methodname = "{methodname}" |
| 158 | testrail_name_template = "{title}" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 159 | 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 Dmitriev | efe5c0b | 2018-10-24 20:35:26 +0300 | [diff] [blame] | 164 | description += "\n<a href=" + it.trim().split().last() + ">${testSuiteName}</a>" |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 165 | } |
| 166 | } |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 167 | } |
| 168 | } |
| 169 | |
| 170 | } catch (e) { |
Dennis Dmitriev | b08c077 | 2018-10-17 15:10:26 +0300 | [diff] [blame] | 171 | common.printMsg("Job is failed", "purple") |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 172 | throw e |
| 173 | } finally { |
| 174 | // reporting is failed for some reason |
Dennis Dmitriev | fbf4227 | 2018-10-23 00:19:50 +0300 | [diff] [blame] | 175 | writeFile(file: "description.txt", text: description, encoding: "UTF-8") |
Dennis Dmitriev | e4b831b | 2018-08-15 17:16:10 +0300 | [diff] [blame] | 176 | } |
| 177 | } |
| 178 | } |