* Adding test cases for backend with nil service Signed-off-by: Marcos <marcosnery.comp@gmail.com> Co-authored-by: Renato Araujo <renatobritto@protonmail.com> Co-authored-by: André Goretti <andremotta96@gmail.com> Co-authored-by: Kalebe Lopes <calbkalebe@gmail.com> * Add e2e test for backend nil service and add nil safeguard (#7344) Co-authored-by: Renato Araujo <renatobritto@protonmail.com> Co-authored-by: André Goretti <andremotta96@gmail.com> Co-authored-by: Kalebe Lopes <calbkalebe@gmail.com> * changing portuguese names to english in order to maintain the pattern * updating boilerplate header * adding second test case to also test valid path Co-authored-by: Ricardo Katz <rikatz@users.noreply.github.com> * Updating boilerplate * fixing boilerplate Signed-off-by: MarcosN <marcosnery.comp@gmail.com> Co-authored-by: André Goretti <andremotta96@gmail.com> Co-authored-by: Gabriel Albino <enggabrielalbino@gmail.com> * Improving template test for cases where a nil backend service is included Signed-off-by: MarcosN <marcosnery.comp@gmail.com> Co-authored-by: André Goretti <andremotta96@gmail.com> Co-authored-by: Gabriel Albino <enggabrielalbino@gmail.com> Co-authored-by: Renato Araujo <renatobritto@protonmail.com> Co-authored-by: André Goretti <andremotta96@gmail.com> Co-authored-by: Kalebe Lopes <calbkalebe@gmail.com> Co-authored-by: Ricardo Katz <rikatz@users.noreply.github.com> Co-authored-by: Gabriel Albino <enggabrielalbino@gmail.com>
This commit is contained in:
parent
f5fe7615ac
commit
638a93835a
3 changed files with 210 additions and 0 deletions
|
|
@ -1018,6 +1018,10 @@ func getIngressInformation(i, h, p interface{}) *ingressInformation {
|
|||
continue
|
||||
}
|
||||
|
||||
if rPath.Backend.Service == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if info.Service != "" && rPath.Backend.Service.Name == "" {
|
||||
// empty rule. Only contains a Path and PathType
|
||||
return info
|
||||
|
|
|
|||
|
|
@ -1203,6 +1203,106 @@ func TestGetIngressInformation(t *testing.T) {
|
|||
ServicePort: "b-svc-80",
|
||||
},
|
||||
},
|
||||
"valid ingress definition with name demo in namespace something and path /ok with a nil backend service": {
|
||||
&ingress.Ingress{
|
||||
Ingress: networking.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "demo",
|
||||
Namespace: "something",
|
||||
Annotations: map[string]string{
|
||||
"ingress.annotation": "ok",
|
||||
},
|
||||
},
|
||||
Spec: networking.IngressSpec{
|
||||
Rules: []networking.IngressRule{
|
||||
{
|
||||
Host: "foo.bar",
|
||||
IngressRuleValue: networking.IngressRuleValue{
|
||||
HTTP: &networking.HTTPIngressRuleValue{
|
||||
Paths: []networking.HTTPIngressPath{
|
||||
{
|
||||
Path: "/ok",
|
||||
PathType: &pathPrefix,
|
||||
Backend: networking.IngressBackend{
|
||||
Service: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"foo.bar",
|
||||
"/ok",
|
||||
&ingressInformation{
|
||||
Namespace: "something",
|
||||
Rule: "demo",
|
||||
Annotations: map[string]string{
|
||||
"ingress.annotation": "ok",
|
||||
},
|
||||
},
|
||||
},
|
||||
"valid ingress definition with name demo in namespace something and path /ok with both a nil service and a valid one": {
|
||||
&ingress.Ingress{
|
||||
Ingress: networking.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "demo",
|
||||
Namespace: "something",
|
||||
Annotations: map[string]string{
|
||||
"ingress.annotation": "ok",
|
||||
},
|
||||
},
|
||||
Spec: networking.IngressSpec{
|
||||
Rules: []networking.IngressRule{
|
||||
{
|
||||
Host: "foo.bar",
|
||||
IngressRuleValue: networking.IngressRuleValue{
|
||||
HTTP: &networking.HTTPIngressRuleValue{
|
||||
Paths: []networking.HTTPIngressPath{
|
||||
{
|
||||
Path: "/ok",
|
||||
PathType: &pathPrefix,
|
||||
Backend: networking.IngressBackend{
|
||||
Service: nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
Path: "/oksvc",
|
||||
PathType: &pathPrefix,
|
||||
Backend: networking.IngressBackend{
|
||||
Service: &networking.IngressServiceBackend{
|
||||
Name: "b-svc",
|
||||
Port: networking.ServiceBackendPort{
|
||||
Name: "b-svc-80",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"foo.bar",
|
||||
"/oksvc",
|
||||
&ingressInformation{
|
||||
Namespace: "something",
|
||||
Rule: "demo",
|
||||
Annotations: map[string]string{
|
||||
"ingress.annotation": "ok",
|
||||
},
|
||||
Service: "b-svc",
|
||||
ServicePort: "b-svc-80",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for title, testCase := range testcases {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue