4
4
5
5
set -e
6
6
7
- SECONDS=0
8
7
SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " > /dev/null 2>&1 && pwd ) "
9
- echo " Running AWS Load Balancer Controller e2e tests with the following variables
10
- KUBE_CONFIG_PATH: $KUBE_CONFIG_PATH
11
- CLUSTER_NAME: $CLUSTER_NAME
12
- REGION: $REGION
13
- IP_FAMILY: ${IP_FAMILY:- " IPv4" }
14
- OS_OVERRIDE: $OS_OVERRIDE "
8
+ GINKGO_TEST_BUILD=" $SCRIPT_DIR /../test/build"
9
+
10
+ source " $SCRIPT_DIR " /lib/common.sh
15
11
16
12
function toggle_windows_scheduling(){
17
13
schedule=$1
@@ -22,37 +18,18 @@ function toggle_windows_scheduling(){
22
18
done
23
19
}
24
20
25
- if [[ -z " ${OS_OVERRIDE} " ]]; then
26
- OS_OVERRIDE=linux
27
- fi
28
-
29
- GET_CLUSTER_INFO_CMD=" aws eks describe-cluster --name $CLUSTER_NAME --region $REGION "
30
-
31
- if [[ -z " ${ENDPOINT} " ]]; then
32
- CLUSTER_INFO=$( $GET_CLUSTER_INFO_CMD )
33
- else
34
- CLUSTER_INFO=$( $GET_CLUSTER_INFO_CMD --endpoint $ENDPOINT )
35
- fi
36
-
37
21
echo " Cordon off windows nodes"
38
22
toggle_windows_scheduling " cordon"
39
23
40
- VPC_ID=$( echo $CLUSTER_INFO | jq -r ' .cluster.resourcesVpcConfig.vpcId' )
41
- ACCOUNT_ID=$( aws sts get-caller-identity | jq -r ' .Account' )
42
-
43
- echo " VPC ID: $VPC_ID "
44
-
45
24
eksctl utils associate-iam-oidc-provider \
46
25
--region $REGION \
47
26
--cluster $CLUSTER_NAME \
48
27
--approve
49
28
50
29
echo " Creating AWSLoadbalancerController IAM Policy"
51
- curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.2.1/docs/install/iam_policy.json
52
-
53
30
aws iam create-policy \
54
31
--policy-name AWSLoadBalancerControllerIAMPolicy \
55
- --policy-document file://iam-policy .json || true
32
+ --policy-document file://" $SCRIPT_DIR " /../docs/install/iam_policy .json || true
56
33
57
34
echo " Creating IAM serviceaccount"
58
35
eksctl create iamserviceaccount \
@@ -74,16 +51,22 @@ kubectl apply -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller/
74
51
echo " Install aws-load-balancer-controller"
75
52
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 --set region=$REGION --set vpcId=$VPC_ID
76
53
54
+ function run_ginkgo_test() {
55
+ local focus=$1
56
+ echo " Starting the ginkgo tests from generated ginkgo test binaries with focus: $focus "
57
+ if [ " $IP_FAMILY " == " IPv4" ]; then
58
+ (CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo $EXTRA_GINKGO_FLAGS --focus=" $focus " -v --timeout 60m --fail-on-pending $GINKGO_TEST_BUILD /ingress.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --ip-family=$IP_FAMILY || true)
59
+ (CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo $EXTRA_GINKGO_FLAGS --focus=" $focus " -v --timeout 60m --fail-on-pending $GINKGO_TEST_BUILD /service.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --ip-family=$IP_FAMILY || true)
60
+ elif [ " $IP_FAMILY " == " IPv6" ]; then
61
+ (CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo $EXTRA_GINKGO_FLAGS --focus=" $focus " --skip=" instance" -v --timeout 60m --fail-on-pending $GINKGO_TEST_BUILD /ingress.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --ip-family=$IP_FAMILY || true)
62
+ (CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo $EXTRA_GINKGO_FLAGS --focus=" $focus " --skip=" instance" -v --timeout 60m --fail-on-pending $GINKGO_TEST_BUILD /service.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --ip-family=$IP_FAMILY || true)
63
+ else
64
+ echo " Invalid IP_FAMILY input, choose from IPv4 or IPv6 only"
65
+ fi
66
+ }
67
+
77
68
# Start the test
78
- echo " Starting the ginkgo test suite"
79
- if [ " $IP_FAMILY " == " IPv4" ]; then
80
- (cd $SCRIPT_DIR && CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo -v -r --timeout 60m --fail-on-pending -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --ip-family=$IP_FAMILY || true)
81
- elif [ " $IP_FAMILY " == " IPv6" ]; then
82
- (cd $SCRIPT_DIR && CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo --skip=" instance" -v -r --timeout 60m --fail-on-pending -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --ip-family=$IP_FAMILY || true)
83
- else
84
- echo " Invalid IP_FAMILY input, choose from IPv4 or IPv6 only"
85
- exit
86
- fi
69
+ run_ginkgo_test
87
70
88
71
# tail=-1 is added so that no logs are truncated
89
72
# https://github.com/kubernetes/kubectl/issues/812
@@ -102,4 +85,8 @@ kubectl delete -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller
102
85
echo " Uncordon windows nodes"
103
86
toggle_windows_scheduling " uncordon"
104
87
105
- echo " Successfully finished the test suite $(( $SECONDS / 60 )) minutes and $(( $SECONDS % 60 )) seconds"
88
+ # Need to do this as last step
89
+ echo " Delete IAM Policy"
90
+ aws iam delete-policy --policy-arn arn:aws:iam::$ACCOUNT_ID :policy/AWSLoadBalancerControllerIAMPolicy || true
91
+
92
+ echo " Successfully finished the test suite $(( $SECONDS / 60 )) minutes and $(( $SECONDS % 60 )) seconds"
0 commit comments