Alter e2e test for disable_catch_all.go

This commit is contained in:
Mahnoor Mehboob 2021-04-22 12:01:41 -04:00
parent cc4d5f2283
commit 2503b23b09
2 changed files with 21 additions and 9 deletions

View file

@ -328,7 +328,7 @@ func New(
return
}
if hasCatchAllIngress(ing.Spec) && disableCatchAll {
if hasCatchAllIngressRule(ing.Spec) && disableCatchAll {
klog.InfoS("Ignoring delete for catch-all because of --disable-catch-all", "ingress", klog.KObj(ing))
return
}
@ -353,7 +353,7 @@ func New(
return
}
if hasCatchAllIngress(ing.Spec) && disableCatchAll {
if hasCatchAllIngressRule(ing.Spec) && disableCatchAll {
klog.InfoS("Ignoring add for catch-all ingress because of --disable-catch-all", "ingress", klog.KObj(ing))
return
}
@ -377,7 +377,7 @@ func New(
validOld := class.IsValid(oldIng)
validCur := class.IsValid(curIng)
if !validOld && validCur {
if hasCatchAllIngress(curIng.Spec) && disableCatchAll {
if hasCatchAllIngressRule(curIng.Spec) && disableCatchAll {
klog.InfoS("ignoring update for catch-all ingress because of --disable-catch-all", "ingress", klog.KObj(curIng))
return
}
@ -389,7 +389,7 @@ func New(
ingDeleteHandler(old)
return
} else if validCur && !reflect.DeepEqual(old, cur) {
if hasCatchAllIngress(curIng.Spec) && disableCatchAll {
if hasCatchAllIngressRule(curIng.Spec) && disableCatchAll {
klog.InfoS("ignoring update for catch-all ingress and delete old one because of --disable-catch-all", "ingress", klog.KObj(curIng))
ingDeleteHandler(old)
return
@ -624,9 +624,9 @@ func New(
return store
}
// hasCatchAllIngress returns whether or not an ingress produces a
// hasCatchAllIngressRule returns whether or not an ingress produces a
// catch-all server, and so should be ignored when --disable-catch-all is set
func hasCatchAllIngress(spec networkingv1beta1.IngressSpec) bool {
func hasCatchAllIngressRule(spec networkingv1beta1.IngressSpec) bool {
return spec.Backend != nil
}

View file

@ -48,7 +48,7 @@ var _ = framework.IngressNginxDescribe("[Flag] disable-catch-all", func() {
assert.Nil(ginkgo.GinkgoT(), err, "updating ingress controller deployment flags")
})
ginkgo.It("should ignore catch all Ingress", func() {
ginkgo.It("should ignore catch all Ingress with backend", func() {
host := "foo"
ing := framework.NewSingleCatchAllIngress("catch-all", f.Namespace, framework.EchoService, 80, nil)
@ -67,6 +67,18 @@ var _ = framework.IngressNginxDescribe("[Flag] disable-catch-all", func() {
})
})
ginkgo.It("should ignore catch all Ingress with backend and rules", func() {
host := "foo"
ing := framework.NewSingleIngressWithBackendAndRules(host, "/", host, f.Namespace, framework.EchoService, 80, framework.EchoService, 80, nil)
f.EnsureIngress(ing)
f.WaitForNginxServer("_", func(cfg string) bool {
return strings.Contains(cfg, `set $ingress_name ""`) &&
strings.Contains(cfg, `set $proxy_upstream_name "upstream-default-backend"`)
})
})
ginkgo.It("should delete Ingress updated to catch-all", func() {
host := "foo"
@ -105,10 +117,10 @@ var _ = framework.IngressNginxDescribe("[Flag] disable-catch-all", func() {
Status(http.StatusNotFound)
})
ginkgo.It("should allow Ingress with both a default backend and rules", func() {
ginkgo.It("should allow Ingress with rules", func() {
host := "foo"
ing := framework.NewSingleIngressWithBackendAndRules("not-catch-all", "/rulepath", host, f.Namespace, framework.EchoService, 80, framework.EchoService, 80, nil)
ing := framework.NewSingleIngress("not-catch-all", "/", host, f.Namespace, framework.EchoService, 80, nil)
f.EnsureIngress(ing)
f.WaitForNginxServer(host, func(cfg string) bool {