Add support for configurable pre and post hooks.

Adds 3 hooks to the devstack-vm-gate-wrap.sh script so that we can
make use of this script for non-devstack type gating tests.

The new hooks are:
 -pre_test_hook (optional, only executed if defined)
 -gate_hook (runs the devstack-vm-gate.sh as a default)
 -post_test_hook (optional, only executed if defined)

Change-Id: I9d2435780a23a04a8b34b2d885125132a7e4f16a
This commit is contained in:
Monty Taylor 2013-03-09 18:17:23 -05:00 committed by Dan Prince
parent e2d4168bfd
commit dea2e83c5e
2 changed files with 34 additions and 9 deletions

View File

@ -107,9 +107,12 @@ reviewers is as follows:
* This job runs on one of the previously configured "devstack-foo"
nodes and invokes the ``devstack-vm-gate-wrap.sh`` script which
checks out code from all of the involved repositories, and merges
the proposed change.
* That script then calls ``devstack-vm-gate.sh`` which installs a
devstack configuration file, and invokes devstack.
the proposed change.
* If the ``pre_test_hook`` function is defined it is executed.
* The wrap script defines a ``gate_hook`` function if one is
not provided. By default it uses the devstack-vm-gate.sh script
which installs a devstack configuration file, and invokes devstack.
* If the ``post_test_hook`` function is defined it is executed.
* Once devstack is finished, it runs ``exercise.sh`` which performs
some basic integration testing.
* After everything is done, the script copies all of the log files

View File

@ -70,6 +70,10 @@ export DEVSTACK_GATE_VIRT_DRIVER=${DEVSTACK_GATE_VIRT_DRIVER:-libvirt}
# is the project being gated.
export DEVSTACK_GATE_TEMPEST_FULL=${DEVSTACK_GATE_TEMPEST_FULL:-0}
# Set GATE_SCRIPT_DIR to point to devstack-gate in the workspace so that
# we are testing the proposed change from this point forward.
GATE_SCRIPT_DIR=$BASE/new/devstack-gate
# Set this variable to skip updating the devstack-gate project itself.
# Useful in development so you can edit scripts in place and run them
# directly. Do not set in production.
@ -84,6 +88,17 @@ export BASE=/opt/stack
# Most of the work of this script is done in functions so that we may
# easily redirect their stdout / stderr to log files.
function function_exists {
type $1 2>/dev/null | grep -q 'is a function'
}
if ! function_exists "gate_hook"; then
# the command we use to run the gate
function gate_hook {
$GATE_SCRIPT_DIR/devstack-vm-gate.sh
}
fi
function setup_workspace {
DEST=$1
CHECKOUT_ZUUL=$2
@ -356,10 +371,6 @@ mkdir -p logs
setup_workspace $BASE/new 1 &> \
$WORKSPACE/logs/devstack-gate-setup-workspace-new.txt
# Set GATE_SCRIPT_DIR to point to devstack-gate in the workspace so that
# we are testing the proposed change from this point forward.
GATE_SCRIPT_DIR=$BASE/new/devstack-gate
# Also, if we're testing devstack-gate, re-exec this script once so
# that we can test the new version of it.
if [[ $ZUUL_PROJECT == "openstack-infra/devstack-gate" ]] && [[ $RE_EXEC != "true" ]]; then
@ -381,10 +392,21 @@ echo "Pipeline: $ZUUL_PIPELINE"
setup_host &> $WORKSPACE/logs/devstack-gate-setup-host.txt
# Run the test
$GATE_SCRIPT_DIR/devstack-vm-gate.sh
# Run pre test hook if we have one
if function_exists "pre_test_hook"; then
pre_test_hook
fi
# Run the gate function
gate_hook
RETVAL=$?
# Run post test hook if we have one
if [ $RETVAL -eq 0 ] && function_exists "post_test_hook"; then
post_test_hook
RETVAL=$?
fi
cleanup_host &> $WORKSPACE/logs/devstack-gate-cleanup-host.txt
exit $RETVAL