Skip to content

Commit

Permalink
Add openstack regression test runner
Browse files Browse the repository at this point in the history
Run the Openstack release tests from charmed-openstack-tests.
  • Loading branch information
dosaboy committed Sep 27, 2024
1 parent 7cc5c23 commit c895782
Showing 1 changed file with 116 additions and 0 deletions.
116 changes: 116 additions & 0 deletions openstack/tools/openstack_regression_tests_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/bin/bash -eu
#
# Run Openstack regression tests.
#
FUNC_TEST_TARGET=
IMAGES_PATH=$HOME/tmp

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.
--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

# This is required for magnum tests and zaza will look in swift if it is not cached so we need to cache it first.
mkdir -p $IMAGES_PATH
if ! [[ -e $IMAGES_PATH/fedora-coreos-35.qcow2 ]]; then
wget https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/35.20220424.3.0/x86_64/fedora-coreos-35.20220424.3.0-openstack.x86_64.qcow2.xz -O $IMAGES_PATH/fedora-coreos-35.qcow2.xz
(cd $IMAGES_PATH; xz -d fedora-coreos-35.qcow2.xz; )
fi

# Install dependencies
which yq &>/dev/null || sudo snap install yq

TOOLS_PATH=$(realpath $(dirname $0))/func_test_tools
CHARM_PATH=$(pwd)

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)
(
# Ensure charmed-openstack-tester checked out and up-to-date
if [[ -d $HOME/charmed-openstack-tester ]]; then
cd $HOME/charmed-openstack-tester
git checkout master
git pull
else
cd $HOME
git clone https://github.com/openstack-charmers/charmed-openstack-tester
cd charmed-openstack-tester
fi

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"

0 comments on commit c895782

Please sign in to comment.