-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add openstack charm func test runner
Also includes tool to identify func test targets from the charm.
- Loading branch information
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/bin/bash -eux | ||
SKIP_BUILD=false | ||
|
||
while (($# > 0)) | ||
do | ||
case "$1" in | ||
--skip-build) | ||
SKIP_BUILD=true | ||
;; | ||
*) | ||
echo "ERROR: invalid input '$1'" | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
|
||
source ~/novarc | ||
CIDR=`openstack subnet show subnet_${OS_USERNAME}-psd-extra -c cidr -f value` | ||
FIP_MAX=$(ipcalc $CIDR| awk '$1=="HostMax:" {print $2}') | ||
FIP_MIN=$(ipcalc $CIDR| awk '$1=="HostMin:" {print $2}') | ||
FIP_MIN_ABC=${FIP_MIN%.*} | ||
FIP_MIN_D=${FIP_MIN##*.} | ||
FIP_MIN=${FIP_MIN_ABC}.$(($FIP_MIN_D + 64)) | ||
|
||
# More information on confog https://github.com/openstack-charmers/zaza/blob/master/doc/source/runningcharmtests.rst | ||
export TEST_HTTP_PROXY=http://squid.internal:3128 | ||
export TEST_FIP_RANGE=FIP_MIN:FIP_MAX | ||
export TEST_CIDR_EXT=CIDR | ||
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" | ||
export TEST_CONSTRAINTS_FILE=https://raw.githubusercontent.com/openstack-charmers/zaza/master/constraints-juju34.txt | ||
# 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 | ||
export NET_ID=$(openstack network show net_${OS_USERNAME}-psd -f value -c id) | ||
|
||
## Build Charm | ||
# Note: If you have a reactive charm, some paths may be prefixed by src/, like | ||
# src/.tox or src/tests | ||
# | ||
# 1. Check charmcraft channel required in zosci.yaml and refresh it to the | ||
# matching version. The version will differ based on stable branch version, | ||
# e.g. yoga is often 1.5, zed is often 2.0, master 2.x.. some noble-caracal | ||
# ones may be on 3.x | ||
|
||
sudo snap refresh charmcraft --channel 2.x/stable | ||
|
||
# Ensure lxc initialised | ||
lxd init --auto || true | ||
|
||
# 2. Build. This should always do the right thing, regardless of how the | ||
# charm is built. | ||
if ! $SKIP_BUILD; then | ||
tox -re build | ||
fi | ||
|
||
# 3. Run tests | ||
|
||
for target in $(python3 $(realpath $(dirname $0))/identify_charm_func_tests.py); do | ||
tox -re func-target $target | ||
|
||
read -p "Destroy model and run next test? [ENTER]" | ||
# cleanup before next run | ||
model=`juju list-models| egrep -o "^zaza-\S+"|tr -d '*'` | ||
juju destroy-model --no-prompt $model --force --no-wait --destroy-storage | ||
done | ||
|
||
# To troubleshoot issues with a run you can do the following: | ||
# | ||
# . .tox/func-target/bin/activate | ||
# cd tests/distro-regression/ | ||
# model=`juju list-models| egrep -o "^zaza-\S+"|tr -d '*'` | ||
# functest-configure -m TARGET:$model | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Get names of test targets that OSCI would run for the given charm. Should be | ||
# run from within the charm root. | ||
# | ||
# Outputs space seperated list of target names. | ||
# | ||
import os | ||
import yaml | ||
|
||
CLASSIC_TESTS_YAML = 'tests/tests.yaml' | ||
REACTIVE_TESTS_YAML = os.path.join('src', CLASSIC_TESTS_YAML) | ||
|
||
if os.path.exists(REACTIVE_TESTS_YAML): | ||
bundles = yaml.safe_load(open(REACTIVE_TESTS_YAML)) | ||
else: | ||
bundles = yaml.safe_load(open(CLASSIC_TESTS_YAML)) | ||
|
||
targets = set(bundles['smoke_bundles'] + bundles['gate_bundles'] + | ||
bundles['dev_bundles']) | ||
|
||
print(' '.join(sorted(targets))) |