Add reporting of [CVP Sanity] results
- add a new method get_artifact() to JenkinsClient
- add a CLI tool get_jenkins_job_artifact.py , example usage:
export ENV_NAME=cookied-cicd-queens-dvr-sl
. tcp_tests/utils/env_salt
. tcp_tests/utils/env_jenkins_cicd
tcp_tests/utils/get_jenkins_job_artifact.py \
--job-name cvp-sanity \
--build-number lastBuild \
--artifact-path validation_artifacts/cvp-sanity_report.xml \
--destination-name ./cvp-sanity_report.xml
- add the XML report downloader to the test "test_run_cvp_func_sanity"
- add new report type "CVP Sanity" to the testrail reporter
swarm-testrail-report.groovy
Closes-Bug: #PROD-25356
Change-Id: Ic34d76c62c7f70ada5b941e3ffc5b22e1be769d0
diff --git a/tcp_tests/tests/system/test_cvp_pipelines.py b/tcp_tests/tests/system/test_cvp_pipelines.py
index 80154a1..cb6a5bb 100644
--- a/tcp_tests/tests/system/test_cvp_pipelines.py
+++ b/tcp_tests/tests/system/test_cvp_pipelines.py
@@ -12,12 +12,15 @@
# License for the specific language governing permissions and limitations
# under the License.
+import jenkins
import pytest
+import os
from tcp_tests import logger
from tcp_tests import settings
from tcp_tests.utils import run_jenkins_job
from tcp_tests.utils import get_jenkins_job_stages
+from tcp_tests.utils import get_jenkins_job_artifact
LOG = logger.logger
@@ -100,6 +103,7 @@
1. Get CICD Jenkins access credentials from salt
2. Run job cvp-sanity
3. Get passed stages from cvp-sanity
+ 4. Download XML report from the job
"""
salt = salt_actions
show_step(1)
@@ -145,9 +149,26 @@
LOG.info(description)
LOG.info('\n'.join(stages))
-
- assert cvp_func_sanity_result == 'SUCCESS', "{0}\n{1}".format(
- description, '\n'.join(stages))
+ LOG.info('Job {0} result: {1}'.format(job_name,
+ cvp_func_sanity_result))
+ # Download XML report
+ show_step(4)
+ destination_name = os.path.join(settings.LOGS_DIR,
+ "cvp_sanity_results.xml")
+ # Do not fail the test case when the job is failed, but
+ # artifact with the XML report is present in the job.
+ try:
+ get_jenkins_job_artifact.download_artifact(
+ host=jenkins_url,
+ username=jenkins_user,
+ password=jenkins_pass,
+ job_name=job_name,
+ build_number='lastBuild',
+ artifact_path='validation_artifacts/cvp-sanity_report.xml',
+ destination_name=destination_name)
+ except jenkins.NotFoundException:
+ raise jenkins.NotFoundException("{0}\n{1}".format(
+ description, '\n'.join(stages)))
@pytest.mark.grab_versions
@pytest.mark.parametrize("_", [settings.ENV_NAME])