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

Add eshop UI tests on AWS #552

Merged
merged 67 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
95118ba
Initial work on adding UI tests for eShop on AWS
ytimocin Jun 27, 2023
0059d31
update get ekscluster command to add region
vishwahiremat Jul 13, 2023
f252832
Trigger Build
vishwahiremat Jul 13, 2023
9c7df7d
resolving merge conflicts
vishwahiremat Jul 13, 2023
a7c0eb6
making app name unique
vishwahiremat Jul 14, 2023
cb886ee
updating the app name to unique
vishwahiremat Jul 14, 2023
893eacc
Trigger Build
vishwahiremat Jul 14, 2023
ce0ce52
Trigger Build
vishwahiremat Jul 17, 2023
abf4185
reverting changes
vishwahiremat Jul 17, 2023
fb73fa8
updating the namespace
vishwahiremat Jul 17, 2023
1ee3674
updating namespace
vishwahiremat Jul 17, 2023
4dc85c0
fixinf delete app
vishwahiremat Jul 17, 2023
05b3256
fix delete app syntax error
vishwahiremat Jul 17, 2023
e7cb45e
fixing syntax error
vishwahiremat Jul 17, 2023
4103c96
Merge branch 'edge' into ytimocin/ui-tests-eshop-aws
vishwahiremat Jul 18, 2023
4291f75
fixing appname issue
vishwahiremat Jul 18, 2023
009e43c
updating the 1ES runner pools for samples
vishwahiremat Jul 21, 2023
ee851c1
adding changes to not use k3d cluster for aws eshop
vishwahiremat Jul 21, 2023
fab39d1
not add publicEndpointOverride for eks cluster
vishwahiremat Jul 21, 2023
d6cd9fc
setting eks cluster context
vishwahiremat Jul 21, 2023
54b809f
updating the node-type
vishwahiremat Jul 21, 2023
12dd32f
fixing aws playwright tests
vishwahiremat Jul 23, 2023
4f25209
fix syntax error
vishwahiremat Jul 23, 2023
10a6ccb
fix for demo app ui test
vishwahiremat Jul 23, 2023
2f94bab
adding changes to delete services before deleting eks cluster
vishwahiremat Jul 24, 2023
db3635a
deleting contour-envoy service
vishwahiremat Jul 24, 2023
583dfa9
addressing comments
vishwahiremat Jul 24, 2023
88cbf68
deleting resources before deleting the cluster
vishwahiremat Jul 25, 2023
0c7f0c0
reolve merge conflicts
vishwahiremat Jul 25, 2023
abfc206
fixing delete stack command
vishwahiremat Jul 25, 2023
2bfdec6
removing aws-eshop playwright file
vishwahiremat Jul 25, 2023
4ba1b34
fix for if condn
vishwahiremat Jul 25, 2023
02e422a
fix for aws test file
vishwahiremat Jul 25, 2023
8546311
Adding workflow dispatch to kick off automated samples validation (#422)
willdavsmith Jul 28, 2023
72fb390
Testing
willdavsmith Aug 25, 2023
c2d8d2e
progress
willdavsmith Sep 11, 2023
7e0d0ae
Adding applicationName to aws resource definitions
willdavsmith Sep 11, 2023
4b9991c
Merge remote-tracking branch 'origin/edge' into willdavsmith/ui-test-…
willdavsmith Sep 11, 2023
dd01ed0
PR
willdavsmith Sep 11, 2023
88d2acd
Improvements
willdavsmith Sep 11, 2023
a1b2e4b
nit
willdavsmith Sep 11, 2023
2450934
WIP only test aws eshop
willdavsmith Sep 11, 2023
bed4eb3
PR
willdavsmith Sep 11, 2023
f9655cd
bug
willdavsmith Sep 11, 2023
05c6234
bug
willdavsmith Sep 11, 2023
246bf69
bug
willdavsmith Sep 11, 2023
b360bdf
bug
willdavsmith Sep 11, 2023
cffb590
bug
willdavsmith Sep 11, 2023
409b05c
bug
willdavsmith Sep 11, 2023
70cc54f
bug
willdavsmith Sep 11, 2023
9cb4068
pr
willdavsmith Sep 11, 2023
d8afcd7
PR
willdavsmith Sep 11, 2023
c50d2a0
nit
willdavsmith Sep 11, 2023
8c05f4d
pr
willdavsmith Sep 11, 2023
6cd6fd7
bug
willdavsmith Sep 12, 2023
de51364
Fixing deletion logic
willdavsmith Sep 12, 2023
5379ef8
Fixing
willdavsmith Sep 12, 2023
dbab081
Running everything
willdavsmith Sep 12, 2023
17e94a7
I think it works
willdavsmith Sep 12, 2023
68336f3
it did not work
willdavsmith Sep 12, 2023
201268a
maybe
willdavsmith Sep 12, 2023
cc2bffd
versioning
willdavsmith Sep 14, 2023
a5e4d3a
Whoops
willdavsmith Sep 14, 2023
b7a012c
Merge branch 'edge' into willdavsmith/ui-test-eshop-aws
willdavsmith Sep 15, 2023
57a5f48
Merge remote-tracking branch 'origin/edge' into willdavsmith/ui-test-…
willdavsmith Sep 16, 2023
8020351
PR comment
willdavsmith Sep 25, 2023
af07cd6
Merge branch 'edge' into willdavsmith/ui-test-eshop-aws
willdavsmith Sep 25, 2023
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
92 changes: 92 additions & 0 deletions .github/scripts/delete-aws-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash

# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------


APP_NAME=$1
APP_LABEL='RadiusApplication'
RESOURCE_TYPES='AWS::RDS::DBInstance,AWS::RDS::DBSubnetGroup,AWS::MemoryDB::Cluster,AWS::MemoryDB::SubnetGroup'

# File to store the list of deleted resources
DELETED_RESOURCES_FILE='deleted-resources.txt'

# Number of retries
MAX_RETRIES=5

# Retry delay in seconds
RETRY_DELAY=300 # 5 minutes

function delete_aws_resources() {
# Empty the file
truncate -s 0 $DELETED_RESOURCES_FILE

for resource_type in ${RESOURCE_TYPES//,/ }
do
aws cloudcontrol list-resources --type-name "$resource_type" --query "ResourceDescriptions[].Identifier" --output text | tr '\t' '\n' | while read identifier
do
aws cloudcontrol get-resource --type-name "$resource_type" --identifier "$identifier" --query "ResourceDescription.Properties" --output text | while read resource
do
resource_tags=$(jq -c -r .Tags <<< "$resource")
for tag in $(jq -c -r '.[]' <<< "$resource_tags")
do
key=$(jq -r '.Key' <<< "$tag")
value=$(jq -r '.Value' <<< "$tag")
if [[ "$key" == "$APP_LABEL" && "$value" == "$APP_NAME" ]]
then
echo "Deleting resource of type: $resource_type with identifier: $identifier"
echo "$identifier\n" >> $DELETED_RESOURCES_FILE
aws cloudcontrol delete-resource --type-name "$resource_type" --identifier "$identifier"
fi
done
done
done
done

if [ -s $DELETED_RESOURCES_FILE ]; then
return 1
else
return 0
fi
}

RETRY_COUNT=0
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
# Trigger the function to delete the resources
delete_aws_resources

# If the function returned 0, then no resources needed to be deleted
# on this run. This means that all resources have been deleted.
if [ $? -eq 0 ]; then
echo "All resources deleted successfully"
break
fi

# Still have resources to delete, increase the retry count
RETRY_COUNT=$((RETRY_COUNT + 1))

# Check if there are more retries left
if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
# Retry after delay
echo "Retrying in $RETRY_DELAY seconds..."
sleep $RETRY_DELAY
fi
done

# Check if the maximum number of retries exceeded
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
echo "Maximum number of retries exceeded"
fi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Purge test resources
name: Purge Azure test resources
on:
schedule:
- cron: "30 0,12 * * *"
Expand All @@ -7,7 +7,7 @@ env:
VALID_RESOURCE_WINDOW: 6*60*60
jobs:
purge_azure_resources:
name: Azure resources clean-ups
name: Azure test resource cleanup
runs-on: [self-hosted, 1ES.Pool=1ES-Radius]
steps:
- name: Login to Azure
Expand All @@ -18,30 +18,47 @@ jobs:
--tenant ${{ secrets.AZURE_SP_TESTS_TENANTID }}

az account set --subscription ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }}

