From 81cb00573f8c376de9b6e1a58ca548882f3ab2a2 Mon Sep 17 00:00:00 2001 From: emile Date: Mon, 1 Feb 2016 11:07:05 +0100 Subject: [PATCH] Fix tests to accept entrypoints --- integration/basic_test.go | 7 ++-- integration/consul_test.go | 8 +++-- integration/fixtures/consul/simple.toml | 15 ++++----- integration/fixtures/docker/simple.toml | 15 ++++----- .../fixtures/file/56-simple-panic.toml | 15 ++++----- integration/fixtures/file/simple.toml | 15 ++++----- integration/fixtures/https/https_sni.toml | 18 ++++++---- integration/fixtures/marathon/simple.toml | 15 ++++----- integration/fixtures/simple_default.toml | 14 +++----- integration/fixtures/simple_web.toml | 7 ++-- integration/marathon_test.go | 8 +++-- provider/docker_test.go | 12 ++++--- provider/kv_test.go | 4 +-- provider/marathon_test.go | 33 ++++++++++++++++++- 14 files changed, 107 insertions(+), 79 deletions(-) diff --git a/integration/basic_test.go b/integration/basic_test.go index d9a9178a8..90dd2fd25 100644 --- a/integration/basic_test.go +++ b/integration/basic_test.go @@ -46,9 +46,10 @@ func (s *SimpleSuite) TestSimpleDefaultConfig(c *check.C) { // TODO validate : run on 80 resp, err := http.Get("http://127.0.0.1:8000/") - // Expected a 404 as we did not configure anything - c.Assert(err, checker.IsNil) - c.Assert(resp.StatusCode, checker.Equals, 404) + // Expected no response as we did not configure anything + c.Assert(resp, checker.IsNil) + c.Assert(err, checker.NotNil) + c.Assert(err.Error(), checker.Contains, fmt.Sprintf("getsockopt: connection refused")) } func (s *SimpleSuite) TestWithWebConfig(c *check.C) { diff --git a/integration/consul_test.go b/integration/consul_test.go index 07af1aa7f..c672cfde2 100644 --- a/integration/consul_test.go +++ b/integration/consul_test.go @@ -5,6 +5,7 @@ import ( "os/exec" "time" + "fmt" checker "github.com/vdemeester/shakers" check "gopkg.in/check.v1" ) @@ -19,7 +20,8 @@ func (s *ConsulSuite) TestSimpleConfiguration(c *check.C) { // TODO validate : run on 80 resp, err := http.Get("http://127.0.0.1:8000/") - // Expected a 404 as we did not comfigure anything - c.Assert(err, checker.IsNil) - c.Assert(resp.StatusCode, checker.Equals, 404) + // Expected no response as we did not configure anything + c.Assert(resp, checker.IsNil) + c.Assert(err, checker.NotNil) + c.Assert(err.Error(), checker.Contains, fmt.Sprintf("getsockopt: connection refused")) } diff --git a/integration/fixtures/consul/simple.toml b/integration/fixtures/consul/simple.toml index 34947f7e8..287738af7 100644 --- a/integration/fixtures/consul/simple.toml +++ b/integration/fixtures/consul/simple.toml @@ -1,12 +1,9 @@ -# Reverse proxy port -# -# Optional -# Default: ":80" -# -# port = ":80" -port = ":8000" -# -# LogLevel +defaultEntryPoints = ["http"] + +[entryPoints] + [entryPoints.http] + address = ":8000" + logLevel = "DEBUG" [consul] diff --git a/integration/fixtures/docker/simple.toml b/integration/fixtures/docker/simple.toml index 963cfd5a8..d055def10 100644 --- a/integration/fixtures/docker/simple.toml +++ b/integration/fixtures/docker/simple.toml @@ -1,12 +1,9 @@ -# Reverse proxy port -# -# Optional -# Default: ":80" -# -# port = ":80" -port = ":8000" -# -# LogLevel +defaultEntryPoints = ["http"] + +[entryPoints] + [entryPoints.http] + address = ":8000" + logLevel = "DEBUG" [docker] diff --git a/integration/fixtures/file/56-simple-panic.toml b/integration/fixtures/file/56-simple-panic.toml index f8c792e65..278b9cb9c 100644 --- a/integration/fixtures/file/56-simple-panic.toml +++ b/integration/fixtures/file/56-simple-panic.toml @@ -1,12 +1,9 @@ -# Reverse proxy port -# -# Optional -# Default: ":80" -# -# port = ":80" -port = ":8000" -# -# LogLevel +defaultEntryPoints = ["http"] + +[entryPoints] + [entryPoints.http] + address = ":8000" + logLevel = "DEBUG" [file] diff --git a/integration/fixtures/file/simple.toml b/integration/fixtures/file/simple.toml index 3db190f40..bcdc07c6e 100644 --- a/integration/fixtures/file/simple.toml +++ b/integration/fixtures/file/simple.toml @@ -1,12 +1,9 @@ -# Reverse proxy port -# -# Optional -# Default: ":80" -# -# port = ":80" -port = ":8000" -# -# LogLevel +defaultEntryPoints = ["http"] + +[entryPoints] + [entryPoints.http] + address = ":8000" + logLevel = "DEBUG" [file] diff --git a/integration/fixtures/https/https_sni.toml b/integration/fixtures/https/https_sni.toml index aebf22657..2a1fa04a9 100644 --- a/integration/fixtures/https/https_sni.toml +++ b/integration/fixtures/https/https_sni.toml @@ -1,13 +1,17 @@ -port = ":4443" logLevel = "DEBUG" -[[certificates]] -CertFile = "fixtures/https/snitest.com.cert" -KeyFile = "fixtures/https/snitest.com.key" +defaultEntryPoints = ["https"] -[[certificates]] -CertFile = "fixtures/https/snitest.org.cert" -KeyFile = "fixtures/https/snitest.org.key" +[entryPoints] + [entryPoints.https] + address = ":4443" + [entryPoints.https.tls] + [[entryPoints.https.tls.certificates]] + CertFile = "fixtures/https/snitest.com.cert" + KeyFile = "fixtures/https/snitest.com.key" + [[entryPoints.https.tls.certificates]] + CertFile = "fixtures/https/snitest.org.cert" + KeyFile = "fixtures/https/snitest.org.key" [file] diff --git a/integration/fixtures/marathon/simple.toml b/integration/fixtures/marathon/simple.toml index c6cfbb05a..fedfdfb3d 100644 --- a/integration/fixtures/marathon/simple.toml +++ b/integration/fixtures/marathon/simple.toml @@ -1,12 +1,9 @@ -# Reverse proxy port -# -# Optional -# Default: ":80" -# -# port = ":80" -port = ":8000" -# -# LogLevel +defaultEntryPoints = ["http"] + +[entryPoints] + [entryPoints.http] + address = ":8000" + logLevel = "DEBUG" [marathon] diff --git a/integration/fixtures/simple_default.toml b/integration/fixtures/simple_default.toml index 3f5fe41df..d61410d7c 100644 --- a/integration/fixtures/simple_default.toml +++ b/integration/fixtures/simple_default.toml @@ -1,9 +1,5 @@ -# Reverse proxy port -# -# Optional -# Default: ":80" -# -port = ":8000" -# -# LogLevel -logLevel = "DEBUG" +defaultEntryPoints = ["http"] + +[entryPoints] + [entryPoints.http] + address = ":8000" \ No newline at end of file diff --git a/integration/fixtures/simple_web.toml b/integration/fixtures/simple_web.toml index 49452f6e5..b05590cf2 100644 --- a/integration/fixtures/simple_web.toml +++ b/integration/fixtures/simple_web.toml @@ -1,6 +1,9 @@ -port = ":8000" logLevel = "DEBUG" +defaultEntryPoints = ["http"] + +[entryPoints] + [entryPoints.http] + address = ":8000" [web] - address = ":8080" diff --git a/integration/marathon_test.go b/integration/marathon_test.go index 40a42ffd6..e13b25bbf 100644 --- a/integration/marathon_test.go +++ b/integration/marathon_test.go @@ -5,6 +5,7 @@ import ( "os/exec" "time" + "fmt" checker "github.com/vdemeester/shakers" check "gopkg.in/check.v1" ) @@ -19,7 +20,8 @@ func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) { // TODO validate : run on 80 resp, err := http.Get("http://127.0.0.1:8000/") - // Expected a 404 as we did not configure anything - c.Assert(err, checker.IsNil) - c.Assert(resp.StatusCode, checker.Equals, 404) + // Expected no response as we did not configure anything + c.Assert(resp, checker.IsNil) + c.Assert(err, checker.NotNil) + c.Assert(err.Error(), checker.Contains, fmt.Sprintf("getsockopt: connection refused")) } diff --git a/provider/docker_test.go b/provider/docker_test.go index 54b30dc5d..590c16ccd 100644 --- a/provider/docker_test.go +++ b/provider/docker_test.go @@ -682,7 +682,8 @@ func TestDockerLoadDockerConfig(t *testing.T) { }, expectedFrontends: map[string]*types.Frontend{ `"frontend-Host-test-docker-localhost"`: { - Backend: "backend-test", + Backend: "backend-test", + EntryPoints: []string{}, Routes: map[string]types.Route{ `"route-frontend-Host-test-docker-localhost"`: { Rule: "Host", @@ -709,7 +710,8 @@ func TestDockerLoadDockerConfig(t *testing.T) { Name: "test1", Config: &docker.Config{ Labels: map[string]string{ - "traefik.backend": "foobar", + "traefik.backend": "foobar", + "traefik.frontend.entryPoints": "http,https", }, }, NetworkSettings: &docker.NetworkSettings{ @@ -736,7 +738,8 @@ func TestDockerLoadDockerConfig(t *testing.T) { }, expectedFrontends: map[string]*types.Frontend{ `"frontend-Host-test1-docker-localhost"`: { - Backend: "backend-foobar", + Backend: "backend-foobar", + EntryPoints: []string{"http", "https"}, Routes: map[string]types.Route{ `"route-frontend-Host-test1-docker-localhost"`: { Rule: "Host", @@ -745,7 +748,8 @@ func TestDockerLoadDockerConfig(t *testing.T) { }, }, `"frontend-Host-test2-docker-localhost"`: { - Backend: "backend-foobar", + Backend: "backend-foobar", + EntryPoints: []string{}, Routes: map[string]types.Route{ `"route-frontend-Host-test2-docker-localhost"`: { Rule: "Host", diff --git a/provider/kv_test.go b/provider/kv_test.go index 3cb79f257..d879ccfa4 100644 --- a/provider/kv_test.go +++ b/provider/kv_test.go @@ -176,7 +176,7 @@ func TestKvGet(t *testing.T) { } for _, c := range cases { - actual := c.provider.get(c.keys...) + actual := c.provider.get("", c.keys...) if actual != c.expected { t.Fatalf("expected %v, got %v for %v and %v", c.expected, actual, c.keys, c.provider) } @@ -188,7 +188,7 @@ func TestKvGet(t *testing.T) { Error: true, }, } - actual := provider.get("anything") + actual := provider.get("", "anything") if actual != "" { t.Fatalf("Should have return nil, got %v", actual) } diff --git a/provider/marathon_test.go b/provider/marathon_test.go index 8ffc026eb..642f28224 100644 --- a/provider/marathon_test.go +++ b/provider/marathon_test.go @@ -84,7 +84,8 @@ func TestMarathonLoadConfig(t *testing.T) { }, expectedFrontends: map[string]*types.Frontend{ `frontend-test`: { - Backend: "backend-test", + Backend: "backend-test", + EntryPoints: []string{}, Routes: map[string]types.Route{ `route-host-test`: { Rule: "Host", @@ -735,6 +736,36 @@ func TestMarathonGetPassHostHeader(t *testing.T) { } } +func TestMarathonGetEntryPoints(t *testing.T) { + provider := &Marathon{} + + applications := []struct { + application marathon.Application + expected []string + }{ + { + application: marathon.Application{}, + expected: []string{}, + }, + { + application: marathon.Application{ + Labels: map[string]string{ + "traefik.frontend.entryPoints": "http,https", + }, + }, + expected: []string{"http", "https"}, + }, + } + + for _, a := range applications { + actual := provider.getEntryPoints(a.application) + + if !reflect.DeepEqual(actual, a.expected) { + t.Fatalf("expected %#v, got %#v", a.expected, actual) + } + } +} + func TestMarathonGetFrontendValue(t *testing.T) { provider := &Marathon{ Domain: "docker.localhost",