From 31ca6ea1412ca30c708f52ef844f5a2eedb7a56d Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Fri, 22 Aug 2014 23:21:07 -0700 Subject: [PATCH] Add hook scripts for the functional infra job Infra jobs support hooks to customize behavior. This change adds scripts that are intended to be called by the neutron-dsvm-functional jobs as hooks. Defining hook behavior in-tree instead of directly in the job definition has the advantage of allowing changes in hook behavior to be tested before merge. The gate_hook.sh script added by this change installs a rootwrap filter to allow functional tests to destroy python processes that they have spawned. The tests use the python executable provided by their tox env, and the default rootwrap configuration does not support killing processes launched by non-system python executables. This change will have to merge to master and stable/icehouse before the supporting infra config change can be merged: https://review.openstack.org/#/c/116458/ Partial-bug: #1360658 Change-Id: Idcc6195f91fac833c14892f27fb793048ef964b9 --- neutron/tests/functional/contrib/README | 3 +++ .../tests/functional/contrib/filters.template | 12 ++++++++++++ neutron/tests/functional/contrib/gate_hook.sh | 17 +++++++++++++++++ .../tests/functional/contrib/post_test_hook.sh | 11 +++++++++++ 4 files changed, 43 insertions(+) create mode 100644 neutron/tests/functional/contrib/README create mode 100644 neutron/tests/functional/contrib/filters.template create mode 100644 neutron/tests/functional/contrib/gate_hook.sh create mode 100644 neutron/tests/functional/contrib/post_test_hook.sh diff --git a/neutron/tests/functional/contrib/README b/neutron/tests/functional/contrib/README new file mode 100644 index 00000000000..1836db15fb8 --- /dev/null +++ b/neutron/tests/functional/contrib/README @@ -0,0 +1,3 @@ +The files in this directory are intended for use by the +neutron-dsvm-functional infra jobs that run the functional test suite +in the gate. diff --git a/neutron/tests/functional/contrib/filters.template b/neutron/tests/functional/contrib/filters.template new file mode 100644 index 00000000000..2f0ebbedff6 --- /dev/null +++ b/neutron/tests/functional/contrib/filters.template @@ -0,0 +1,12 @@ +# neutron-rootwrap command filters to support functional testing. It +# is NOT intended to be used outside of a test environment. +# +# This file should be owned by (and only-writeable by) the root user + +[Filters] +# '$BASE_PATH' is intended to be replaced with the expected tox path +# (e.g. /opt/stack/new/neutron/.tox/dsvm-functional) by the neutron +# functional jenkins job. This ensures that tests can kill the +# processes that they launch with their containing tox environment's +# python. +kill_tox_python: KillFilter, root, $BASE_PATH/bin/python, -9 diff --git a/neutron/tests/functional/contrib/gate_hook.sh b/neutron/tests/functional/contrib/gate_hook.sh new file mode 100644 index 00000000000..5251bd9392b --- /dev/null +++ b/neutron/tests/functional/contrib/gate_hook.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -ex + +$BASE/new/devstack-gate/devstack-vm-gate.sh + +# Ideally devstack would only install dependencies +# rather than starting services, but for now unstack is +# a cheap way of accomplishing the same result. +$BASE/new/devstack/unstack.sh + +# Add a rootwrap filter to support test-only +# configuration (e.g. a KillFilter for processes that +# use the python installed in a tox env). +FUNC_FILTER=$BASE/new/neutron/neutron/tests/functional/contrib/filters.template +sed -e "s+\$BASE_PATH+$BASE/new/neutron/.tox/dsvm-functional+" \ + $FUNC_FILTER > /etc/neutron/rootwrap.d/functional.filters diff --git a/neutron/tests/functional/contrib/post_test_hook.sh b/neutron/tests/functional/contrib/post_test_hook.sh new file mode 100644 index 00000000000..a8794b96fe8 --- /dev/null +++ b/neutron/tests/functional/contrib/post_test_hook.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -xe + +NEUTRON_DIR=$BASE/new/neutron + +# Run tests as the stack user to allow sudo+rootwrap. +sudo chown -R stack:stack $NEUTRON_DIR +cd $NEUTRON_DIR +echo "Running neutron functional test suite" +sudo -H -u stack tox -e dsvm-functional