Browse Source

Delete post_test_hook.generate_test_logs

Log files as .txt files, don't zip them, and put them where
they need to be instead of copy them there in the post gate
hook. The benefit to doing this is that we'll get logs
for tests even if the job timed out.

Change-Id: I4bfd27534c827aed3cbd7b43d7d1289480ea4806
Related-Bug: #1567668
changes/94/303594/6
Assaf Muller 6 years ago
committed by Jakub Libosvar
parent
commit
8adc737cd1
  1. 6
      TESTING.rst
  2. 4
      neutron/tests/common/helpers.py
  3. 19
      neutron/tests/contrib/post_test_hook.sh
  4. 8
      neutron/tests/fullstack/base.py
  5. 6
      neutron/tests/functional/base.py
  6. 2
      tox.ini

6
TESTING.rst

@ -502,11 +502,11 @@ tools/configure_for_func_testing.sh is advised (As described above).
When running full-stack tests on a clean VM for the first time, we
advise to run ./stack.sh successfully to make sure all Neutron's
dependencies are met. Full-stack based Neutron daemons produce logs to a
sub-folder in /tmp/dsvm-fullstack-logs (for example, a test named
"test_example" will produce logs to /tmp/dsvm-fullstack-logs/test_example/),
sub-folder in /opt/stack/logs/dsvm-fullstack-logs (for example, a test named
"test_example" will produce logs to /opt/stack/logs/dsvm-fullstack-logs/test_example/),
so that will be a good place to look if your test is failing.
Logging from the test infrastructure itself is placed in:
/tmp/dsvm-fullstack-logs/test_example.log.
/opt/stack/logs/dsvm-fullstack-logs/test_example.log.
Fullstack test suite assumes 240.0.0.0/4 (Class E) range in root namespace of
the test machine is available for its usage.

4
neutron/tests/common/helpers.py

@ -45,6 +45,10 @@ def find_sample_file(filename):
path=os.path.join(neutron.__path__[0], '..', 'etc'))
def get_test_log_path():
return os.environ.get('OS_LOG_PATH', '/tmp')
class FakePlugin(common_db_mixin.CommonDbMixin,
agents_db.AgentDbMixin):
pass

19
neutron/tests/contrib/post_test_hook.sh

@ -7,19 +7,6 @@ SCRIPTS_DIR="/usr/os-testr-env/bin/"
venv=${1:-"dsvm-functional"}
function generate_test_logs {
local path="$1"
# Compress all $path/*.txt files and move the directories holding those
# files to /opt/stack/logs. Files with .log suffix have their
# suffix changed to .txt (so browsers will know to open the compressed
# files and not download them).
if [ -d "$path" ]
then
sudo find $path -iname "*.log" -type f -exec mv {} {}.txt \; -exec gzip -9 {}.txt \;
sudo mv $path/* /opt/stack/logs/
fi
}
function generate_testr_results {
# Give job user rights to access tox logs
sudo -H -u $owner chmod o+rw .
@ -31,18 +18,12 @@ function generate_testr_results {
gzip -9 ./testr_results.html
sudo mv ./*.gz /opt/stack/logs/
fi
if [[ "$venv" == dsvm-functional* ]] || [[ "$venv" == dsvm-fullstack* ]]
then
generate_test_logs $log_dir
fi
}
if [[ "$venv" == dsvm-functional* ]] || [[ "$venv" == dsvm-fullstack* ]]
then
owner=stack
sudo_env=
log_dir="/tmp/${venv}-logs"
# Set owner permissions according to job's requirements.
cd $NEUTRON_DIR

8
neutron/tests/fullstack/base.py

@ -12,18 +12,22 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
from oslo_config import cfg
from oslo_db.sqlalchemy import test_base
from neutron.db.migration import cli as migration
from neutron.tests import base as tests_base
from neutron.tests.common import base
from neutron.tests.common import helpers
from neutron.tests.fullstack.resources import client as client_resource
from neutron.tests import tools
# This is the directory from which infra fetches log files for fullstack tests
DEFAULT_LOG_DIR = '/tmp/dsvm-fullstack-logs/'
DEFAULT_LOG_DIR = os.path.join(helpers.get_test_log_path(),
'dsvm-fullstack-logs')
class BaseFullStackTestCase(base.MySQLTestCase):
@ -33,7 +37,7 @@ class BaseFullStackTestCase(base.MySQLTestCase):
super(BaseFullStackTestCase, self).setUp()
tests_base.setup_test_logging(
cfg.CONF, DEFAULT_LOG_DIR, '%s.log' % self.get_name())
cfg.CONF, DEFAULT_LOG_DIR, '%s.txt' % self.get_name())
# NOTE(ihrachys): seed should be reset before environment fixture below
# since the latter starts services that may rely on generated port

6
neutron/tests/functional/base.py

@ -21,18 +21,20 @@ from neutron.agent.common import config
from neutron.agent.linux import utils
from neutron.tests import base
from neutron.tests.common import base as common_base
from neutron.tests.common import helpers
SUDO_CMD = 'sudo -n'
# This is the directory from which infra fetches log files for functional tests
DEFAULT_LOG_DIR = '/tmp/dsvm-functional-logs/'
DEFAULT_LOG_DIR = os.path.join(helpers.get_test_log_path(),
'dsvm-functional-logs')
class BaseLoggingTestCase(base.BaseTestCase):
def setUp(self):
super(BaseLoggingTestCase, self).setUp()
base.setup_test_logging(
cfg.CONF, DEFAULT_LOG_DIR, "%s.log" % self.id())
cfg.CONF, DEFAULT_LOG_DIR, "%s.txt" % self.id())
class BaseSudoTestCase(BaseLoggingTestCase):

2
tox.ini

@ -28,6 +28,7 @@ setenv = OS_SUDO_TESTING=1
OS_ROOTWRAP_CMD=sudo {envdir}/bin/neutron-rootwrap {envdir}/etc/neutron/rootwrap.conf
OS_ROOTWRAP_DAEMON_CMD=sudo {envdir}/bin/neutron-rootwrap-daemon {envdir}/etc/neutron/rootwrap.conf
OS_FAIL_ON_MISSING_DEPS=1
OS_LOG_PATH={env:OS_LOG_PATH:/opt/stack/logs}
commands = false
[testenv:functional]
@ -35,6 +36,7 @@ basepython = python2.7
setenv = {[testenv]setenv}
{[testenv:common]setenv}
OS_TEST_PATH=./neutron/tests/functional
OS_LOG_PATH={env:OS_LOG_PATH:/opt/stack/logs}
deps =
{[testenv]deps}
-r{toxinidir}/neutron/tests/functional/requirements.txt

Loading…
Cancel
Save