Skip to content

Commit 58111cd

Browse files
author
cgchinmay
authored
Add controller deployment ready logic to e2e script (#2658)
Add error handling
1 parent a9beee7 commit 58111cd

File tree

2 files changed

+51
-9
lines changed

2 files changed

+51
-9
lines changed

scripts/run-e2e-test.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,30 @@ kubectl apply -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller/
5151
echo "Install aws-load-balancer-controller"
5252
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
5353

54+
echo_time() {
55+
date +"%D %T $*"
56+
}
57+
58+
wait_until_deployment_ready() {
59+
NS=""
60+
if [ ! -z $2 ]; then
61+
NS="-n $2"
62+
fi
63+
echo_time "Checking if deployment $1 is ready"
64+
for i in $(seq 1 60); do
65+
desiredReplicas=$(kubectl get deployments.apps $1 $NS -ojsonpath="{.spec.replicas}")
66+
availableReplicas=$(kubectl get deployments.apps $1 $NS -ojsonpath="{.status.availableReplicas}")
67+
if [[ ! -z $desiredReplicas && ! -z $availableReplicas && "$desiredReplicas" -eq "$availableReplicas" ]]; then
68+
break
69+
fi
70+
echo -n "."
71+
sleep 2
72+
done
73+
echo_time "Deployment $1 $NS replicas desired=$desiredReplicas available=$availableReplicas"
74+
}
75+
76+
wait_until_deployment_ready aws-load-balancer-controller kube-system
77+
5478
function run_ginkgo_test() {
5579
local focus=$1
5680
echo "Starting the ginkgo tests from generated ginkgo test binaries with focus: $focus"

test/e2e/ingress/vanilla_ingress_test.go

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ var _ = Describe("vanilla ingress tests", func() {
102102
WithIngressClassName(ingClass.Name).
103103
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
104104
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ingClass, ing)
105-
resStack.Setup(ctx)
105+
err := resStack.Setup(ctx)
106+
Expect(err).NotTo(HaveOccurred())
107+
106108
defer resStack.TearDown(ctx)
107109

108110
lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)
@@ -138,7 +140,9 @@ var _ = Describe("vanilla ingress tests", func() {
138140
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
139141
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
140142
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ing)
141-
resStack.Setup(ctx)
143+
err := resStack.Setup(ctx)
144+
Expect(err).NotTo(HaveOccurred())
145+
142146
defer resStack.TearDown(ctx)
143147

144148
lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)
@@ -183,7 +187,9 @@ var _ = Describe("vanilla ingress tests", func() {
183187
WithIngressClassName(ingClass.Name).
184188
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
185189
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ingClass, ing)
186-
resStack.Setup(ctx)
190+
err := resStack.Setup(ctx)
191+
Expect(err).NotTo(HaveOccurred())
192+
187193
defer resStack.TearDown(ctx)
188194

189195
ExpectNoLBProvisionedForIngress(ctx, tf, ing)
@@ -212,7 +218,9 @@ var _ = Describe("vanilla ingress tests", func() {
212218
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
213219
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
214220
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ing)
215-
resStack.Setup(ctx)
221+
err := resStack.Setup(ctx)
222+
Expect(err).NotTo(HaveOccurred())
223+
216224
defer resStack.TearDown(ctx)
217225

218226
ExpectNoLBProvisionedForIngress(ctx, tf, ing)
@@ -240,7 +248,9 @@ var _ = Describe("vanilla ingress tests", func() {
240248
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
241249
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
242250
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ing)
243-
resStack.Setup(ctx)
251+
err := resStack.Setup(ctx)
252+
Expect(err).NotTo(HaveOccurred())
253+
244254
defer resStack.TearDown(ctx)
245255

246256
ExpectNoLBProvisionedForIngress(ctx, tf, ing)
@@ -275,7 +285,9 @@ var _ = Describe("vanilla ingress tests", func() {
275285
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
276286
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
277287
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ing)
278-
resStack.Setup(ctx)
288+
err := resStack.Setup(ctx)
289+
Expect(err).NotTo(HaveOccurred())
290+
279291
defer resStack.TearDown(ctx)
280292

281293
lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)
@@ -318,7 +330,9 @@ var _ = Describe("vanilla ingress tests", func() {
318330
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
319331
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
320332
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ing)
321-
resStack.Setup(ctx)
333+
err := resStack.Setup(ctx)
334+
Expect(err).NotTo(HaveOccurred())
335+
322336
defer resStack.TearDown(ctx)
323337

324338
lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)
@@ -389,7 +403,9 @@ var _ = Describe("vanilla ingress tests", func() {
389403
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/forward-multiple-tg", PathType: &exact, Backend: ingForwardMultipleTGBackend}).
390404
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
391405
resStack := fixture.NewK8SResourceStack(tf, dp1, svc1, dp2, svc2, ing)
392-
resStack.Setup(ctx)
406+
err := resStack.Setup(ctx)
407+
Expect(err).NotTo(HaveOccurred())
408+
393409
defer resStack.TearDown(ctx)
394410

395411
lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)
@@ -503,7 +519,9 @@ var _ = Describe("vanilla ingress tests", func() {
503519
AddHTTPRoute("www.example.com", networking.HTTPIngressPath{Path: "/path7", PathType: &exact, Backend: ingRulePath7Backend}).
504520
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
505521
resStack := fixture.NewK8SResourceStack(tf, ing)
506-
resStack.Setup(ctx)
522+
err := resStack.Setup(ctx)
523+
Expect(err).NotTo(HaveOccurred())
524+
507525
defer resStack.TearDown(ctx)
508526

509527
lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)

0 commit comments

Comments
 (0)