- name: List Test Resource Groups
run: |
echo "## Test resource group list" >> $GITHUB_STEP_SUMMARY
az group list --query "[?starts_with(name, 'samplestest-')].{Name:name, creationTime:tags.creationTime}" -o json > resource_groups.json

# Create the file to store the resource group list
touch ${{ env.AZURE_RG_DELETE_LIST_FILE}}

resource_groups=$(az group list --query "[].{Name:name, creationTime:tags.creationTime}" -o tsv)

current_time=$(date +%s)
hours_ago=$((current_time - ${{ env.VALID_RESOURCE_WINDOW }}))
while IFS=$'\t' read -r name creation_time; do
if [[ ! "$name" =~ ^"samplestest-" ]]; then
continue
fi

jq -r '.[] | select(.creationTime == null || .creationTime < '$hours_ago') | .Name' resource_groups.json > ${{ env.AZURE_RG_DELETE_LIST_FILE}}
jq -r '.[] | {name: .Name, creationTime: .creationTime // "None"}' resource_groups.json > $GITHUB_STEP_SUMMARY
if [ "$creation_time" = "None" ]; then
echo " * :wastebasket: $name - old resource" >> $GITHUB_STEP_SUMMARY
echo $name >> ${{ env.AZURE_RG_DELETE_LIST_FILE}}
continue
fi

# Check if the resource group was created more than 6 hours ago
if [ "$creation_time" -lt "$hours_ago" ]; then
echo " * :wastebasket: $name - creationTime: $creation_time" >> $GITHUB_STEP_SUMMARY
echo $name >> ${{ env.AZURE_RG_DELETE_LIST_FILE}}
else
echo " * :white_check_mark: $name - creationTime: $creation_time" >> $GITHUB_STEP_SUMMARY
fi
done <<< "$resource_groups"
- name: Delete Azure Resource Groups
run: |
echo "## Deleting resource group list" >> $GITHUB_STEP_SUMMARY
cat ${{ env.AZURE_RG_DELETE_LIST_FILE}} | while read -r line
cat ${{ env.AZURE_RG_DELETE_LIST_FILE}} | while read line
do
echo " * $line" >> $GITHUB_STEP_SUMMARY
az group delete --resource-group $line --yes --verbose
done

- name: Create GitHub issue on failure
if: ${{ failure() }}
run: |
gh issue create --title "Samples purge test resources failed \
gh issue create --title "Samples purge Azure test resources failed" \
--body "Test failed on ${{ github.repository }}. See [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details." \
s--repo ${{ github.repository }}
--repo ${{ github.repository }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Radius version number to use (e.g. 0.22.0, 0.23.0-rc1)'
description: 'Radius version number to use (e.g. 0.1.0, 0.1.0-rc1)'
required: true
default: ''
type: string
Expand Down
Loading
Loading