Skip to content

Commit

Permalink
Add tests for annotation override (gateway sources)
Browse files Browse the repository at this point in the history
  • Loading branch information
BadLiveware committed Mar 5, 2023
1 parent 93cb700 commit da02bf5
Showing 1 changed file with 122 additions and 0 deletions.
122 changes: 122 additions & 0 deletions source/gateway_httproute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,128 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
}},
endpoints: nil,
},
{
title: "AnnotationOverride",
config: Config{
GatewayNamespace: "gateway-namespace",
},
namespaces: namespaces("gateway-namespace", "route-namespace"),
gateways: []*v1beta1.Gateway{
{
ObjectMeta: metav1.ObjectMeta{
Name: "overriden-gateway",
Namespace: "gateway-namespace",
Annotations: map[string]string{
targetAnnotationKey: "4.3.2.1",
},
},
Spec: v1beta1.GatewaySpec{
Listeners: []v1beta1.Listener{{
Protocol: v1beta1.HTTPProtocolType,
AllowedRoutes: allowAllNamespaces,
}},
},
Status: gatewayStatus("1.2.3.4"),
},
},
routes: []*v1beta1.HTTPRoute{{
ObjectMeta: objectMeta("route-namespace", "test"),
Spec: v1beta1.HTTPRouteSpec{
Hostnames: hostnames("test.example.internal"),
},
Status: httpRouteStatus( // The route is attached to both gateways.
gatewayParentRef("gateway-namespace", "overriden-gateway"),
),
}},
endpoints: []*endpoint.Endpoint{
newTestEndpoint("test.example.internal", "A", "4.3.2.1"),
},
},
{
title: "AnnotationOverrideMultipleStatusAddresses",
config: Config{
GatewayNamespace: "gateway-namespace",
},
namespaces: namespaces("gateway-namespace", "route-namespace"),
gateways: []*v1beta1.Gateway{
{
ObjectMeta: metav1.ObjectMeta{
Name: "overriden-gateway",
Namespace: "gateway-namespace",
Annotations: map[string]string{
targetAnnotationKey: "4.3.2.1",
},
},
Spec: v1beta1.GatewaySpec{
Listeners: []v1beta1.Listener{{
Protocol: v1beta1.HTTPProtocolType,
AllowedRoutes: allowAllNamespaces,
}},
},
Status: gatewayStatus("1.2.3.4", "2.3.4.5"),
},
},
routes: []*v1beta1.HTTPRoute{{
ObjectMeta: objectMeta("route-namespace", "test"),
Spec: v1beta1.HTTPRouteSpec{
Hostnames: hostnames("test.example.internal"),
},
Status: httpRouteStatus( // The route is attached to both gateways.
gatewayParentRef("gateway-namespace", "overriden-gateway"),
),
}},
endpoints: []*endpoint.Endpoint{
newTestEndpoint("test.example.internal", "A", "4.3.2.1"),
},
},
{
title: "MutlipleGatewaysOneAnnotationOverride",
config: Config{
GatewayNamespace: "gateway-namespace",
},
namespaces: namespaces("gateway-namespace", "route-namespace"),
gateways: []*v1beta1.Gateway{
{
ObjectMeta: metav1.ObjectMeta{
Name: "overriden-gateway",
Namespace: "gateway-namespace",
Annotations: map[string]string{
targetAnnotationKey: "4.3.2.1",
},
},
Spec: v1beta1.GatewaySpec{
Listeners: []v1beta1.Listener{{
Protocol: v1beta1.HTTPProtocolType,
AllowedRoutes: allowAllNamespaces,
}},
},
Status: gatewayStatus("1.2.3.4"),
},
{
ObjectMeta: objectMeta("gateway-namespace", "test"),
Spec: v1beta1.GatewaySpec{
Listeners: []v1beta1.Listener{{
Protocol: v1beta1.HTTPProtocolType,
AllowedRoutes: allowAllNamespaces,
}},
},
Status: gatewayStatus("2.3.4.5"),
},
},
routes: []*v1beta1.HTTPRoute{{
ObjectMeta: objectMeta("route-namespace", "test"),
Spec: v1beta1.HTTPRouteSpec{
Hostnames: hostnames("test.example.internal"),
},
Status: httpRouteStatus( // The route is attached to both gateways.
gatewayParentRef("gateway-namespace", "overriden-gateway"),
gatewayParentRef("gateway-namespace", "test"),
),
}},
endpoints: []*endpoint.Endpoint{
newTestEndpoint("test.example.internal", "A", "4.3.2.1", "2.3.4.5"),
},
},
}
for _, tt := range tests {
tt := tt
Expand Down

0 comments on commit da02bf5

Please sign in to comment.