mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-05 09:06:58 +02:00
update all route tests to have a valid spec.parentRef entry
This commit is contained in:
parent
5a1aef4d94
commit
94278ae67c
@ -74,6 +74,11 @@ func TestGatewayGRPCRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1.GRPCRouteSpec{
|
Spec: v1.GRPCRouteSpec{
|
||||||
Hostnames: []v1.Hostname{"api-hostnames.foobar.internal"},
|
Hostnames: []v1.Hostname{"api-hostnames.foobar.internal"},
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "internal"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: v1.GRPCRouteStatus{
|
Status: v1.GRPCRouteStatus{
|
||||||
RouteStatus: gwRouteStatus(gwParentRef("default", "internal")),
|
RouteStatus: gwRouteStatus(gwParentRef("default", "internal")),
|
||||||
|
@ -174,6 +174,12 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("route-namespace", "test"),
|
ObjectMeta: objectMeta("route-namespace", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.example.internal"),
|
Hostnames: hostnames("test.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("gateway-namespace", "gateway-name"),
|
||||||
|
gwParentRef("gateway-namespace", "not-gateway-name"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus( // The route is attached to both gateways.
|
Status: httpRouteStatus( // The route is attached to both gateways.
|
||||||
gwParentRef("gateway-namespace", "gateway-name"),
|
gwParentRef("gateway-namespace", "gateway-name"),
|
||||||
@ -216,6 +222,12 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("route-namespace", "test"),
|
ObjectMeta: objectMeta("route-namespace", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.example.internal"),
|
Hostnames: hostnames("test.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("gateway-namespace", "test"),
|
||||||
|
gwParentRef("not-gateway-namespace", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus( // The route is attached to both gateways.
|
Status: httpRouteStatus( // The route is attached to both gateways.
|
||||||
gwParentRef("gateway-namespace", "test"),
|
gwParentRef("gateway-namespace", "test"),
|
||||||
@ -247,6 +259,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("route-namespace", "test"),
|
ObjectMeta: objectMeta("route-namespace", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("route-namespace.example.internal"),
|
Hostnames: hostnames("route-namespace.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("gateway-namespace", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("gateway-namespace", "test")),
|
Status: httpRouteStatus(gwParentRef("gateway-namespace", "test")),
|
||||||
},
|
},
|
||||||
@ -296,6 +313,12 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.example.internal"),
|
Hostnames: hostnames("test.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "labels-match"),
|
||||||
|
gwParentRef("default", "labels-dont-match"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus( // The route is attached to both gateways.
|
Status: httpRouteStatus( // The route is attached to both gateways.
|
||||||
gwParentRef("default", "labels-match"),
|
gwParentRef("default", "labels-match"),
|
||||||
@ -328,6 +351,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("labels-match.example.internal"),
|
Hostnames: hostnames("labels-match.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
@ -339,6 +367,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("labels-dont-match.example.internal"),
|
Hostnames: hostnames("labels-dont-match.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
@ -369,6 +402,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("annotations-match.example.internal"),
|
Hostnames: hostnames("annotations-match.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
@ -380,6 +418,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("annotations-dont-match.example.internal"),
|
Hostnames: hostnames("annotations-dont-match.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
@ -408,6 +451,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: hostnames("api.example.internal"),
|
Hostnames: hostnames("api.example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
@ -438,6 +486,12 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.example.internal"),
|
Hostnames: hostnames("test.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "one"),
|
||||||
|
gwParentRef("default", "two"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
gwParentRef("default", "one"),
|
gwParentRef("default", "one"),
|
||||||
@ -474,6 +528,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("*.example.internal"),
|
Hostnames: hostnames("*.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "one"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
gwParentRef("default", "one"),
|
gwParentRef("default", "one"),
|
||||||
@ -510,6 +569,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("*.example.internal"),
|
Hostnames: hostnames("*.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test", withSectionName("foo")),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
gwParentRef("default", "test", withSectionName("foo")),
|
gwParentRef("default", "test", withSectionName("foo")),
|
||||||
@ -554,6 +618,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("*.example.internal"),
|
Hostnames: hostnames("*.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test", withPortNumber(80)),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
gwParentRef("default", "test", withPortNumber(80)),
|
gwParentRef("default", "test", withPortNumber(80)),
|
||||||
@ -581,6 +650,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
routes: []*v1beta1.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "no-hostname"),
|
ObjectMeta: objectMeta("default", "no-hostname"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: []v1.Hostname{
|
Hostnames: []v1.Hostname{
|
||||||
"foo.example.internal",
|
"foo.example.internal",
|
||||||
},
|
},
|
||||||
@ -608,6 +682,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
routes: []*v1beta1.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "no-hostname"),
|
ObjectMeta: objectMeta("default", "no-hostname"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: []v1.Hostname{
|
Hostnames: []v1.Hostname{
|
||||||
"*.example.internal",
|
"*.example.internal",
|
||||||
},
|
},
|
||||||
@ -635,6 +714,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
routes: []*v1beta1.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "no-hostname"),
|
ObjectMeta: objectMeta("default", "no-hostname"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: []v1.Hostname{
|
Hostnames: []v1.Hostname{
|
||||||
"*.example.internal",
|
"*.example.internal",
|
||||||
},
|
},
|
||||||
@ -662,6 +746,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
routes: []*v1beta1.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "no-hostname"),
|
ObjectMeta: objectMeta("default", "no-hostname"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: nil,
|
Hostnames: nil,
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
@ -679,6 +768,9 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("example.internal"),
|
Hostnames: hostnames("example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(),
|
Status: httpRouteStatus(),
|
||||||
}},
|
}},
|
||||||
@ -698,6 +790,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
routes: []*v1beta1.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "no-hostname"),
|
ObjectMeta: objectMeta("default", "no-hostname"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: nil,
|
Hostnames: nil,
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
@ -725,6 +822,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: nil,
|
Hostnames: nil,
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
@ -738,6 +840,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: hostnames("with-hostname.internal"),
|
Hostnames: hostnames("with-hostname.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
@ -772,6 +879,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("with-hostname.internal"),
|
Hostnames: hostnames("with-hostname.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
}},
|
}},
|
||||||
@ -797,12 +909,22 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("default", "fqdn-with-hostnames"),
|
ObjectMeta: objectMeta("default", "fqdn-with-hostnames"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("fqdn-with-hostnames.internal"),
|
Hostnames: hostnames("fqdn-with-hostnames.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: objectMeta("default", "fqdn-without-hostnames"),
|
ObjectMeta: objectMeta("default", "fqdn-without-hostnames"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: nil,
|
Hostnames: nil,
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
@ -832,6 +954,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
routes: []*v1beta1.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "fqdn-with-hostnames"),
|
ObjectMeta: objectMeta("default", "fqdn-with-hostnames"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: hostnames("fqdn-with-hostnames.internal"),
|
Hostnames: hostnames("fqdn-with-hostnames.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
@ -861,6 +988,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("valid-ttl.internal"),
|
Hostnames: hostnames("valid-ttl.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
@ -872,6 +1004,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("invalid-ttl.internal"),
|
Hostnames: hostnames("invalid-ttl.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
@ -902,6 +1039,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: hostnames("provider-annotations.com"),
|
Hostnames: hostnames("provider-annotations.com"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
@ -941,6 +1083,12 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
routes: []*v1beta1.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "one"),
|
||||||
|
gwParentRef("default", "two"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: hostnames("test.one.internal", "test.two.internal"),
|
Hostnames: hostnames("test.one.internal", "test.two.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
@ -976,6 +1124,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("same-namespace", "test"),
|
ObjectMeta: objectMeta("same-namespace", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("same-namespace.example.internal"),
|
Hostnames: hostnames("same-namespace.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("same-namespace", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("same-namespace", "test")),
|
Status: httpRouteStatus(gwParentRef("same-namespace", "test")),
|
||||||
},
|
},
|
||||||
@ -983,6 +1136,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("other-namespace", "test"),
|
ObjectMeta: objectMeta("other-namespace", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("other-namespace.example.internal"),
|
Hostnames: hostnames("other-namespace.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("same-namespace", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("same-namespace", "test")),
|
Status: httpRouteStatus(gwParentRef("same-namespace", "test")),
|
||||||
},
|
},
|
||||||
@ -1035,6 +1193,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("foo", "test"),
|
ObjectMeta: objectMeta("foo", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("foo.example.internal"),
|
Hostnames: hostnames("foo.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
@ -1042,6 +1205,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("bar", "test"),
|
ObjectMeta: objectMeta("bar", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("bar.example.internal"),
|
Hostnames: hostnames("bar.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
},
|
},
|
||||||
@ -1075,6 +1243,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
routes: []*v1beta1.HTTPRoute{{
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
ObjectMeta: objectMeta("default", "test"),
|
ObjectMeta: objectMeta("default", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Hostnames: hostnames("example.internal"),
|
Hostnames: hostnames("example.internal"),
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(gwParentRef("default", "test")),
|
Status: httpRouteStatus(gwParentRef("default", "test")),
|
||||||
@ -1109,6 +1282,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("route-namespace", "test"),
|
ObjectMeta: objectMeta("route-namespace", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.example.internal"),
|
Hostnames: hostnames("test.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("gateway-namespace", "overriden-gateway"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus( // The route is attached to both gateways.
|
Status: httpRouteStatus( // The route is attached to both gateways.
|
||||||
gwParentRef("gateway-namespace", "overriden-gateway"),
|
gwParentRef("gateway-namespace", "overriden-gateway"),
|
||||||
@ -1156,8 +1334,14 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("route-namespace", "test"),
|
ObjectMeta: objectMeta("route-namespace", "test"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.example.internal"),
|
Hostnames: hostnames("test.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("gateway-namespace", "overriden-gateway"),
|
||||||
|
gwParentRef("gateway-namespace", "test"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus( // The route is attached to both gateways.
|
Status: httpRouteStatus(
|
||||||
gwParentRef("gateway-namespace", "overriden-gateway"),
|
gwParentRef("gateway-namespace", "overriden-gateway"),
|
||||||
gwParentRef("gateway-namespace", "test"),
|
gwParentRef("gateway-namespace", "test"),
|
||||||
),
|
),
|
||||||
@ -1191,6 +1375,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("default", "one"),
|
ObjectMeta: objectMeta("default", "one"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.one.internal"),
|
Hostnames: hostnames("test.one.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "one"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
gwParentRef("default", "one"),
|
gwParentRef("default", "one"),
|
||||||
@ -1200,6 +1389,11 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
ObjectMeta: objectMeta("default", "two"),
|
ObjectMeta: objectMeta("default", "two"),
|
||||||
Spec: v1.HTTPRouteSpec{
|
Spec: v1.HTTPRouteSpec{
|
||||||
Hostnames: hostnames("test.two.internal"),
|
Hostnames: hostnames("test.two.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "two"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: httpRouteStatus(
|
Status: httpRouteStatus(
|
||||||
gwParentRef("default", "two"),
|
gwParentRef("default", "two"),
|
||||||
@ -1215,6 +1409,71 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
|
|||||||
"level=debug msg=\"Endpoints generated from HTTPRoute default/two: [test.two.internal 0 IN A 2.3.4.5 []]\"",
|
"level=debug msg=\"Endpoints generated from HTTPRoute default/two: [test.two.internal 0 IN A 2.3.4.5 []]\"",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "NoParentRefs",
|
||||||
|
config: Config{
|
||||||
|
GatewayNamespace: "gateway-namespace",
|
||||||
|
},
|
||||||
|
namespaces: namespaces("gateway-namespace", "route-namespace"),
|
||||||
|
gateways: []*v1beta1.Gateway{
|
||||||
|
{
|
||||||
|
ObjectMeta: objectMeta("gateway-namespace", "test"),
|
||||||
|
Spec: v1.GatewaySpec{
|
||||||
|
Listeners: []v1.Listener{{
|
||||||
|
Protocol: v1.HTTPProtocolType,
|
||||||
|
AllowedRoutes: allowAllNamespaces,
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
|
ObjectMeta: objectMeta("route-namespace", "test"),
|
||||||
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
Hostnames: hostnames("test.example.internal"),
|
||||||
|
},
|
||||||
|
Status: httpRouteStatus(gwParentRef("gateway-namespace", "test")),
|
||||||
|
}},
|
||||||
|
endpoints: []*endpoint.Endpoint{},
|
||||||
|
logExpectations: []string{
|
||||||
|
"level=debug msg=\"No parent references found for HTTPRoute route-namespace/test\"",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "ParentRefsMismatch",
|
||||||
|
config: Config{
|
||||||
|
GatewayNamespace: "gateway-namespace",
|
||||||
|
},
|
||||||
|
namespaces: namespaces("gateway-namespace", "route-namespace"),
|
||||||
|
gateways: []*v1beta1.Gateway{
|
||||||
|
{
|
||||||
|
ObjectMeta: objectMeta("gateway-namespace", "test"),
|
||||||
|
Spec: v1.GatewaySpec{
|
||||||
|
Listeners: []v1.Listener{{
|
||||||
|
Protocol: v1.HTTPProtocolType,
|
||||||
|
AllowedRoutes: allowAllNamespaces,
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
Status: gatewayStatus("1.2.3.4"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
routes: []*v1beta1.HTTPRoute{{
|
||||||
|
ObjectMeta: objectMeta("route-namespace", "test"),
|
||||||
|
Spec: v1.HTTPRouteSpec{
|
||||||
|
Hostnames: hostnames("test.example.internal"),
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("gateway-namespace", "default-gateway"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Status: httpRouteStatus(gwParentRef("gateway-namespace", "other-gateway")),
|
||||||
|
}},
|
||||||
|
endpoints: []*endpoint.Endpoint{},
|
||||||
|
logExpectations: []string{
|
||||||
|
"level=debug msg=\"Parent reference gateway-namespace/other-gateway not found in routeParentRefs for HTTPRoute route-namespace/test\"",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
tt := tt
|
||||||
|
@ -73,7 +73,13 @@ func TestGatewayTCPRouteSourceEndpoints(t *testing.T) {
|
|||||||
hostnameAnnotationKey: "api-annotation.foobar.internal",
|
hostnameAnnotationKey: "api-annotation.foobar.internal",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.TCPRouteSpec{},
|
Spec: v1alpha2.TCPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "internal"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Status: v1alpha2.TCPRouteStatus{
|
Status: v1alpha2.TCPRouteStatus{
|
||||||
RouteStatus: gwRouteStatus(gwParentRef("default", "internal")),
|
RouteStatus: gwRouteStatus(gwParentRef("default", "internal")),
|
||||||
},
|
},
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
v1 "sigs.k8s.io/gateway-api/apis/v1"
|
v1 "sigs.k8s.io/gateway-api/apis/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -246,75 +245,3 @@ func TestIsDNS1123Domain(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGwRouteIsAccepted(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
desc string
|
|
||||||
conditions []metav1.Condition
|
|
||||||
currentGeneration int64
|
|
||||||
want bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
desc: "accepted condition with matching generation",
|
|
||||||
conditions: []metav1.Condition{
|
|
||||||
{
|
|
||||||
Type: string(v1.RouteConditionAccepted),
|
|
||||||
Status: metav1.ConditionTrue,
|
|
||||||
ObservedGeneration: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
currentGeneration: 1,
|
|
||||||
want: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "accepted condition with different generation",
|
|
||||||
conditions: []metav1.Condition{
|
|
||||||
{
|
|
||||||
Type: string(v1.RouteConditionAccepted),
|
|
||||||
Status: metav1.ConditionTrue,
|
|
||||||
ObservedGeneration: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
currentGeneration: 2,
|
|
||||||
want: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "accepted condition with false status",
|
|
||||||
conditions: []metav1.Condition{
|
|
||||||
{
|
|
||||||
Type: string(v1.RouteConditionAccepted),
|
|
||||||
Status: metav1.ConditionFalse,
|
|
||||||
ObservedGeneration: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
currentGeneration: 1,
|
|
||||||
want: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "no accepted condition",
|
|
||||||
conditions: []metav1.Condition{
|
|
||||||
{
|
|
||||||
Type: "OtherCondition",
|
|
||||||
Status: metav1.ConditionTrue,
|
|
||||||
ObservedGeneration: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
currentGeneration: 1,
|
|
||||||
want: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
desc: "empty conditions",
|
|
||||||
conditions: []metav1.Condition{},
|
|
||||||
currentGeneration: 1,
|
|
||||||
want: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.desc, func(t *testing.T) {
|
|
||||||
if got := gwRouteIsAccepted(tt.conditions, tt.currentGeneration); got != tt.want {
|
|
||||||
t.Errorf("gwRouteIsAccepted() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -75,6 +75,11 @@ func TestGatewayTLSRouteSourceEndpoints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Spec: v1alpha2.TLSRouteSpec{
|
Spec: v1alpha2.TLSRouteSpec{
|
||||||
Hostnames: []v1.Hostname{"api-hostnames.foobar.internal"},
|
Hostnames: []v1.Hostname{"api-hostnames.foobar.internal"},
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "internal"),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Status: v1alpha2.TLSRouteStatus{
|
Status: v1alpha2.TLSRouteStatus{
|
||||||
RouteStatus: gwRouteStatus(gwParentRef("default", "internal")),
|
RouteStatus: gwRouteStatus(gwParentRef("default", "internal")),
|
||||||
|
@ -73,7 +73,13 @@ func TestGatewayUDPRouteSourceEndpoints(t *testing.T) {
|
|||||||
hostnameAnnotationKey: "api-annotation.foobar.internal",
|
hostnameAnnotationKey: "api-annotation.foobar.internal",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: v1alpha2.UDPRouteSpec{},
|
Spec: v1alpha2.UDPRouteSpec{
|
||||||
|
CommonRouteSpec: v1.CommonRouteSpec{
|
||||||
|
ParentRefs: []v1.ParentReference{
|
||||||
|
gwParentRef("default", "internal"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Status: v1alpha2.UDPRouteStatus{
|
Status: v1alpha2.UDPRouteStatus{
|
||||||
RouteStatus: gwRouteStatus(gwParentRef("default", "internal")),
|
RouteStatus: gwRouteStatus(gwParentRef("default", "internal")),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user