func updateIngressOrFail(clientset *fedclientset.Clientset, namespace string) (newIng *v1beta1.Ingress) { var err error if clientset == nil || len(namespace) == 0 { Fail(fmt.Sprintf("Internal error: invalid parameters passed to createIngressOrFail: clientset: %v, namespace: %v", clientset, namespace)) } ingress := &v1beta1.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: FederatedIngressName, }, Spec: v1beta1.IngressSpec{ Backend: &v1beta1.IngressBackend{ ServiceName: "updated-testingress-service", ServicePort: intstr.FromInt(80), }, }, } err = waitForFederatedIngressExists(clientset, namespace, FederatedIngressName, FederatedIngressTimeout) if err != nil { framework.Failf("failed to get ingress %q: %v", FederatedIngressName, err) } for i := 0; i < MaxRetriesOnFederatedApiserver; i++ { newIng, err = clientset.Extensions().Ingresses(namespace).Update(ingress) if err == nil { framework.DescribeIng(namespace) return newIng } if !errors.IsConflict(err) && !errors.IsServerTimeout(err) { framework.Failf("failed to update ingress %q: %v", FederatedIngressName, err) } } framework.Failf("too many retries updating ingress %q", FederatedIngressName) return nil }
func (j *testJig) update(update func(ing *extensions.Ingress)) { var err error ns, name := j.ing.Namespace, j.ing.Name for i := 0; i < 3; i++ { j.ing, err = j.client.Extensions().Ingresses(ns).Get(name, metav1.GetOptions{}) if err != nil { framework.Failf("failed to get ingress %q: %v", name, err) } update(j.ing) j.ing, err = j.client.Extensions().Ingresses(ns).Update(j.ing) if err == nil { framework.DescribeIng(j.ing.Namespace) return } if !apierrs.IsConflict(err) && !apierrs.IsServerTimeout(err) { framework.Failf("failed to update ingress %q: %v", name, err) } } framework.Failf("too many retries updating ingress %q", name) }
// Platform specific setup BeforeEach(func() { framework.SkipUnlessProviderIs("gce", "gke") By("Initializing gce controller") gceController = &GCEIngressController{ ns: ns, c: jig.client, cloud: framework.TestContext.CloudConfig, } gceController.init() }) // Platform specific cleanup AfterEach(func() { if CurrentGinkgoTestDescription().Failed { framework.DescribeIng(ns) } if jig.ing == nil { By("No ingress created, no cleanup necessary") return } By("Deleting ingress") jig.deleteIngress() By("Cleaning up cloud resources") cleanupGCE(gceController) }) It("should conform to Ingress spec", func() { conformanceTests = createComformanceTests(jig, ns) for _, t := range conformanceTests {