From f5bb5234c1225a7150d426e596d0dba02af36e5e Mon Sep 17 00:00:00 2001 From: Zihong Zheng Date: Thu, 1 Feb 2018 14:18:43 -0800 Subject: [PATCH] [e2e ingress-gce] Retrieve the correct health check resource --- test/e2e/network/ingress.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/test/e2e/network/ingress.go b/test/e2e/network/ingress.go index 3db1af1a06..5b7f6df9d5 100644 --- a/test/e2e/network/ingress.go +++ b/test/e2e/network/ingress.go @@ -256,29 +256,27 @@ var _ = SIGDescribe("Loadbalancing: L7", func() { // Get cluster UID. clusterID, err := framework.GetClusterID(f.ClientSet) Expect(err).NotTo(HaveOccurred()) - // Get default backend nodeport. - defaultBackendNodePort, err := jig.GetDefaultBackendNodePort() - Expect(err).NotTo(HaveOccurred()) + // Get the related nodeports. + nodePorts := jig.GetIngressNodePorts(false) + Expect(len(nodePorts)).ToNot(Equal(0)) // Filter health check using cluster UID as the suffix. By("Retrieving relevant health check resources from GCE.") gceCloud := gceController.Cloud.Provider.(*gcecloud.GCECloud) hcs, err := gceCloud.ListHealthChecks() Expect(err).NotTo(HaveOccurred()) - ingressHCs := []*compute.HealthCheck{} + var hcToChange *compute.HealthCheck for _, hc := range hcs { if strings.HasSuffix(hc.Name, clusterID) { - Expect(hc.HttpHealthCheck).ToNot(Equal(nil)) - // Skip the default backend healthcheck as that shouldn't be customized. - if hc.HttpHealthCheck.Port == int64(defaultBackendNodePort) { - continue + Expect(hc.HttpHealthCheck).NotTo(BeNil()) + if fmt.Sprintf("%d", hc.HttpHealthCheck.Port) == nodePorts[0] { + hcToChange = hc + break } - ingressHCs = append(ingressHCs, hc) } } + Expect(hcToChange).NotTo(BeNil()) - Expect(len(ingressHCs)).ToNot(Equal(0)) - hcToChange := ingressHCs[0] By(fmt.Sprintf("Modifying health check %v without involving ingress.", hcToChange.Name)) // Change timeout from 60s to 25s. hcToChange.TimeoutSec = 25