Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete all zaza models before and after each test #257

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions openstack/tools/charmed_openstack_functest_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ SKIP_BUILD=false
SLEEP=
WAIT_ON_DESTROY=true

. $(dirname $0)/func_test_tools/common.sh

usage () {
cat << EOF
USAGE: $(basename $0) OPTIONS
Expand Down Expand Up @@ -111,16 +113,7 @@ done
which yq &>/dev/null || sudo snap install yq

# Ensure zosci-config checked out and up-to-date
(
cd
if [[ -d zosci-config ]]; then
cd zosci-config
git checkout master
git pull
else
git clone https://github.com/openstack-charmers/zosci-config
fi
)
get_and_update_repo https://github.com/openstack-charmers/zosci-config

TOOLS_PATH=$(realpath $(dirname $0))/func_test_tools
CHARM_PATH=$PWD
Expand Down Expand Up @@ -239,6 +232,10 @@ fi
first=true
init_noop_target=true
for target in ${!func_targets[@]}; do
# Destroy any existing zaza models to ensure we have all the resources we
# need.
destroy_zaza_models

# Only rebuild on first run.
if $first; then
first=false
Expand Down Expand Up @@ -268,8 +265,9 @@ for target in ${!func_targets[@]}; do
if $WAIT_ON_DESTROY; then
read -p "Destroy model and run next test? [ENTER]"
fi
# cleanup before next run
juju destroy-model --no-prompt $model --force --no-wait --destroy-storage

# Cleanup before next run
destroy_zaza_models
done
popd &>/dev/null || true

Expand Down
34 changes: 34 additions & 0 deletions openstack/tools/func_test_tools/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
destroy_zaza_models ()
{
if $(juju destroy-model --help| grep -q "no-prompt"); then
j3=true
else
j3=false
fi
for model in $(juju list-models| egrep -o "^zaza-\S+"|tr -d '*'); do
if $j3; then
juju destroy-model --no-prompt --force --no-wait \
--destroy-storage $model
else
juju destroy-model --yes --force --no-wait --destroy-storage \
$model
fi
done
}

get_and_update_repo ()
{
url=$1
name=$(basename $url)
path=${2:-$HOME}
(
cd $path
if [[ -d $name ]]; then
cd $name
git checkout master
git pull
else
git clone $url
fi
)
}
23 changes: 4 additions & 19 deletions openstack/tools/openstack_regression_tests_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ FUNC_TEST_PR=
FUNC_TEST_TARGET=
IMAGES_PATH=$HOME/tmp

. $(dirname $0)/func_test_tools/common.sh

usage () {
cat << EOF
USAGE: $(basename $0) OPTIONS
Expand Down Expand Up @@ -65,16 +67,7 @@ fi
which yq &>/dev/null || sudo snap install yq

# Ensure zosci-config checked out and up-to-date
(
cd
if [[ -d zosci-config ]]; then
cd zosci-config
git checkout master
git pull
else
git clone https://github.com/openstack-charmers/zosci-config
fi
)
get_and_update_repo https://github.com/openstack-charmers/zosci-config

TOOLS_PATH=$(realpath $(dirname $0))/func_test_tools
CHARM_PATH=$PWD
Expand Down Expand Up @@ -130,15 +123,7 @@ fi
LOGFILE=$(mktemp --suffix=-openstack-release-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
git clone https://github.com/openstack-charmers/charmed-openstack-tester
cd charmed-openstack-tester
fi
get_and_update_repo https://github.com/openstack-charmers/charmed-openstack-tester

# If a func test pr is provided switch to that pr.
if [[ -n $FUNC_TEST_PR ]]; then
Expand Down
30 changes: 16 additions & 14 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,30 @@ bashfiles =
{toxinidir}/common/generate-bundle.sh

{toxinidir}/openstack/novarc
# find openstack/tools/ -name \*.sh
{toxinidir}/openstack/tools/create-microceph-vm.sh
# find openstack/tools/ -name \*.sh| xargs -I{} echo " {toxinidir}/{}"
{toxinidir}/openstack/tools/func_test_tools/manual_functests_runner.sh
{toxinidir}/openstack/tools/func_test_tools/common.sh
{toxinidir}/openstack/tools/create_octavia_lb.sh
{toxinidir}/openstack/tools/float_all.sh
{toxinidir}/openstack/tools/create_nova_az_aggregates.sh
{toxinidir}/openstack/tools/vault-unseal-and-authorise.sh
{toxinidir}/openstack/tools/create_sg_log.sh
{toxinidir}/openstack/tools/install_local_ca.sh
{toxinidir}/openstack/tools/create_nova_az_aggregates.sh
{toxinidir}/openstack/tools/enable_samltestid.sh
{toxinidir}/openstack/tools/delete_project.sh
{toxinidir}/openstack/tools/charmed_openstack_functest_runner.sh
{toxinidir}/openstack/tools/create_ipv4_octavia.sh
{toxinidir}/openstack/tools/configure_octavia.sh
{toxinidir}/openstack/tools/create_sg_log.sh
{toxinidir}/openstack/tools/setup_tempest.sh
{toxinidir}/openstack/tools/instance_launch.sh
{toxinidir}/openstack/tools/create_project.sh
{toxinidir}/openstack/tools/allocate_vips.sh
{toxinidir}/openstack/tools/upload_octavia_amphora_image.sh
{toxinidir}/openstack/tools/install_local_ca.sh
{toxinidir}/openstack/tools/charmed_openstack_functest_runner.sh
{toxinidir}/openstack/tools/openstack_regression_tests_runner.sh
{toxinidir}/openstack/tools/func_test_tools/manual_functests_runner.sh
{toxinidir}/openstack/tools/instance_launch.sh
{toxinidir}/openstack/tools/setup_tempest.sh
{toxinidir}/openstack/tools/create_octavia_lb.sh
{toxinidir}/openstack/tools/sec_groups.sh
{toxinidir}/openstack/tools/configure_octavia.sh
{toxinidir}/openstack/tools/delete_project.sh
{toxinidir}/openstack/tools/create_project.sh
{toxinidir}/openstack/tools/create-microceph-vm.sh
{toxinidir}/openstack/tools/upload_image.sh
{toxinidir}/openstack/tools/openstack_regression_tests_runner.sh


setenv =
PYTHONHASHSEED=0
Expand Down