From e8a2e0059d403b7dcbc050310684812dae119472 Mon Sep 17 00:00:00 2001 From: Paul Michali Date: Tue, 26 May 2015 20:27:25 +0000 Subject: [PATCH] VPNaaS: Cleanup functional hook scripts This does a few minor fixes. First, it changes the bash invocation line. Next, it uses a case statement for one multicondition if-clause. Third, it uses VENV for the virtual environemnt variable to be consistent with gate_hook.sh. Change-Id: I788c95657fe70e894bb55beca190ba6bedf71aca --- neutron_vpnaas/tests/contrib/gate_hook.sh | 2 +- .../tests/contrib/post_test_hook.sh | 33 ++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/neutron_vpnaas/tests/contrib/gate_hook.sh b/neutron_vpnaas/tests/contrib/gate_hook.sh index 5e5dfa860..466687aa4 100644 --- a/neutron_vpnaas/tests/contrib/gate_hook.sh +++ b/neutron_vpnaas/tests/contrib/gate_hook.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -ex diff --git a/neutron_vpnaas/tests/contrib/post_test_hook.sh b/neutron_vpnaas/tests/contrib/post_test_hook.sh index e6e8e4f15..a6a4463a0 100644 --- a/neutron_vpnaas/tests/contrib/post_test_hook.sh +++ b/neutron_vpnaas/tests/contrib/post_test_hook.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -xe @@ -6,40 +6,41 @@ NEUTRON_VPNAAS_DIR="$BASE/new/neutron-vpnaas" TEMPEST_DIR="$BASE/new/tempest" SCRIPTS_DIR="/usr/local/jenkins/slave_scripts" -venv=${1:-"dsvm-functional"} +VENV=${1:-"dsvm-functional"} function generate_testr_results { # Give job user rights to access tox logs sudo -H -u $owner chmod o+rw . sudo -H -u $owner chmod o+rw -R .testrepository if [ -f ".testrepository/0" ] ; then - .tox/$venv/bin/subunit-1to2 < .testrepository/0 > ./testrepository.subunit - .tox/$venv/bin/python $SCRIPTS_DIR/subunit2html.py ./testrepository.subunit testr_results.html + .tox/$VENV/bin/subunit-1to2 < .testrepository/0 > ./testrepository.subunit + .tox/$VENV/bin/python $SCRIPTS_DIR/subunit2html.py ./testrepository.subunit testr_results.html gzip -9 ./testrepository.subunit gzip -9 ./testr_results.html sudo mv ./*.gz /opt/stack/logs/ fi } -if [[ "$venv" == "dsvm-functional" || "$venv" == "dsvm-functional-sswan" ]] -then - owner=stack - sudo_env= -elif [ "$venv" == "api" ] -then - owner=tempest - # Configure the api tests to use the tempest.conf set by devstack. - sudo_env="TEMPEST_CONFIG_DIR=$TEMPEST_DIR/etc" -fi +case $VENV in + dsvm-functional | dsvm-functional-sswan) + owner=stack + sudo_env= + ;; + api) + owner=tempest + # Configure the api tests to use the tempest.conf set by devstack. + sudo_env="TEMPEST_CONFIG_DIR=$TEMPEST_DIR/etc" + ;; +esac # Set owner permissions according to job's requirements. cd $NEUTRON_VPNAAS_DIR sudo chown -R $owner:stack $NEUTRON_VPNAAS_DIR # Run tests -echo "Running neutron $venv test suite" +echo "Running neutron $VENV test suite" set +e -sudo -H -u $owner $sudo_env tox -e $venv +sudo -H -u $owner $sudo_env tox -e $VENV testr_exit_code=$? set -e