diff --git a/openstack/tools/charmed_openstack_functest_runner.sh b/openstack/tools/charmed_openstack_functest_runner.sh index 420268f0..c0438f00 100755 --- a/openstack/tools/charmed_openstack_functest_runner.sh +++ b/openstack/tools/charmed_openstack_functest_runner.sh @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/openstack/tools/func_test_tools/common.sh b/openstack/tools/func_test_tools/common.sh new file mode 100644 index 00000000..082e91bf --- /dev/null +++ b/openstack/tools/func_test_tools/common.sh @@ -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 + ) +} \ No newline at end of file diff --git a/openstack/tools/openstack_regression_tests_runner.sh b/openstack/tools/openstack_regression_tests_runner.sh index bec19d8d..ba955868 100755 --- a/openstack/tools/openstack_regression_tests_runner.sh +++ b/openstack/tools/openstack_regression_tests_runner.sh @@ -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 @@ -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 @@ -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 diff --git a/tox.ini b/tox.ini index 4adf7e4d..38927b61 100644 --- a/tox.ini +++ b/tox.ini @@ -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