Skip to content

Commit bc57291

Browse files
authored
Merge pull request #3841 from Skarlso/fix_ipv6_e2e_test
[E2E] Add check that the pod list is not empty.
2 parents 6df68e2 + 1c910a5 commit bc57291

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

test/e2e/suites/managed/eks_ipv6_test.go

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package managed
2222
import (
2323
"context"
2424
"fmt"
25+
"time"
2526

2627
"github.com/onsi/ginkgo"
2728
. "github.com/onsi/gomega"
@@ -96,19 +97,32 @@ var _ = ginkgo.Describe("[managed] [general] [ipv6] EKS cluster tests", func() {
9697
Name: clusterName,
9798
})
9899
Expect(cluster).NotTo(BeNil(), "couldn't find CAPI cluster")
99-
// Don't replace this with var pods *corev1.PodsList as that results in a nil pointer error from List.
100-
pods := &corev1.PodList{}
101-
listOptions := []client.ListOption{
102-
client.InNamespace(namespace.Namespace),
103-
client.MatchingLabels(map[string]string{"app": "aws-node"}),
104-
}
105-
clusterClient := e2eCtx.Environment.BootstrapClusterProxy.GetWorkloadCluster(ctx, namespace.Name, clusterName).GetClient()
106-
err := clusterClient.List(ctx, pods, listOptions...)
107-
Expect(err).ToNot(HaveOccurred())
108-
109-
for _, pod := range pods.Items {
110-
Expect(net.IsIPv6String(pod.Status.PodIP)).To(BeTrue())
111-
}
100+
101+
Eventually(func() bool {
102+
pods := &corev1.PodList{}
103+
listOptions := []client.ListOption{
104+
client.InNamespace(namespace.Namespace),
105+
client.MatchingLabels(map[string]string{"k8s-app": "aws-node"}),
106+
}
107+
clusterClient := e2eCtx.Environment.BootstrapClusterProxy.GetWorkloadCluster(ctx, namespace.Name, clusterName).GetClient()
108+
err := clusterClient.List(ctx, pods, listOptions...)
109+
Expect(err).ToNot(HaveOccurred())
110+
shared.Byf("checking if pods list is empty: %d", len(pods.Items))
111+
if len(pods.Items) == 0 {
112+
return false
113+
}
114+
for _, pod := range pods.Items {
115+
shared.Byf("checking if pod ip address is ipv6 based: %s/%s", pod.Name, pod.Status.PodIP)
116+
if pod.Status.PodIP == "" {
117+
return false
118+
}
119+
if !net.IsIPv6String(pod.Status.PodIP) {
120+
return false
121+
}
122+
}
123+
124+
return true
125+
}).WithTimeout(5*time.Minute).WithPolling(10*time.Second).Should(BeTrue(), "failed to wait for pods to appear and have ipv6 address")
112126

113127
framework.DeleteCluster(ctx, framework.DeleteClusterInput{
114128
Deleter: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),

0 commit comments

Comments
 (0)