2019-01-29 16:54:05 +00:00
|
|
|
package marathon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"math"
|
|
|
|
"testing"
|
2022-11-16 10:38:07 +00:00
|
|
|
"time"
|
2019-01-29 16:54:05 +00:00
|
|
|
|
|
|
|
"github.com/gambol99/go-marathon"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
2022-11-16 10:38:07 +00:00
|
|
|
ptypes "github.com/traefik/paerser/types"
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/config/dynamic"
|
2019-01-29 16:54:05 +00:00
|
|
|
)
|
|
|
|
|
2019-09-30 16:12:04 +00:00
|
|
|
func Int(v int) *int { return &v }
|
|
|
|
func Bool(v bool) *bool { return &v }
|
2019-09-13 15:46:04 +00:00
|
|
|
|
2019-01-29 16:54:05 +00:00
|
|
|
func TestGetConfigurationAPIErrors(t *testing.T) {
|
|
|
|
fakeClient := newFakeClient(true, marathon.Applications{})
|
|
|
|
|
|
|
|
p := &Provider{
|
|
|
|
marathonClient: fakeClient,
|
|
|
|
}
|
|
|
|
|
|
|
|
actualConfig := p.getConfigurations(context.Background())
|
|
|
|
fakeClient.AssertExpectations(t)
|
|
|
|
|
|
|
|
if actualConfig != nil {
|
|
|
|
t.Errorf("configuration should have been nil, got %v", actualConfig)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBuildConfiguration(t *testing.T) {
|
|
|
|
testCases := []struct {
|
2019-06-21 07:24:04 +00:00
|
|
|
desc string
|
|
|
|
applications *marathon.Applications
|
|
|
|
constraints string
|
|
|
|
defaultRule string
|
2019-07-10 07:26:04 +00:00
|
|
|
expected *dynamic.Configuration
|
2019-01-29 16:54:05 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "simple application",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80))),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-08-26 08:30:05 +00:00
|
|
|
"app": {LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
}},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "filtered task",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80), taskState(taskStateStaging))),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "multiple ports",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-08-26 08:30:05 +00:00
|
|
|
"app": {LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
}},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with basic auth",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.middlewares.Middleware1.basicauth.users", "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/,test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
|
|
|
|
withLabel("traefik.http.routers.app.middlewares", "Middleware1"),
|
2019-01-29 16:54:05 +00:00
|
|
|
withTasks(localhostTask(taskPorts(80))),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
Middlewares: []string{"Middleware1"},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Middleware1": {
|
2019-07-10 07:26:04 +00:00
|
|
|
BasicAuth: &dynamic.BasicAuth{
|
2019-04-15 16:22:07 +00:00
|
|
|
Users: []string{
|
|
|
|
"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
|
|
|
|
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
2019-08-26 08:30:05 +00:00
|
|
|
"app": {LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
}},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
{
|
2022-10-26 15:16:05 +00:00
|
|
|
desc: "TCP with IP allowlist",
|
2021-06-11 13:30:05 +00:00
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
|
|
|
|
withLabel("traefik.tcp.routers.Test.rule", "HostSNI(`foo.bar`)"),
|
2022-10-26 15:16:05 +00:00
|
|
|
withLabel("traefik.tcp.middlewares.Middleware1.ipallowlist.sourcerange", "foobar, fiibar"),
|
2021-06-11 13:30:05 +00:00
|
|
|
withLabel("traefik.tcp.routers.Test.middlewares", "Middleware1"),
|
|
|
|
withTasks(localhostTask(taskPorts(80))),
|
|
|
|
)),
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"Test": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
|
|
|
Middlewares: []string{"Middleware1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{
|
|
|
|
"Middleware1": {
|
2022-10-26 15:16:05 +00:00
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-06-11 13:30:05 +00:00
|
|
|
SourceRange: []string{"foobar", "fiibar"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"app": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "localhost:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
{
|
|
|
|
desc: "2 applications in the same service",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/foo-v000"),
|
|
|
|
withTasks(localhostTask(taskPorts(8080))),
|
|
|
|
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.services.Service1.LoadBalancer.server.port", "index:0"),
|
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`app.marathon.localhost`)"),
|
2019-01-29 16:54:05 +00:00
|
|
|
),
|
|
|
|
application(
|
|
|
|
appID("/foo-v001"),
|
|
|
|
withTasks(localhostTask(taskPorts(8081))),
|
|
|
|
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.services.Service1.LoadBalancer.server.port", "index:0"),
|
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`app.marathon.localhost`)"),
|
2019-01-29 16:54:05 +00:00
|
|
|
),
|
|
|
|
),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Router1": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-08-26 08:30:05 +00:00
|
|
|
"Service1": {LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:8080",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:8081",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
}},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "2 applications with 2 tasks in the same service",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/foo-v000"),
|
|
|
|
withTasks(localhostTask(taskPorts(8080))),
|
|
|
|
withTasks(localhostTask(taskPorts(8081))),
|
|
|
|
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.services.Service1.LoadBalancer.server.port", "index:0"),
|
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`app.marathon.localhost`)"),
|
2019-01-29 16:54:05 +00:00
|
|
|
),
|
|
|
|
application(
|
|
|
|
appID("/foo-v001"),
|
|
|
|
withTasks(localhostTask(taskPorts(8082))),
|
|
|
|
withTasks(localhostTask(taskPorts(8083))),
|
|
|
|
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.services.Service1.LoadBalancer.server.port", "index:0"),
|
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`app.marathon.localhost`)"),
|
2019-01-29 16:54:05 +00:00
|
|
|
),
|
|
|
|
),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Router1": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-08-26 08:30:05 +00:00
|
|
|
"Service1": {LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:8080",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:8081",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:8082",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:8083",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
}},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "2 applications",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/foo"),
|
|
|
|
withTasks(localhostTask(taskPorts(8080))),
|
|
|
|
),
|
|
|
|
application(
|
|
|
|
appID("/bar"),
|
|
|
|
withTasks(localhostTask(taskPorts(8081))),
|
|
|
|
),
|
|
|
|
),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"foo": {
|
|
|
|
Service: "foo",
|
|
|
|
Rule: "Host(`foo.marathon.localhost`)",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
"bar": {
|
|
|
|
Service: "bar",
|
|
|
|
Rule: "Host(`bar.marathon.localhost`)",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-08-26 08:30:05 +00:00
|
|
|
"foo": {LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:8080",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
}},
|
2019-08-26 08:30:05 +00:00
|
|
|
"bar": {LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:8081",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
}},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two tasks no labels",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80)), localhostTask(taskPorts(81))),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:81",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "simple application with label on service",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80))),
|
2019-06-05 20:18:06 +00:00
|
|
|
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "true"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-08-26 08:30:05 +00:00
|
|
|
"Service1": {LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
}},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with labels",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-06-05 20:18:06 +00:00
|
|
|
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "true"),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
|
|
|
|
withLabel("traefik.http.routers.Router1.service", "Service1"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Router1": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with rule label",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Router1": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with rule label and one service",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
|
2019-06-05 20:18:06 +00:00
|
|
|
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "true"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Router1": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with rule label and two services",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
|
2019-06-05 20:18:06 +00:00
|
|
|
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "true"),
|
|
|
|
withLabel("traefik.http.services.Service2.loadbalancer.passhostheader", "true"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
"Service2": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
desc: "two apps with same service name and different passhostheader",
|
2019-01-29 16:54:05 +00:00
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-06-05 20:18:06 +00:00
|
|
|
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "false"),
|
2019-01-29 16:54:05 +00:00
|
|
|
),
|
|
|
|
application(
|
|
|
|
appID("/app2"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-06-05 20:18:06 +00:00
|
|
|
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "true"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
"app2": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`app2.marathon.localhost`)",
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two apps with two identical middleware",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-08-26 10:20:06 +00:00
|
|
|
withLabel("traefik.http.middlewares.Middleware1.inflightreq.amount", "42"),
|
2019-01-29 16:54:05 +00:00
|
|
|
),
|
|
|
|
application(
|
|
|
|
appID("/app2"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-08-26 10:20:06 +00:00
|
|
|
withLabel("traefik.http.middlewares.Middleware1.inflightreq.amount", "42"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
"app2": {
|
|
|
|
Service: "app2",
|
|
|
|
Rule: "Host(`app2.marathon.localhost`)",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Middleware1": {
|
2019-08-26 10:20:06 +00:00
|
|
|
InFlightReq: &dynamic.InFlightReq{
|
|
|
|
Amount: 42,
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"app2": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two apps with two different middlewares",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-08-26 10:20:06 +00:00
|
|
|
withLabel("traefik.http.middlewares.Middleware1.inflightreq.amount", "42"),
|
2019-01-29 16:54:05 +00:00
|
|
|
),
|
|
|
|
application(
|
|
|
|
appID("/app2"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-08-26 10:20:06 +00:00
|
|
|
withLabel("traefik.http.middlewares.Middleware1.inflightreq.amount", "41"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
"app2": {
|
|
|
|
Service: "app2",
|
|
|
|
Rule: "Host(`app2.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
"app2": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two apps with two different routers with same name",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
|
2019-01-29 16:54:05 +00:00
|
|
|
),
|
|
|
|
application(
|
|
|
|
appID("/app2"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`bar.com`)"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
"app2": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two apps with two identical routers with same name",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
|
2019-06-05 20:18:06 +00:00
|
|
|
withLabel("traefik.http.services.Service1.LoadBalancer.passhostheader", "true"),
|
2019-01-29 16:54:05 +00:00
|
|
|
),
|
|
|
|
application(
|
|
|
|
appID("/app2"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
|
2019-06-05 20:18:06 +00:00
|
|
|
withLabel("traefik.http.services.Service1.LoadBalancer.passhostheader", "true"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Router1": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two apps with two identical routers with same name",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
|
2019-01-29 16:54:05 +00:00
|
|
|
),
|
|
|
|
application(
|
|
|
|
appID("/app2"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
"app2": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with wrong label",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.wrong.label", "tchouk"),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with label port",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.services.Service1.LoadBalancer.server.scheme", "h2c"),
|
|
|
|
withLabel("traefik.http.services.Service1.LoadBalancer.server.port", "90"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "h2c://localhost:90",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with label port on two services",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.services.Service1.LoadBalancer.server.port", ""),
|
|
|
|
withLabel("traefik.http.services.Service2.LoadBalancer.server.port", "8080"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
"Service2": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:8080",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app without port",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask()),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app without port with middleware",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask()),
|
2019-03-14 08:30:04 +00:00
|
|
|
withLabel("traefik.http.middlewares.Middleware1.basicauth.users", "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/,test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
|
2019-01-29 16:54:05 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with traefik.enable=false",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask()),
|
|
|
|
withLabel("traefik.enable", "false"),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with traefik.enable=false",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask()),
|
|
|
|
withLabel("traefik.enable", "false"),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with non matching constraint",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.tags", "foo"),
|
|
|
|
)),
|
2019-06-21 07:24:04 +00:00
|
|
|
constraints: `Label("traefik.tags", "bar")`,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with non matching marathon constraint",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
constraint("rack_id:CLUSTER:rack-1"),
|
|
|
|
)),
|
2019-06-21 07:24:04 +00:00
|
|
|
constraints: `MarathonConstraint("rack_id:CLUSTER:rack-2")`,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with matching marathon constraint",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
constraint("rack_id:CLUSTER:rack-1"),
|
|
|
|
)),
|
2019-06-21 07:24:04 +00:00
|
|
|
constraints: `MarathonConstraint("rack_id:CLUSTER:rack-1")`,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with matching constraint",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.tags", "bar"),
|
|
|
|
)),
|
2019-06-21 07:24:04 +00:00
|
|
|
constraints: `Label("traefik.tags", "bar")`,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with group as subdomain rule",
|
2019-01-30 15:24:07 +00:00
|
|
|
defaultRule: `Host("{{ .Name | trimPrefix "/" | splitList "/" | strsToItfs | reverse | join "." }}.marathon.localhost")`,
|
2019-01-29 16:54:05 +00:00
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/a/b/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"a_b_app": {
|
|
|
|
Service: "a_b_app",
|
|
|
|
Rule: `Host("app.b.a.marathon.localhost")`,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"a_b_app": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with tcp labels",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.tcp.routers.foo.rule", "HostSNI(`foo.bar`)"),
|
|
|
|
withLabel("traefik.tcp.routers.foo.tls", "true"),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-04-15 16:22:07 +00:00
|
|
|
"foo": {
|
|
|
|
Service: "app",
|
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
|
|
|
Address: "localhost:80",
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
{
|
|
|
|
desc: "one app with udp labels",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.udp.routers.foo.entrypoints", "mydns"),
|
|
|
|
)),
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"foo": {
|
|
|
|
Service: "app",
|
|
|
|
EntryPoints: []string{"mydns"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"app": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "localhost:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
|
|
|
desc: "one app with tcp labels without rule",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.tcp.routers.foo.tls", "true"),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2021-06-11 13:30:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
|
|
|
Address: "localhost:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with tcp labels with port",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.tcp.routers.foo.rule", "HostSNI(`foo.bar`)"),
|
|
|
|
withLabel("traefik.tcp.routers.foo.tls", "true"),
|
|
|
|
withLabel("traefik.tcp.services.foo.loadbalancer.server.port", "8080"),
|
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-04-15 16:22:07 +00:00
|
|
|
"foo": {
|
|
|
|
Service: "foo",
|
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-04-15 16:22:07 +00:00
|
|
|
"foo": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
|
|
|
Address: "localhost:8080",
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 15:46:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-09-13 15:46:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-09-13 15:46:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-09-13 15:46:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
{
|
|
|
|
desc: "one app with udp labels with port",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.udp.routers.foo.entrypoints", "mydns"),
|
|
|
|
withLabel("traefik.udp.services.foo.loadbalancer.server.port", "8080"),
|
|
|
|
)),
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"foo": {
|
|
|
|
Service: "foo",
|
|
|
|
EntryPoints: []string{"mydns"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"foo": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "localhost:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 15:46:04 +00:00
|
|
|
{
|
2022-12-09 08:58:05 +00:00
|
|
|
// TODO: replace or delete?
|
2019-09-13 15:46:04 +00:00
|
|
|
desc: "one app with tcp labels with port, with termination delay",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.tcp.routers.foo.rule", "HostSNI(`foo.bar`)"),
|
|
|
|
withLabel("traefik.tcp.routers.foo.tls", "true"),
|
|
|
|
withLabel("traefik.tcp.services.foo.loadbalancer.server.port", "8080"),
|
|
|
|
)),
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"foo": {
|
|
|
|
Service: "foo",
|
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-09-13 15:46:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"foo": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-09-13 15:46:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "localhost:8080",
|
|
|
|
},
|
|
|
|
},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with tcp labels with port and http service",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.tcp.routers.foo.rule", "HostSNI(`foo.bar`)"),
|
|
|
|
withLabel("traefik.tcp.routers.foo.tls", "true"),
|
|
|
|
withLabel("traefik.tcp.services.foo.loadbalancer.server.port", "8080"),
|
2019-06-05 20:18:06 +00:00
|
|
|
withLabel("traefik.http.services.bar.loadbalancer.passhostheader", "true"),
|
2019-04-15 16:22:07 +00:00
|
|
|
)),
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-04-15 16:22:07 +00:00
|
|
|
"foo": {
|
|
|
|
Service: "foo",
|
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-04-15 16:22:07 +00:00
|
|
|
"foo": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
|
|
|
Address: "localhost:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-04-15 16:22:07 +00:00
|
|
|
"app": {
|
|
|
|
Service: "bar",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2020-02-20 21:24:05 +00:00
|
|
|
"bar": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://localhost:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one app with udp labels with port and http service",
|
|
|
|
applications: withApplications(
|
|
|
|
application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80, 81),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
withLabel("traefik.udp.routers.foo.entrypoints", "mydns"),
|
|
|
|
withLabel("traefik.udp.services.foo.loadbalancer.server.port", "8080"),
|
|
|
|
withLabel("traefik.http.services.bar.loadbalancer.passhostheader", "true"),
|
|
|
|
)),
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"foo": {
|
|
|
|
Service: "foo",
|
|
|
|
EntryPoints: []string{"mydns"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"foo": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "localhost:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"app": {
|
|
|
|
Service: "bar",
|
|
|
|
Rule: "Host(`app.marathon.localhost`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-04-15 16:22:07 +00:00
|
|
|
"bar": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-04-15 16:22:07 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-04-15 16:22:07 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2019-01-30 15:24:07 +00:00
|
|
|
defaultRule := "Host(`{{ normalize .Name }}.marathon.localhost`)"
|
2019-01-29 16:54:05 +00:00
|
|
|
if len(test.defaultRule) > 0 {
|
|
|
|
defaultRule = test.defaultRule
|
|
|
|
}
|
|
|
|
|
|
|
|
p := &Provider{
|
2019-06-21 07:24:04 +00:00
|
|
|
DefaultRule: defaultRule,
|
|
|
|
ExposedByDefault: true,
|
2019-01-29 16:54:05 +00:00
|
|
|
}
|
|
|
|
p.Constraints = test.constraints
|
|
|
|
|
|
|
|
err := p.Init()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
actualConfig := p.buildConfiguration(context.Background(), test.applications)
|
|
|
|
|
|
|
|
assert.NotNil(t, actualConfig)
|
2019-04-15 16:22:07 +00:00
|
|
|
assert.Equal(t, test.expected, actualConfig)
|
2019-01-29 16:54:05 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestApplicationFilterEnabled(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
exposedByDefault bool
|
|
|
|
enabledLabel string
|
|
|
|
expected bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "exposed and tolerated by valid label value",
|
|
|
|
exposedByDefault: true,
|
|
|
|
enabledLabel: "true",
|
|
|
|
expected: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "exposed but overridden by label",
|
|
|
|
exposedByDefault: true,
|
|
|
|
enabledLabel: "false",
|
|
|
|
expected: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "non-exposed but overridden by label",
|
|
|
|
exposedByDefault: false,
|
|
|
|
enabledLabel: "true",
|
|
|
|
expected: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2019-06-17 09:48:05 +00:00
|
|
|
provider := &Provider{ExposedByDefault: true}
|
2019-01-29 16:54:05 +00:00
|
|
|
|
|
|
|
app := application(withLabel("traefik.enable", test.enabledLabel))
|
|
|
|
|
|
|
|
extraConf, err := provider.getConfiguration(app)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2019-06-21 07:24:04 +00:00
|
|
|
if provider.keepApplication(context.Background(), extraConf, stringValueMap(app.Labels)) != test.expected {
|
2019-01-29 16:54:05 +00:00
|
|
|
t.Errorf("got unexpected filtering = %t", !test.expected)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetServer(t *testing.T) {
|
|
|
|
type expected struct {
|
2019-07-10 07:26:04 +00:00
|
|
|
server dynamic.Server
|
2019-01-29 16:54:05 +00:00
|
|
|
error string
|
|
|
|
}
|
|
|
|
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
provider Provider
|
|
|
|
app marathon.Application
|
|
|
|
extraConf configuration
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer dynamic.Server
|
2019-01-29 16:54:05 +00:00
|
|
|
expected expected
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "undefined host",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{},
|
2019-01-29 16:54:05 +00:00
|
|
|
expected: expected{
|
|
|
|
error: `host is undefined for task "taskID" app ""`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with task port",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80))),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
},
|
|
|
|
expected: expected{
|
2019-07-10 07:26:04 +00:00
|
|
|
server: dynamic.Server{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "without task port",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask()),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
},
|
|
|
|
expected: expected{
|
|
|
|
error: "unable to process ports for /app taskID: no port found",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with default server port",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80))),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
Port: "88",
|
|
|
|
},
|
|
|
|
expected: expected{
|
2019-07-10 07:26:04 +00:00
|
|
|
server: dynamic.Server{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:88",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with invalid default server port",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80))),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
Port: "aaaa",
|
|
|
|
},
|
|
|
|
expected: expected{
|
|
|
|
error: `unable to process ports for /app taskID: strconv.Atoi: parsing "aaaa": invalid syntax`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with negative default server port",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80))),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
Port: "-6",
|
|
|
|
},
|
|
|
|
expected: expected{
|
|
|
|
error: `unable to process ports for /app taskID: explicitly specified port -6 must be greater than zero`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with port index",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
Port: "index:1",
|
|
|
|
},
|
|
|
|
expected: expected{
|
2019-07-10 07:26:04 +00:00
|
|
|
server: dynamic.Server{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:81",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with out of range port index",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
Port: "index:2",
|
|
|
|
},
|
|
|
|
expected: expected{
|
|
|
|
error: "unable to process ports for /app taskID: index 2 must be within range (0, 1)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with invalid port index",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
Port: "index:aaa",
|
|
|
|
},
|
|
|
|
expected: expected{
|
|
|
|
error: `unable to process ports for /app taskID: strconv.Atoi: parsing "aaa": invalid syntax`,
|
|
|
|
},
|
|
|
|
},
|
2020-12-16 11:32:03 +00:00
|
|
|
{
|
|
|
|
desc: "with port name",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
portDefinition(80, "fist-port"),
|
|
|
|
portDefinition(81, "second-port"),
|
|
|
|
portDefinition(82, "third-port"),
|
|
|
|
withTasks(localhostTask()),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
|
|
|
defaultServer: dynamic.Server{
|
|
|
|
Scheme: "http",
|
|
|
|
Port: "name:third-port",
|
|
|
|
},
|
|
|
|
expected: expected{
|
|
|
|
server: dynamic.Server{
|
|
|
|
URL: "http://localhost:82",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with port name not found",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
portDefinition(80, "fist-port"),
|
|
|
|
portDefinition(81, "second-port"),
|
|
|
|
portDefinition(82, "third-port"),
|
|
|
|
withTasks(localhostTask()),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
|
|
|
defaultServer: dynamic.Server{
|
|
|
|
Scheme: "http",
|
|
|
|
Port: "name:other-name",
|
|
|
|
},
|
|
|
|
expected: expected{
|
|
|
|
error: `unable to process ports for /app taskID: no port with name other-name`,
|
|
|
|
},
|
|
|
|
},
|
2019-01-29 16:54:05 +00:00
|
|
|
{
|
|
|
|
desc: "with application port and no task port",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
2020-12-16 11:32:03 +00:00
|
|
|
portDefinition(80, "http"),
|
2019-01-29 16:54:05 +00:00
|
|
|
withTasks(localhostTask()),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
},
|
|
|
|
expected: expected{
|
2019-07-10 07:26:04 +00:00
|
|
|
server: dynamic.Server{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with IP per task",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
ipAddrPerTask(88),
|
|
|
|
withTasks(localhostTask()),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
},
|
|
|
|
expected: expected{
|
2019-07-10 07:26:04 +00:00
|
|
|
server: dynamic.Server{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:88",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with container network",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
containerNetwork(),
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(80),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
},
|
|
|
|
expected: expected{
|
2019-07-10 07:26:04 +00:00
|
|
|
server: dynamic.Server{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with bridge network",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
bridgeNetwork(),
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(83),
|
|
|
|
withTasks(localhostTask(taskPorts(80, 81))),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
},
|
|
|
|
expected: expected{
|
2019-07-10 07:26:04 +00:00
|
|
|
server: dynamic.Server{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://localhost:80",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with several IP addresses on task",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
ipAddrPerTask(88),
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(83),
|
|
|
|
withTasks(
|
|
|
|
task(
|
|
|
|
withTaskID("myTask"),
|
|
|
|
host("localhost"),
|
|
|
|
ipAddresses("127.0.0.1", "127.0.0.2"),
|
|
|
|
taskState(taskStateRunning),
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
extraConf: configuration{
|
|
|
|
Marathon: specificConfiguration{
|
|
|
|
IPAddressIdx: 0,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
},
|
|
|
|
expected: expected{
|
2019-07-10 07:26:04 +00:00
|
|
|
server: dynamic.Server{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:88",
|
2019-01-29 16:54:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with several IP addresses on task, undefined [MinInt32] IPAddressIdx",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
ipAddrPerTask(88),
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(83),
|
|
|
|
withTasks(
|
|
|
|
task(
|
|
|
|
host("localhost"),
|
|
|
|
ipAddresses("127.0.0.1", "127.0.0.2"),
|
|
|
|
taskState(taskStateRunning),
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
extraConf: configuration{
|
|
|
|
Marathon: specificConfiguration{
|
|
|
|
IPAddressIdx: math.MinInt32,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
},
|
|
|
|
expected: expected{
|
|
|
|
error: "found 2 task IP addresses but missing IP address index for Marathon application /app on task taskID",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with several IP addresses on task, IPAddressIdx out of range",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
ipAddrPerTask(88),
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(83),
|
|
|
|
withTasks(
|
|
|
|
task(
|
|
|
|
host("localhost"),
|
|
|
|
ipAddresses("127.0.0.1", "127.0.0.2"),
|
|
|
|
taskState(taskStateRunning),
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
extraConf: configuration{
|
|
|
|
Marathon: specificConfiguration{
|
|
|
|
IPAddressIdx: 3,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
},
|
|
|
|
expected: expected{
|
|
|
|
error: "cannot use IP address index to select from 2 task IP addresses for Marathon application /app on task taskID",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "with task without IP address",
|
|
|
|
provider: Provider{},
|
|
|
|
app: application(
|
|
|
|
ipAddrPerTask(88),
|
|
|
|
appID("/app"),
|
|
|
|
appPorts(83),
|
|
|
|
withTasks(
|
|
|
|
task(
|
|
|
|
host("localhost"),
|
|
|
|
taskState(taskStateRunning),
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
extraConf: configuration{},
|
2019-07-10 07:26:04 +00:00
|
|
|
defaultServer: dynamic.Server{
|
2019-01-29 16:54:05 +00:00
|
|
|
Scheme: "http",
|
|
|
|
},
|
|
|
|
expected: expected{
|
|
|
|
error: "missing IP address for Marathon application /app on task taskID",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
task := task()
|
|
|
|
if len(test.app.Tasks) > 0 {
|
|
|
|
task = *test.app.Tasks[0]
|
|
|
|
}
|
|
|
|
|
|
|
|
server, err := test.provider.getServer(test.app, task, test.extraConf, test.defaultServer)
|
|
|
|
if len(test.expected.error) > 0 {
|
|
|
|
require.EqualError(t, err, test.expected.error)
|
|
|
|
} else {
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
assert.Equal(t, test.expected.server, server)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|