From ec5b10fc34d7a24298810c852ec2358c84825413 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Fri, 9 Sep 2016 10:44:51 +0100 Subject: [PATCH] Compress test execution logs The volume of logs we collect in CI jobs are extensive. This patch ensures that the logs collected are compressed to reduce the space taken in CI systems. PYTHONUNBUFFERED is also set to ensure that the console log from the CI jobs is recorded in the exact order of execution. Change-Id: I867081cb1f263e554f7dbe02791a46c9d2cef60f Related-Bug: #1620849 --- bindep.txt | 3 +++ tox.ini | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/bindep.txt b/bindep.txt index 931e963d..fe589259 100644 --- a/bindep.txt +++ b/bindep.txt @@ -36,3 +36,6 @@ python-ndg-httpsclient [platform:ubuntu !platform:ubuntu-trusty] python2-pyasn1 [platform:rpm] pyOpenSSL [platform:rpm] python-ndg_httpsclient [platform:rpm] + +# Required for compressing collected log files in CI +gzip diff --git a/tox.ini b/tox.ini index c9b18e48..4e73a590 100644 --- a/tox.ini +++ b/tox.ini @@ -26,6 +26,7 @@ whitelist_externals = rm setenv = VIRTUAL_ENV={envdir} + PYTHONUNBUFFERED=1 [testenv:docs] @@ -145,9 +146,17 @@ install_command = pip install -U --force-reinstall {opts} {packages} +[testenv:func_logs] +commands = + bash -c 'mkdir -p {toxinidir}/logs' + bash -c 'rsync --archive --verbose --ignore-errors /var/log/ /openstack/log/ {toxinidir}/logs/ || true' + bash -c 'find "{toxinidir}/logs/" -type f | sed "p;s|$|.txt|" | xargs -n2 mv' + bash -c 'command gzip --best --recursive "{toxinidir}/logs/"' + + [testenv:functional] # Ignore_errors is set to true so that the logs are collected at the -# end of the run. This will not produce a failse positive. Any +# end of the run. This will not produce a false positive. Any # exception will be mark the run as failed and exit 1 after all of # the commands have been iterated through. ignore_errors = True @@ -166,12 +175,15 @@ commands = -e "rolename={toxinidir}" \ -e "install_test_packages=True" \ {toxinidir}/tests/test.yml -vvvv - bash -c 'mkdir -p {toxinidir}/logs' - bash -c 'rsync -av --ignore-errors /var/log/ /openstack/log/ {toxinidir}/logs/ || true' - + {[testenv:func_logs]commands} [testenv:func_lxd] +# Ignore_errors is set to true so that the logs are collected at the +# end of the run. This will not produce a false positive. Any +# exception will be mark the run as failed and exit 1 after all of +# the commands have been iterated through. +ignore_errors = True # NOTE(michaelgugino): this target tests nova with lxd install_command = {[testenv:func_base]install_command} @@ -186,9 +198,7 @@ commands = -e "rolename={toxinidir}" \ -e "install_test_packages=True" \ {toxinidir}/tests/test.yml -vvvv - bash -c 'mkdir -p {toxinidir}/logs' - bash -c 'rsync -av --ignore-errors /var/log/ /openstack/log/ {toxinidir}/logs/ || true' - + {[testenv:func_logs]commands} [testenv:linters]