Skip to content

Commit c15235f

Browse files
authored
Azure: Delete resource groups between all samples runs. (#47)
* delete rg inbetween all sample app runs
1 parent 69ded6b commit c15235f

1 file changed

Lines changed: 18 additions & 22 deletions

File tree

run-samples.sh

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ command -v localstack >/dev/null 2>&1 || { echo >&2 "localstack CLI is required
3232
command -v az >/dev/null 2>&1 || { echo >&2 "az CLI is required but not installed. Aborting."; exit 1; }
3333
command -v azlocal >/dev/null 2>&1 || { echo >&2 "azlocal is required but not installed. Run 'pip install azlocal'. Aborting."; exit 1; }
3434
command -v funclocal >/dev/null 2>&1 || { echo >&2 "funclocal is required but not installed. Run 'pip install azlocal'. Aborting."; exit 1; }
35-
command -v tflocal >/dev/null 2>&1 || { echo >&2 "tflocal is required but not installed. Run 'pip install terraform-local'. Aborting."; exit 1; }
35+
#command -v tflocal >/dev/null 2>&1 || { echo >&2 "tflocal is required but not installed. Run 'pip install terraform-local'. Aborting."; exit 1; }
3636
command -v terraform >/dev/null 2>&1 || { echo >&2 "terraform CLI is required but not installed. Aborting."; exit 1; }
3737
command -v func >/dev/null 2>&1 || { echo >&2 "Azure Functions Core Tools (func) is required but not installed. Aborting."; exit 1; }
3838

@@ -145,33 +145,29 @@ for (( i=START; i<START+COUNT; i++ )); do
145145
# Cleanup Bicep artifacts for bicep tests
146146
if [[ "$path" == *"/bicep" ]]; then
147147
echo "Cleaning up Bicep artifacts..."
148-
# Clean up zip files if any were created
149148
rm -f *.zip || true
150-
151-
# Clean up Azure resources to prevent state pollution between tests
152-
echo "Cleaning up Azure resources in LocalStack..."
153-
if command -v azlocal >/dev/null 2>&1; then
154-
echo "Deleting all resource groups..."
155-
# List and delete all resource groups
156-
RG_LIST=$(azlocal group list --query "[].name" -o tsv 2>/dev/null || echo "")
157-
if [[ -n "$RG_LIST" ]]; then
158-
echo "$RG_LIST" | while read -r rg; do
159-
if [[ -n "$rg" ]]; then
160-
echo " - Deleting resource group: $rg"
161-
azlocal group delete --name "$rg" --yes --no-wait 2>/dev/null || true
162-
fi
163-
done
164-
# Wait a bit for deletions to process
165-
sleep 2
166-
else
167-
echo " No resource groups to clean up"
168-
fi
169-
fi
170149
fi
171150

172151
popd > /dev/null
173152
echo "Completed: $path"
174153

154+
# Clean up Azure resources to prevent state pollution between tests
155+
echo "Cleaning up Azure resources in LocalStack..."
156+
if command -v azlocal >/dev/null 2>&1; then
157+
RG_LIST=$(azlocal group list --query "[].name" -o tsv 2>/dev/null || echo "")
158+
if [[ -n "$RG_LIST" ]]; then
159+
echo "$RG_LIST" | while read -r rg; do
160+
if [[ -n "$rg" ]]; then
161+
echo " - Deleting resource group: $rg"
162+
azlocal group delete --name "$rg" --yes --no-wait 2>/dev/null || true
163+
fi
164+
done
165+
sleep 2
166+
else
167+
echo " No resource groups to clean up"
168+
fi
169+
fi
170+
175171
# Cleanup Docker resources after each test to free up disk space
176172
echo "Cleaning up Docker resources..."
177173
docker system prune -af --volumes || true

0 commit comments

Comments
 (0)