Add getting logs from jobs
Related-Prod:PROD-36500
Change-Id: I4f8a999ceb03fe7a80f9bbf9a2d9252084ef95f1
diff --git a/jobs/pipelines/swarm-run-pytest.groovy b/jobs/pipelines/swarm-run-pytest.groovy
index 1771b5d..65004b9 100644
--- a/jobs/pipelines/swarm-run-pytest.groovy
+++ b/jobs/pipelines/swarm-run-pytest.groovy
@@ -64,6 +64,8 @@
export ${it}_installed=true"""}.join("\n")
shared.run_sh(sources + installed + """
+ mkdir tmp
+ export PYTHONHTTPSVERIFY=0
export TESTS_CONFIGS=${ENV_NAME}_salt_deployed.ini
export ENV_MANAGER=$ENV_MANAGER # use 'hardware' fixture to manage fuel-devops environment
export salt_master_host=\$SALT_MASTER_IP # skip salt_deployed fixture
@@ -76,6 +78,12 @@
""")
+ archiveArtifacts artifacts: "tmp/*"
+ shared.run_sh("""
+ cd ${PARENT_WORKSPACE}
+ rm -rf tmp/
+ """)
+
def snapshot_name = "test_completed"
shared.download_logs("test_completed_${ENV_NAME}")
diff --git a/src/com/mirantis/system_qa/SharedPipeline.groovy b/src/com/mirantis/system_qa/SharedPipeline.groovy
index e83a94b..73a106a 100644
--- a/src/com/mirantis/system_qa/SharedPipeline.groovy
+++ b/src/com/mirantis/system_qa/SharedPipeline.groovy
@@ -396,8 +396,8 @@
]
common.printMsg("Start building job 'swarm-run-pytest' with parameters:", "purple")
common.prettyPrint(parameters)
- build job: 'swarm-run-pytest',
- parameters: parameters
+ swarm_run_pytest_build = build(job: 'swarm-run-pytest', parameters: parameters)
+ copyArtifacts(projectName: 'swarm-run-pytest', selector: specific(swarm_run_pytest_build.getId()))
}
def swarm_testrail_report(String passed_steps, String node_with_reports) {
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: