Add getting logs from jobs
Related-Prod:PROD-36500
Change-Id: I4f8a999ceb03fe7a80f9bbf9a2d9252084ef95f1
diff --git a/tcp_tests/managers/drivetrain_manager.py b/tcp_tests/managers/drivetrain_manager.py
index f65892e..dbc5096 100644
--- a/tcp_tests/managers/drivetrain_manager.py
+++ b/tcp_tests/managers/drivetrain_manager.py
@@ -11,11 +11,11 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-
from tcp_tests.managers.execute_commands import ExecuteCommandsMixin
from tcp_tests.utils import run_jenkins_job
from tcp_tests.utils import get_jenkins_job_stages
from tcp_tests import logger
+from tcp_tests.managers.jenkins import client
LOG = logger.logger
@@ -62,6 +62,11 @@
jenkins_url, jenkins_user, jenkins_pass = self.get_jenkins_creds(
tgt=jenkins_tgt)
+ jenkins = client.JenkinsClient(host=jenkins_url,
+ username=jenkins_user,
+ password=jenkins_pass)
+ build_number = jenkins.job_info(job_name)['nextBuildNumber']
+
job_result = run_jenkins_job.run_job(
host=jenkins_url,
username=jenkins_user,
@@ -83,6 +88,11 @@
.format(description=description,
stages='\n'.join(stages))
+ job_log = jenkins.get_build_output(job_name, build_number)
+
+ with open('tmp/' + job_name + str(build_number) + '.log', 'wb') as f:
+ f.write(job_log)
+
if job_result != 'SUCCESS':
LOG.warning("{0}\n{1}".format(description, '\n'.join(stages)))
return job_result, job_description
diff --git a/tcp_tests/tests/system/test_backup_restore_galera.py b/tcp_tests/tests/system/test_backup_restore_galera.py
index 573756a..ce782b2 100644
--- a/tcp_tests/tests/system/test_backup_restore_galera.py
+++ b/tcp_tests/tests/system/test_backup_restore_galera.py
@@ -82,7 +82,6 @@
"""
dt = drivetrain_actions
-
show_step(1)
ctl_node = underlay_actions.get_target_node_names(target='ctl')[0]
print(ctl_node)
diff --git a/tcp_tests/tests/system/test_cvp_pipelines.py b/tcp_tests/tests/system/test_cvp_pipelines.py
index 41c95fe..c7c919c 100644
--- a/tcp_tests/tests/system/test_cvp_pipelines.py
+++ b/tcp_tests/tests/system/test_cvp_pipelines.py
@@ -207,6 +207,9 @@
ntp_skipped_nodes = ''
job_name = 'cvp-sanity'
+ server = jenkins.Jenkins(jenkins_url, jenkins_user, jenkins_pass)
+ build_number = server.get_job_info(job_name)['nextBuildNumber']
+
skipped_packages = ("python-setuptools,"
"python-pkg-resources,xunitmerge,"
"python-gnocchiclient, "
@@ -250,7 +253,8 @@
# Download XML report
show_step(4)
destination_name = os.path.join(settings.LOGS_DIR,
- "cvp_sanity_results.xml")
+ "tmp/" + job_name + "_"
+ + str(build_number) + "_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:
@@ -259,8 +263,26 @@
username=jenkins_user,
password=jenkins_pass,
job_name=job_name,
- build_number='lastBuild',
- artifact_path='validation_artifacts/cvp-sanity_report.xml',
+ build_number=build_number,
+ artifact_path='validation_artifacts/' + job_name
+ + '_report.xml',
+ destination_name=destination_name)
+ except jenkins.NotFoundException:
+ raise jenkins.NotFoundException("{0}\n{1}".format(
+ description, '\n'.join(stages)))
+
+ destination_name = os.path.join(settings.LOGS_DIR,
+ "tmp/" + job_name + "_"
+ + str(build_number) + "_full.log")
+
+ try:
+ get_jenkins_job_artifact.download_artifact(
+ host=jenkins_url,
+ username=jenkins_user,
+ password=jenkins_pass,
+ job_name=job_name,
+ build_number=build_number,
+ artifact_path='validation_artifacts/full.log',
destination_name=destination_name)
except jenkins.NotFoundException:
raise jenkins.NotFoundException("{0}\n{1}".format(
@@ -370,6 +392,9 @@
jenkins_build_timeout = 50 * 60
job_name = 'cvp-stacklight'
+ server = jenkins.Jenkins(jenkins_url, jenkins_user, jenkins_pass)
+ build_number = server.get_job_info(job_name)['nextBuildNumber']
+
job_parameters = {
"EXTRA_PARAMS": """
envs:
@@ -406,7 +431,8 @@
# Download XML report
show_step(4)
destination_name = os.path.join(settings.LOGS_DIR,
- "stacklight_report.xml")
+ "tmp/" + job_name + "_"
+ + str(build_number) + "_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: