-
Notifications
You must be signed in to change notification settings - Fork 1.5k
e2e test helper script #2246
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
Merged
Merged
e2e test helper script #2246
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e88bfee
Added helper script to run e2e tests
0895b9e
Merge remote-tracking branch 'upstream/main' into e2e_test_helper
1fd09b7
renamed file
3d981c6
removed unnecessary code
339903d
Add VPC_ID as its needed to run ginkgo tests
af0bafc
fixed typo
e5809aa
Cordon off windows nodes
c598f42
Add timeout for deletion of resources
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/bin/bash | ||
|
||
# This script runs e2e tests on the AWS Load Balancer Controller | ||
|
||
set -e | ||
|
||
SECONDS=0 | ||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
echo "Running AWS Load Balancer Controller e2e tests with the following variables | ||
KUBE CONFIG: $KUBE_CONFIG_PATH | ||
CLUSTER_NAME: $CLUSTER_NAME | ||
REGION: $REGION | ||
OS_OVERRIDE: $OS_OVERRIDE" | ||
|
||
function toggle_windows_scheduling(){ | ||
schedule=$1 | ||
nodes=$(kubectl get nodes -l kubernetes.io/os=windows | tail -n +2 | cut -d' ' -f1) | ||
for n in $nodes | ||
do | ||
kubectl $schedule $n | ||
done | ||
} | ||
|
||
if [[ -z "${OS_OVERRIDE}" ]]; then | ||
OS_OVERRIDE=linux | ||
fi | ||
|
||
GET_CLUSTER_INFO_CMD="aws eks describe-cluster --name $CLUSTER_NAME --region $REGION" | ||
|
||
if [[ -z "${ENDPOINT}" ]]; then | ||
CLUSTER_INFO=$($GET_CLUSTER_INFO_CMD) | ||
else | ||
CLUSTER_INFO=$($GET_CLUSTER_INFO_CMD --endpoint $ENDPOINT) | ||
fi | ||
|
||
echo "Cordon off windows nodes" | ||
toggle_windows_scheduling "cordon" | ||
|
||
VPC_ID=$(echo $CLUSTER_INFO | jq -r '.cluster.resourcesVpcConfig.vpcId') | ||
ACCOUNT_ID=$(aws sts get-caller-identity | jq -r '.Account') | ||
|
||
echo "VPC ID: $VPC_ID" | ||
|
||
eksctl utils associate-iam-oidc-provider \ | ||
--region $REGION \ | ||
--cluster $CLUSTER_NAME \ | ||
--approve | ||
|
||
echo "Creating AWSLoadbalancerController IAM Policy" | ||
curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.2.1/docs/install/iam_policy.json | ||
|
||
aws iam create-policy \ | ||
--policy-name AWSLoadBalancerControllerIAMPolicy \ | ||
--policy-document file://iam-policy.json || true | ||
|
||
echo "Creating IAM serviceaccount" | ||
eksctl create iamserviceaccount \ | ||
--cluster=$CLUSTER_NAME \ | ||
--namespace=kube-system \ | ||
--name=aws-load-balancer-controller \ | ||
--attach-policy-arn=arn:aws:iam::$ACCOUNT_ID:policy/AWSLoadBalancerControllerIAMPolicy \ | ||
--override-existing-serviceaccounts \ | ||
--approve || true | ||
|
||
echo "Update helm repo eks" | ||
helm repo add eks https://aws.github.io/eks-charts | ||
|
||
helm repo update | ||
|
||
echo "Install TargetGroupBinding CRDs" | ||
kubectl apply -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller//crds?ref=master" | ||
|
||
echo "Install aws-load-balancer-controller" | ||
helm upgrade -i aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=$CLUSTER_NAME --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller | ||
|
||
#Start the test | ||
echo "Starting the ginkgo test suite" | ||
|
||
(cd $SCRIPT_DIR && CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo -v -r --timeout 60m --failOnPending -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID || true) | ||
|
||
echo "Delete aws-load-balancer-controller" | ||
helm delete aws-load-balancer-controller -n kube-system --timeout=10m || true | ||
|
||
echo "Delete iamserviceaccount" | ||
eksctl delete iamserviceaccount --name aws-load-balancer-controller --namespace kube-system --cluster $CLUSTER_NAME --timeout=10m || true | ||
|
||
echo "Delete TargetGroupBinding CRDs" | ||
kubectl delete -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller//crds?ref=master" --timeout=10m || true | ||
|
||
echo "Uncordon windows nodes" | ||
toggle_windows_scheduling "uncordon" | ||
|
||
echo "Successfully finished the test suite $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.