Skip to content

Commit

Permalink
Fix e2e ingress IP helper
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Feb 7, 2025
1 parent 567a2e8 commit b9c7693
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
12 changes: 7 additions & 5 deletions tests/e2e/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,17 @@ func FetchExternalIPs(kubeconfig string, servicename string) ([]string, error) {
return externalIPs, nil
}

func FetchIngressIP(kubeconfig string) ([]string, error) {
cmd := "kubectl get ing ingress -o jsonpath='{.status.loadBalancer.ingress[*].ip}' --kubeconfig=" + kubeconfig
func FetchIngressIP(namespace, name, kubeconfig string) ([]string, error) {
cmd := fmt.Sprintf("kubectl get ingress -n %s %s -o jsonpath='{.status.loadBalancer.ingress[*].ip}' --kubeconfig=%s", namespace, name, kubeconfig)
res, err := RunCommand(cmd)
if err != nil {
return nil, err
}
ingressIP := strings.Trim(res, " ")
ingressIPs := strings.Split(ingressIP, " ")
return ingressIPs, nil
res = strings.TrimSpace(res)
if res == "" {
return nil, fmt.Errorf("no IPs found for ingress %s/%s", namespace, name)
}
return strings.Split(res, " "), nil
}

func (v VagrantNode) FetchNodeExternalIP() (string, error) {
Expand Down
11 changes: 8 additions & 3 deletions tests/e2e/wasm/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,14 @@ var _ = Describe("Verify K3s can run Wasm workloads", Ordered, func() {
})

It("Interact with Wasm applications", func() {
ingressIPs, err := e2e.FetchIngressIP(tc.KubeConfigFile)
Expect(err).NotTo(HaveOccurred())
Expect(ingressIPs).To(HaveLen(1))
var ingressIPs []string
var err error

Eventually(func() {
ingressIPs, err = e2e.FetchIngressIP("default", "ingress", tc.KubeConfigFile)
Expect(err).NotTo(HaveOccurred())
Expect(ingressIPs).To(HaveLen(1))
}, "120s", "5s").Should(Succeed())

endpoints := []string{"slight/hello", "spin/go-hello", "spin/hello"}
for _, endpoint := range endpoints {
Expand Down

0 comments on commit b9c7693

Please sign in to comment.