diff --git a/test/e2e/framework/ingress_utils.go b/test/e2e/framework/ingress_utils.go index 27a517604ee..566b082e81b 100644 --- a/test/e2e/framework/ingress_utils.go +++ b/test/e2e/framework/ingress_utils.go @@ -62,7 +62,12 @@ const ( validFor = 365 * 24 * time.Hour // Ingress class annotation defined in ingress repository. - ingressClass = "kubernetes.io/ingress.class" + // TODO: All these annotations should be reused from + // ingress-gce/pkg/annotations instead of duplicating them here. + IngressClass = "kubernetes.io/ingress.class" + + // Ingress class annotation value for multi cluster ingress. + MulticlusterIngressClassValue = "gce-multi-cluster" // all cloud resources created by the ingress controller start with this // prefix. @@ -937,7 +942,7 @@ func (j *IngressTestJig) CreateIngress(manifestPath, ns string, ingAnnotations m j.Ingress, err = manifest.IngressFromManifest(filepath.Join(manifestPath, "ing.yaml")) ExpectNoError(err) j.Ingress.Namespace = ns - j.Ingress.Annotations = map[string]string{ingressClass: j.Class} + j.Ingress.Annotations = map[string]string{IngressClass: j.Class} for k, v := range ingAnnotations { j.Ingress.Annotations[k] = v } diff --git a/test/e2e/network/ingress.go b/test/e2e/network/ingress.go index 45577f1131e..4a4736702e0 100644 --- a/test/e2e/network/ingress.go +++ b/test/e2e/network/ingress.go @@ -33,8 +33,9 @@ import ( ) const ( - NEGAnnotation = "alpha.cloud.google.com/load-balancer-neg" - NEGUpdateTimeout = 2 * time.Minute + NEGAnnotation = "alpha.cloud.google.com/load-balancer-neg" + NEGUpdateTimeout = 2 * time.Minute + instanceGroupAnnotation = "ingress.gcp.kubernetes.io/instance-groups" ) var _ = SIGDescribe("Loadbalancing: L7", func() { @@ -153,6 +154,29 @@ var _ = SIGDescribe("Loadbalancing: L7", func() { // framework.ExpectNoError(jig.verifyURL(fmt.Sprintf("https://%v/", ip), "", 30, 1*time.Second, httpClient)) }) + It("multicluster ingress should get instance group annotation", func() { + name := "echomap" + jig.CreateIngress(filepath.Join(framework.IngressManifestPath, "http"), ns, map[string]string{ + framework.IngressClass: framework.MulticlusterIngressClassValue, + }, map[string]string{}) + + By(fmt.Sprintf("waiting for Ingress %s to come up", name)) + pollErr := wait.Poll(2*time.Second, framework.LoadBalancerPollTimeout, func() (bool, error) { + ing, err := f.ClientSet.ExtensionsV1beta1().Ingresses(ns).Get(name, metav1.GetOptions{}) + framework.ExpectNoError(err) + annotations := ing.Annotations + if annotations == nil || annotations[instanceGroupAnnotation] == "" { + framework.Logf("Waiting for ingress to get %s annotation. Found annotations: %v", instanceGroupAnnotation, annotations) + return false, nil + } + return true, nil + }) + if pollErr != nil { + framework.ExpectNoError(fmt.Errorf("Timed out waiting for ingress %s to get %s annotation", name, instanceGroupAnnotation)) + } + // TODO(nikhiljindal): Check the instance group annotation value and verify with a multizone cluster. + }) + // TODO: Implement a multizone e2e that verifies traffic reaches each // zone based on pod labels. })