Skip to content

Commit

Permalink
test: Add test to reproduce behavior
Browse files Browse the repository at this point in the history
(cherry picked from commit ff44b31)
  • Loading branch information
jonstacks authored and Alice-Lilith committed Jan 13, 2025
1 parent bd9228d commit 0ac6fb7
Showing 1 changed file with 116 additions and 0 deletions.
116 changes: 116 additions & 0 deletions pkg/managerdriver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,122 @@ var _ = Describe("Driver", func() {
Expect(err).To(Equal(errSyncDone))
})
})

Describe("When no ingresses are opted in to use endpoints", func() {
It("Should create edges and not endpoints", func() {
ic1 := testutils.NewTestIngressClass("test-ingress-class", true, true)

i1 := testutils.NewTestIngressV1WithClass("ingress-1", "test-namespace", ic1.Name)
i1.Spec.Rules = []netv1.IngressRule{
{
Host: "a.customdomain.com",
IngressRuleValue: netv1.IngressRuleValue{
HTTP: &netv1.HTTPIngressRuleValue{
Paths: []netv1.HTTPIngressPath{
{
Path: "/",
Backend: netv1.IngressBackend{
Service: &netv1.IngressServiceBackend{
Name: "test-service",
Port: netv1.ServiceBackendPort{
Number: 80,
},
},
},
},
{
Path: "/api",
Backend: netv1.IngressBackend{
Service: &netv1.IngressServiceBackend{
Name: "api-service",
Port: netv1.ServiceBackendPort{
Number: 80,
},
},
},
},
},
},
},
},
{
Host: "b.customdomain.com",
IngressRuleValue: netv1.IngressRuleValue{
HTTP: &netv1.HTTPIngressRuleValue{
Paths: []netv1.HTTPIngressPath{
{
Path: "/b/",
Backend: netv1.IngressBackend{
Service: &netv1.IngressServiceBackend{
Name: "b-service",
Port: netv1.ServiceBackendPort{
Number: 80,
},
},
},
},
},
},
},
},
}
i2 := testutils.NewTestIngressV1WithClass("ingress-2", "other-namespace", ic1.Name)
i2.Spec.Rules = []netv1.IngressRule{
{
Host: "c.customdomain.com",
IngressRuleValue: netv1.IngressRuleValue{
HTTP: &netv1.HTTPIngressRuleValue{
Paths: []netv1.HTTPIngressPath{
{
Path: "/",
Backend: netv1.IngressBackend{
Service: &netv1.IngressServiceBackend{
Name: "test-service",
Port: netv1.ServiceBackendPort{
Number: 80,
},
},
},
},
},
},
},
},
{
Host: "d.customdomain.com",
IngressRuleValue: netv1.IngressRuleValue{
HTTP: &netv1.HTTPIngressRuleValue{
Paths: []netv1.HTTPIngressPath{
{
Path: "/",
Backend: netv1.IngressBackend{
Service: &netv1.IngressServiceBackend{
Name: "test-service",
Port: netv1.ServiceBackendPort{
Number: 80,
},
},
},
},
},
},
},
},
}

obs := []runtime.Object{&ic1, &i1, &i2}
c := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(obs...).Build()
Expect(driver.Seed(context.Background(), c)).To(BeNil())

domainSet := driver.calculateDomainSet()
Expect(domainSet.edgeIngressDomains).To(HaveLen(4))
Expect(domainSet.edgeIngressDomains).To(HaveKey("a.customdomain.com"))
Expect(domainSet.edgeIngressDomains).To(HaveKey("b.customdomain.com"))
Expect(domainSet.edgeIngressDomains).To(HaveKey("c.customdomain.com"))
Expect(domainSet.edgeIngressDomains).To(HaveKey("d.customdomain.com"))
Expect(domainSet.endpointIngressDomains).To(HaveLen(0))
})
})
})

func TestExtractPolicy(t *testing.T) {
Expand Down

0 comments on commit 0ac6fb7

Please sign in to comment.