1
0
Fork 0

Allow multiple listeners on same port in Gateway API provider

This commit is contained in:
burner-account 2022-06-23 11:58:09 +02:00 committed by GitHub
parent 804b0ff2f2
commit 55ba4356f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 99 additions and 15 deletions

View file

@ -3566,8 +3566,8 @@ func TestLoadMixedRoutes(t *testing.T) {
},
},
{
desc: "Empty caused by mixed routes multiple protocol using same port",
paths: []string{"services.yml", "mixed/with_multiple_protocol_using_same_port.yml"},
desc: "Empty caused by mixed routes with multiple listeners using same hostname, port and protocol",
paths: []string{"services.yml", "mixed/with_multiple_listeners_using_same_hostname_port_protocol.yml"},
entryPoints: map[string]Entrypoint{
"web": {Address: ":9080"},
"tcp": {Address: ":9000"},
@ -4989,7 +4989,7 @@ func Test_shouldAttach(t *testing.T) {
}
func Test_matchingHostnames(t *testing.T) {
tests := []struct {
testCases := []struct {
desc string
listener v1alpha2.Listener
hostnames []v1alpha2.Hostname
@ -5081,7 +5081,7 @@ func Test_matchingHostnames(t *testing.T) {
},
}
for _, test := range tests {
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -5093,7 +5093,7 @@ func Test_matchingHostnames(t *testing.T) {
}
func Test_getAllowedRoutes(t *testing.T) {
tests := []struct {
testCases := []struct {
desc string
listener v1alpha2.Listener
supportedRouteKinds []v1alpha2.RouteGroupKind
@ -5193,7 +5193,7 @@ func Test_getAllowedRoutes(t *testing.T) {
},
}
for _, test := range tests {
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
@ -5210,6 +5210,45 @@ func Test_getAllowedRoutes(t *testing.T) {
}
}
func Test_makeListenerKey(t *testing.T) {
testCases := []struct {
desc string
listener v1alpha2.Listener
expectedKey string
}{
{
desc: "empty",
expectedKey: "||0",
},
{
desc: "listener with port, protocol and hostname",
listener: v1alpha2.Listener{
Port: 443,
Protocol: v1alpha2.HTTPSProtocolType,
Hostname: hostnamePtr("www.example.com"),
},
expectedKey: "HTTPS|www.example.com|443",
},
{
desc: "listener with port, protocol and nil hostname",
listener: v1alpha2.Listener{
Port: 443,
Protocol: v1alpha2.HTTPSProtocolType,
},
expectedKey: "HTTPS||443",
},
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
assert.Equal(t, test.expectedKey, makeListenerKey(test.listener))
})
}
}
func hostnamePtr(hostname v1alpha2.Hostname) *v1alpha2.Hostname {
return &hostname
}