diff --git a/README.md b/README.md index c6e52498..75c8351f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/devstack-vm-gate-wrap.sh b/devstack-vm-gate-wrap.sh index d55f1fa4..0cd4b57e 100755 --- a/devstack-vm-gate-wrap.sh +++ b/devstack-vm-gate-wrap.sh @@ -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