Skip to content

Commit

Permalink
Add cleanup to e2e tests in vagrant env (#6961)
Browse files Browse the repository at this point in the history
Signed-off-by: ShylajaDevadiga <[email protected]>
  • Loading branch information
ShylajaDevadiga authored and dereknola committed Nov 7, 2024
1 parent eeb095b commit 14be950
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/e2e/scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,43 @@ nodeOS=${1:-"bento/ubuntu-24.04"}
OS=$(echo "$nodeOS"|cut -d'/' -f2)

E2E_REGISTRY=true && export E2E_REGISTRY

cd rke2
git pull --rebase origin master
/usr/local/go/bin/go mod tidy
cd tests/e2e

# create directory to store reports if it does not exists
if [ ! -d createreport ]
then
mkdir createreport
fi

cleanup() {
for net in $(virsh net-list --all | tail -n +2 | tr -s ' ' | cut -d ' ' -f2 | grep -v default); do
virsh net-destroy "$net"
virsh net-undefine "$net"
done

for domain in $(virsh list --all | tail -n +2 | tr -s ' ' | cut -d ' ' -f3); do
virsh destroy "$domain"
virsh undefine "$domain" --remove-all-storage
done

for vm in `vagrant global-status |tr -s ' '|tail +3 |grep "/" |cut -d ' ' -f5`; do
cd $vm
vagrant destroy -f
cd ..
done
}


# Remove VMs which are in invalid state
vagrant global-status --prune

count=0
run_tests(){

count=$(( count + 1 ))
rm createreport/rke2_${OS}.log 2>/dev/null

for i in ${!tests[@]}; do
pushd ${tests[$i]}
Expand All @@ -48,6 +67,7 @@ run_tests(){
}

ls createreport/rke2_${OS}.log 2>/dev/null && rm createreport/rke2_${OS}.log
cleanup
run_tests

# re-run test if first run fails and keep record of repeatedly failed test to debug
Expand Down

0 comments on commit 14be950

Please sign in to comment.