From dfb4cd247ec3725ec68ec160e10d1729e85da8a9 Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Fri, 27 Sep 2024 13:13:32 +0100 Subject: [PATCH] Add openstack regression test runner --- .../openstack_regression_tests_runner.sh | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100755 openstack/tools/openstack_regression_tests_runner.sh diff --git a/openstack/tools/openstack_regression_tests_runner.sh b/openstack/tools/openstack_regression_tests_runner.sh new file mode 100755 index 00000000..015f1ef6 --- /dev/null +++ b/openstack/tools/openstack_regression_tests_runner.sh @@ -0,0 +1,112 @@ +#!/bin/bash -eu +# +# Run Openstack regression tests. +# +FUNC_TEST_TARGET= + +usage () { + cat << EOF +USAGE: `basename $0` OPTIONS + +Run Openstack regression tests. + +OPTIONS: + --func-test-target TARGET_NAME + Provide the name of a specific test target to run. If none provided + all tests are run based on what is defined in osci.yaml i.e. will do + what osci would do by default. + --help + This help message. +EOF +} + +while (($# > 0)); do + case "$1" in + --debug) + set -x + ;; + --func-test-target) + FUNC_TEST_TARGET=$2 + shift + ;; + --help|-h) + usage + exit 0 + ;; + *) + echo "ERROR: invalid input '$1'" + usage + exit 1 + ;; + esac + shift +done + +if [[ -z $FUNC_TEST_TARGET ]]; then + echo "ERROR: must provide a target name with --func-test-target" + exit 1 +fi + +# Install dependencies +which yq &>/dev/null || sudo snap install yq + +TOOLS_PATH=$(realpath $(dirname $0))/func_test_tools +CHARM_PATH=$(pwd) + +# Ensure charmed-openstack-tester checked out and up-to-date +( +cd +if [[ -d charmed-openstack-tester ]]; then + cd charmed-openstack-tester + git checkout master + git pull +else + git clone https://github.com/openstack-charmers/charmed-openstack-tester +fi +) + + +echo "Running regression tests" + +source ~/novarc +export {,TEST_}CIDR_EXT=`openstack subnet show subnet_${OS_USERNAME}-psd-extra -c cidr -f value` +FIP_MAX=$(ipcalc $CIDR_EXT| awk '$1=="HostMax:" {print $2}') +FIP_MIN=$(ipcalc $CIDR_EXT| awk '$1=="HostMin:" {print $2}') +FIP_MIN_ABC=${FIP_MIN%.*} +FIP_MIN_D=${FIP_MIN##*.} +FIP_MIN=${FIP_MIN_ABC}.$(($FIP_MIN_D + 64)) + +CIDR_OAM=`openstack subnet show subnet_${OS_USERNAME}-psd -c cidr -f value` +OAM_MAX=$(ipcalc $CIDR_OAM| awk '$1=="HostMax:" {print $2}') +OAM_MIN=$(ipcalc $CIDR_OAM| awk '$1=="HostMin:" {print $2}') +OAM_MIN_ABC=${OAM_MIN%.*} +OAM_MAX_D=${OAM_MAX##*.} +# Picking last two addresses and hoping they dont get used by Neutron. +export {OS,TEST}_VIP00=${OAM_MIN_ABC}.$(($OAM_MAX_D - 1)) +export {OS,TEST}_VIP01=${OAM_MIN_ABC}.$(($OAM_MAX_D - 2)) + +# More information on config https://github.com/openstack-charmers/zaza/blob/master/doc/source/runningcharmtests.rst +export {,TEST_}NET_ID=$(openstack network show net_${OS_USERNAME}-psd-extra -f value -c id) +export {,TEST_}FIP_RANGE=$FIP_MIN:$FIP_MAX +export {,TEST_}GATEWAY=$(openstack subnet show subnet_${OS_USERNAME}-psd-extra -c gateway_ip -f value) +export {,TEST_}NAME_SERVER=91.189.91.131 +export {,TEST_}CIDR_PRIV=192.168.21.0/24 +export {,TEST_}SWIFT_IP=10.140.56.22 +export TEST_MODEL_SETTINGS="image-stream=released;default-series=jammy;test-mode=true;transmit-vendor-metrics=false" +# We need to set TEST_JUJU3 as well as the constraints file +# Ref: https://github.com/openstack-charmers/zaza/blob/e96ab098f00951079fccb34bc38d4ae6ebb38606/setup.py#L47 +export TEST_JUJU3=1 + +# NOTE: this should not be necessary for > juju 2.x but since we still have a need for it we add it in +export TEST_ZAZA_BUG_LP1987332=1 + +# Some charms point to an upstream constraints file that installs python-libjuju 2.x so we need to do this to ensure we get 3.x +export TEST_CONSTRAINTS_FILE=https://raw.githubusercontent.com/openstack-charmers/zaza/master/constraints-juju34.txt + +LOGFILE=$(mktemp --suffix=-charm-func-test-results) +( + fail=false + tox -e func-target -- $FUNC_TEST_TARGET || fail=true + model=`juju list-models| egrep -o "^zaza-\S+"|tr -d '*'` +) 2>&1 | tee $LOGFILE +echo -e "\nResults also saved to $LOGFILE"