Skip to content

Commit ad885c0

Browse files
committed
e2e
1 parent 9f8b238 commit ad885c0

File tree

1 file changed

+72
-4
lines changed

1 file changed

+72
-4
lines changed

tests/e2e/test_istio_kafka_cluster.go

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,85 @@ func testValidateIstioResources() bool {
5656
gomega.Expect(err).NotTo(gomega.HaveOccurred())
5757
})
5858

59+
ginkgo.It("Checking Kafka cluster status", func() {
60+
// Check if the Kafka cluster exists and is ready
61+
clusterStatus, err := k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), &kubectlOptions, "get", "kafkaclusters.kafka.banzaicloud.io", "kafka", "-o", "jsonpath={.status.state}")
62+
if err != nil {
63+
ginkgo.By(fmt.Sprintf("Error getting Kafka cluster status: %v", err))
64+
} else {
65+
ginkgo.By(fmt.Sprintf("Kafka cluster status: %s", clusterStatus))
66+
}
67+
68+
// Check if the Kafka cluster has external listeners configured
69+
externalListeners, err := k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), &kubectlOptions, "get", "kafkaclusters.kafka.banzaicloud.io", "kafka", "-o", "jsonpath={.spec.listenersConfig.externalListeners}")
70+
if err != nil {
71+
ginkgo.By(fmt.Sprintf("Error getting external listeners: %v", err))
72+
} else {
73+
ginkgo.By(fmt.Sprintf("External listeners: %s", externalListeners))
74+
}
75+
76+
// Check the ingress controller setting
77+
ingressController, err := k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), &kubectlOptions, "get", "kafkaclusters.kafka.banzaicloud.io", "kafka", "-o", "jsonpath={.spec.ingressController}")
78+
if err != nil {
79+
ginkgo.By(fmt.Sprintf("Error getting ingress controller: %v", err))
80+
} else {
81+
ginkgo.By(fmt.Sprintf("Ingress controller: %s", ingressController))
82+
}
83+
})
84+
85+
ginkgo.It("Checking Istio ingress gateway status", func() {
86+
// Check if the standard Istio ingress gateway is running
87+
gatewayPods, err := k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), &kubectlOptions, "get", "pods", "--all-namespaces", "-l", "app=istio-ingressgateway", "-o", "jsonpath={.items[*].status.phase}")
88+
if err != nil {
89+
ginkgo.By(fmt.Sprintf("Error getting Istio ingress gateway pods: %v", err))
90+
} else {
91+
ginkgo.By(fmt.Sprintf("Istio ingress gateway pod statuses: %s", gatewayPods))
92+
}
93+
94+
// Check if there are any Istio Gateway resources at all (including system ones)
95+
allGateways, err := k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), &kubectlOptions, "get", "gateways.networking.istio.io", "--all-namespaces", "-o", "name")
96+
if err != nil {
97+
ginkgo.By(fmt.Sprintf("Error getting all Gateway resources: %v", err))
98+
} else {
99+
ginkgo.By(fmt.Sprintf("All Istio Gateway resources: %s", allGateways))
100+
}
101+
})
102+
59103
ginkgo.It("Validating Istio Gateway resources", func() {
60-
// Check for Istio Gateway resources
61-
gateways, err := k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), &kubectlOptions, "get", "gateways.networking.istio.io", "--all-namespaces", "-o", "name")
104+
// Check for Istio Gateway resources with retry logic
105+
var gateways string
106+
var err error
107+
108+
// Wait up to 2 minutes for Gateway resources to be created
109+
for i := 0; i < 24; i++ {
110+
gateways, err = k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), &kubectlOptions, "get", "gateways.networking.istio.io", "--all-namespaces", "-o", "name")
111+
if err == nil && gateways != "" {
112+
break
113+
}
114+
ginkgo.By(fmt.Sprintf("Waiting for Istio Gateway resources... (attempt %d/24)", i+1))
115+
time.Sleep(5 * time.Second)
116+
}
117+
62118
gomega.Expect(err).NotTo(gomega.HaveOccurred())
63119
gomega.Expect(gateways).NotTo(gomega.BeEmpty())
64120
ginkgo.By(fmt.Sprintf("Found Istio Gateways: %s", gateways))
65121
})
66122

67123
ginkgo.It("Validating Istio VirtualService resources", func() {
68-
// Check for Istio VirtualService resources
69-
virtualServices, err := k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), &kubectlOptions, "get", "virtualservices.networking.istio.io", "--all-namespaces", "-o", "name")
124+
// Check for Istio VirtualService resources with retry logic
125+
var virtualServices string
126+
var err error
127+
128+
// Wait up to 2 minutes for VirtualService resources to be created
129+
for i := 0; i < 24; i++ {
130+
virtualServices, err = k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), &kubectlOptions, "get", "virtualservices.networking.istio.io", "--all-namespaces", "-o", "name")
131+
if err == nil && virtualServices != "" {
132+
break
133+
}
134+
ginkgo.By(fmt.Sprintf("Waiting for Istio VirtualService resources... (attempt %d/24)", i+1))
135+
time.Sleep(5 * time.Second)
136+
}
137+
70138
gomega.Expect(err).NotTo(gomega.HaveOccurred())
71139
gomega.Expect(virtualServices).NotTo(gomega.BeEmpty())
72140
ginkgo.By(fmt.Sprintf("Found Istio VirtualServices: %s", virtualServices))

0 commit comments

Comments
 (0)