Allow upload report from file
Allow add test reports to specific testPlan
PROD-35718
Change-Id: I4c2e10f5357988549533dad39ea59fd50d131b02
diff --git a/jobs/pipelines/swarm-testrail-report.groovy b/jobs/pipelines/swarm-testrail-report.groovy
index 2df04e0..17b770f 100644
--- a/jobs/pipelines/swarm-testrail-report.groovy
+++ b/jobs/pipelines/swarm-testrail-report.groovy
@@ -26,12 +26,22 @@
currentBuild.description = "${PARENT_NODE_NAME}:${ENV_NAME}"
+def find_latest(search_pattern) {
+ return "find ${PARENT_WORKSPACE} -name \"${search_pattern}\" -printf \"'%T@ %p \\n'\" | sort -r |head -n1|awk -F' ' '{ print \$2 }'"
+}
+
timeout(time: 2, unit: 'HOURS') {
node ("${PARENT_NODE_NAME}") {
if (! fileExists("${PARENT_WORKSPACE}")) {
error "'PARENT_WORKSPACE' contains path to non-existing directory ${PARENT_WORKSPACE} on the node '${PARENT_NODE_NAME}'."
}
dir("${PARENT_WORKSPACE}") {
+ if (env.REPORT_FILE_URL) {
+ print "Download report from '${env.REPORT_FILE_URL}'"
+ file_text = new URL ("${env.REPORT_FILE_URL}").getText()
+ print "Copy downloaded file to workspace as ${REPORT_FILE_NAME}"
+ writeFile file: "${REPORT_FILE_NAME}", text: file_text
+ }
def description = ''
def exception_message = ''
try {
@@ -51,24 +61,18 @@
def report_url = ''
// deployment_report_name = "deployment_${ENV_NAME}.xml"
- def deployment_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"deployment_${ENV_NAME}.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
+ def deployment_report_name = sh(script: find_latest("deployment_${ENV_NAME}.xml"), returnStdout: true).trim()
// tcpqa_report_name =~ "nosetests.xml"
- def tcpqa_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"nosetests.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
+ def tcpqa_report_name = sh(script: find_latest("nosetests.xml"), returnStdout: true).trim()
// tempest_report_name =~ "report_*.xml"
- def tempest_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"report_*.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
- // k8s_conformance_report_name =~ conformance_result.xml
- def k8s_conformance_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_result.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
- // k8s_conformance_report_name =~ conformance_virtlet_result.xml
- def k8s_conformance_virtlet_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"conformance_virtlet_result.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
+ def tempest_report_name = sh(script: find_latest("report_*.xml"), returnStdout: true).trim()
// stacklight_report_name =~ "stacklight_report.xml" or "report.xml"
- def stacklight_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"*report.xml\"", returnStdout: true).trim()
+ def stacklight_report_name = sh(script: find_latest("*report.xml"), returnStdout: true).trim()
// cvp_sanity_report_name =~ cvp_sanity_report.xml
- def cvp_sanity_report_name = sh(script: "find ${PARENT_WORKSPACE} -name \"cvp_sanity_results.xml\" -printf \"'%p'\" ", returnStdout: true).trim()
+ def cvp_sanity_report_name = sh(script: find_latest("cvp_sanity_results.xml"), returnStdout: true).trim()
common.printMsg(deployment_report_name ? "Found deployment report: ${deployment_report_name}" : "Deployment report not found", deployment_report_name ? "blue" : "red")
common.printMsg(tcpqa_report_name ? "Found tcp-qa report: ${tcpqa_report_name}" : "tcp-qa report not found", tcpqa_report_name ? "blue" : "red")
common.printMsg(tempest_report_name ? "Found tempest report: ${tempest_report_name}" : "tempest report not found", tempest_report_name ? "blue" : "red")
- 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")
- 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")
common.printMsg(stacklight_report_name ? "Found stacklight-pytest report: ${stacklight_report_name}" : "stacklight-pytest report not found", stacklight_report_name ? "blue" : "red")
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")
@@ -140,56 +144,6 @@
}
}
- if ('k8s' in stacks && k8s_conformance_report_name) {
- stage("K8s conformance report") {
- def k8s_version=shared.run_cmd_stdout("""\
- . ./env_k8s_version;
- echo "\$KUBE_SERVER_VERSION"
- """).trim().split().last()
- testSuiteName = "[MCP][k8s]Hyperkube ${k8s_version}.x"
- methodname = "{methodname}"
- testrail_name_template = "{title}"
- reporter_extra_options = [
- "--send-duplicates",
- "--testrail-add-missing-cases",
- "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
- "--testrail-case-section-name \'Conformance\'",
- ]
- ret = shared.upload_results_to_testrail(k8s_conformance_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
- common.printMsg(ret.stdout, "blue")
- report_url = ret.stdout.split("\n").each {
- if (it.contains("[TestRun URL]")) {
- common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
- description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
- }
- }
- exception_message += ret.exception
- }
- }
-
- if ('k8s' in stacks && k8s_conformance_virtlet_report_name) {
- stage("K8s conformance virtlet report") {
- testSuiteName = "[k8s] Virtlet"
- methodname = "{methodname}"
- testrail_name_template = "{title}"
- reporter_extra_options = [
- "--send-duplicates",
- "--testrail-add-missing-cases",
- "--testrail-case-custom-fields {\\\"custom_qa_team\\\":\\\"9\\\"}",
- "--testrail-case-section-name \'Conformance\'",
- ]
- ret = shared.upload_results_to_testrail(k8s_conformance_virtlet_report_name, testSuiteName, methodname, testrail_name_template, reporter_extra_options)
- common.printMsg(ret.stdout, "blue")
- report_url = ret.stdout.split("\n").each {
- if (it.contains("[TestRun URL]")) {
- common.printMsg("Found report URL: " + it.trim().split().last(), "blue")
- description += "<a href=" + it.trim().split().last() + ">${testSuiteName}</a><br>"
- }
- }
- exception_message += ret.exception
- }
- }
-
if ('stacklight' in stacks && stacklight_report_name) {
stage("stacklight-pytest report") {
testSuiteName = "LMA2.0_Automated"
diff --git a/src/com/mirantis/system_qa/SharedPipeline.groovy b/src/com/mirantis/system_qa/SharedPipeline.groovy
index 9edd241..6b5f82c 100644
--- a/src/com/mirantis/system_qa/SharedPipeline.groovy
+++ b/src/com/mirantis/system_qa/SharedPipeline.groovy
@@ -413,7 +413,7 @@
string(name: 'PARENT_WORKSPACE', value: pwd()),
string(name: 'TCP_QA_REFS', value: "${tcp_qa_refs}"),
string(name: 'TEMPEST_TEST_SUITE_NAME', value: "${tempest_test_suite_name}"),
- string(name: 'TEST_PLAN_NAME_PREFIX', value: "${test_plan_name_prefix}"),
+ string(name: 'TEST_PLAN_NAME_PREFIX', value: "${test_plan_name_prefix}")
]
common.printMsg("Start building job 'swarm-testrail-report' with parameters:", "purple")
common.prettyPrint(parameters)
@@ -686,7 +686,7 @@
def testrailURL = "https://mirantis.testrail.com"
def testrailProject = "Mirantis Cloud Platform"
def testPlanNamePrefix = env.TEST_PLAN_NAME_PREFIX ?: "[2019.2.0-update]System"
- def testPlanName = "${testPlanNamePrefix}-${MCP_VERSION}-${new Date().format('yyyy-MM-dd')}"
+ def testPlanName = env.TEST_PLAN_NAME ?: "${testPlanNamePrefix}-${MCP_VERSION}-${new Date().format('yyyy-MM-dd')}"
def testrailMilestone = "MCP1.1"
def testrailCaseMaxNameLenght = 250
def jobURL = env.BUILD_URL