Enhance integration tests
* refactor: remove unused code. * refactor: factorize Traefik cmd start. * refactor(whitelist): minor change. * refactor(accesslog): better use of checker. * refactor(errorpages): factorize containers IP variables. * refactor(integration): refactor cmdTraefikWithConfigFile.
This commit is contained in:
parent
bbb133d94c
commit
2e84b1e556
20 changed files with 109 additions and 231 deletions
|
@ -7,15 +7,12 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
shellwords "github.com/mattn/go-shellwords"
|
"github.com/mattn/go-shellwords"
|
||||||
|
|
||||||
checker "github.com/vdemeester/shakers"
|
checker "github.com/vdemeester/shakers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,7 +25,7 @@ func (s *AccessLogSuite) TestAccessLog(c *check.C) {
|
||||||
os.Remove("traefik.log")
|
os.Remove("traefik.log")
|
||||||
|
|
||||||
// Start Traefik
|
// Start Traefik
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/access_log_config.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/access_log_config.toml"))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -49,7 +46,7 @@ func (s *AccessLogSuite) TestAccessLog(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
if len(traefikLog) > 0 {
|
if len(traefikLog) > 0 {
|
||||||
fmt.Printf("%s\n", string(traefikLog))
|
fmt.Printf("%s\n", string(traefikLog))
|
||||||
c.Assert(len(traefikLog), checker.Equals, 0)
|
c.Assert(traefikLog, checker.HasLen, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start test servers
|
// Start test servers
|
||||||
|
@ -78,12 +75,12 @@ func (s *AccessLogSuite) TestAccessLog(c *check.C) {
|
||||||
count++
|
count++
|
||||||
tokens, err := shellwords.Parse(line)
|
tokens, err := shellwords.Parse(line)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(len(tokens), checker.Equals, 14)
|
c.Assert(tokens, checker.HasLen, 14)
|
||||||
c.Assert(regexp.MustCompile(`^\d{3}$`).MatchString(tokens[6]), checker.True)
|
c.Assert(tokens[6], checker.Matches, `^\d{3}$`)
|
||||||
c.Assert(tokens[10], checker.Equals, fmt.Sprintf("%d", i+1))
|
c.Assert(tokens[10], checker.Equals, fmt.Sprintf("%d", i+1))
|
||||||
c.Assert(strings.HasPrefix(tokens[11], "frontend"), checker.True)
|
c.Assert(tokens[11], checker.HasPrefix, "frontend")
|
||||||
c.Assert(strings.HasPrefix(tokens[12], "http://127.0.0.1:808"), checker.True)
|
c.Assert(tokens[12], checker.HasPrefix, "http://127.0.0.1:808")
|
||||||
c.Assert(regexp.MustCompile(`^\d+ms$`).MatchString(tokens[13]), checker.True)
|
c.Assert(tokens[13], checker.Matches, `^\d+ms$`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.Assert(count, checker.GreaterOrEqualThan, 3)
|
c.Assert(count, checker.GreaterOrEqualThan, 3)
|
||||||
|
@ -93,7 +90,7 @@ func (s *AccessLogSuite) TestAccessLog(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
if len(traefikLog) > 0 {
|
if len(traefikLog) > 0 {
|
||||||
fmt.Printf("%s\n", string(traefikLog))
|
fmt.Printf("%s\n", string(traefikLog))
|
||||||
c.Assert(len(traefikLog), checker.Equals, 0)
|
c.Assert(traefikLog, checker.HasLen, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ func (s *AcmeSuite) retrieveAcmeCertificate(c *check.C, testCase AcmeTestCase) {
|
||||||
OnHostRule: !testCase.onDemand,
|
OnHostRule: !testCase.onDemand,
|
||||||
})
|
})
|
||||||
|
|
||||||
cmd, output := s.cmdTraefikWithConfigFile(file)
|
cmd, output := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/exec"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -17,11 +15,7 @@ import (
|
||||||
type SimpleSuite struct{ BaseSuite }
|
type SimpleSuite struct{ BaseSuite }
|
||||||
|
|
||||||
func (s *SimpleSuite) TestInvalidConfigShouldFail(c *check.C) {
|
func (s *SimpleSuite) TestInvalidConfigShouldFail(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/invalid_configuration.toml")
|
cmd, output := s.cmdTraefik(withConfigFile("fixtures/invalid_configuration.toml"))
|
||||||
|
|
||||||
var b bytes.Buffer
|
|
||||||
cmd.Stdout = &b
|
|
||||||
cmd.Stderr = &b
|
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -29,7 +23,7 @@ func (s *SimpleSuite) TestInvalidConfigShouldFail(c *check.C) {
|
||||||
|
|
||||||
err = try.Do(500*time.Millisecond, func() error {
|
err = try.Do(500*time.Millisecond, func() error {
|
||||||
expected := "Near line 0 (last key parsed ''): bare keys cannot contain '{'"
|
expected := "Near line 0 (last key parsed ''): bare keys cannot contain '{'"
|
||||||
actual := b.String()
|
actual := output.String()
|
||||||
|
|
||||||
if !strings.Contains(actual, expected) {
|
if !strings.Contains(actual, expected) {
|
||||||
return fmt.Errorf("Got %s, wanted %s", actual, expected)
|
return fmt.Errorf("Got %s, wanted %s", actual, expected)
|
||||||
|
@ -41,7 +35,7 @@ func (s *SimpleSuite) TestInvalidConfigShouldFail(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SimpleSuite) TestSimpleDefaultConfig(c *check.C) {
|
func (s *SimpleSuite) TestSimpleDefaultConfig(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/simple_default.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/simple_default.toml"))
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -54,7 +48,7 @@ func (s *SimpleSuite) TestSimpleDefaultConfig(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SimpleSuite) TestWithWebConfig(c *check.C) {
|
func (s *SimpleSuite) TestWithWebConfig(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/simple_web.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/simple_web.toml"))
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -65,11 +59,7 @@ func (s *SimpleSuite) TestWithWebConfig(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SimpleSuite) TestDefaultEntryPoints(c *check.C) {
|
func (s *SimpleSuite) TestDefaultEntryPoints(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "--debug")
|
cmd, output := s.cmdTraefik("--debug")
|
||||||
|
|
||||||
var b bytes.Buffer
|
|
||||||
cmd.Stdout = &b
|
|
||||||
cmd.Stderr = &b
|
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -77,7 +67,7 @@ func (s *SimpleSuite) TestDefaultEntryPoints(c *check.C) {
|
||||||
|
|
||||||
err = try.Do(500*time.Millisecond, func() error {
|
err = try.Do(500*time.Millisecond, func() error {
|
||||||
expected := "\"DefaultEntryPoints\":[\"http\"]"
|
expected := "\"DefaultEntryPoints\":[\"http\"]"
|
||||||
actual := b.String()
|
actual := output.String()
|
||||||
|
|
||||||
if !strings.Contains(actual, expected) {
|
if !strings.Contains(actual, expected) {
|
||||||
return fmt.Errorf("Got %s, wanted %s", actual, expected)
|
return fmt.Errorf("Got %s, wanted %s", actual, expected)
|
||||||
|
@ -89,11 +79,7 @@ func (s *SimpleSuite) TestDefaultEntryPoints(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SimpleSuite) TestPrintHelp(c *check.C) {
|
func (s *SimpleSuite) TestPrintHelp(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "--help")
|
cmd, output := s.cmdTraefik("--help")
|
||||||
|
|
||||||
var b bytes.Buffer
|
|
||||||
cmd.Stdout = &b
|
|
||||||
cmd.Stderr = &b
|
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -102,7 +88,7 @@ func (s *SimpleSuite) TestPrintHelp(c *check.C) {
|
||||||
err = try.Do(500*time.Millisecond, func() error {
|
err = try.Do(500*time.Millisecond, func() error {
|
||||||
expected := "Usage:"
|
expected := "Usage:"
|
||||||
notExpected := "panic:"
|
notExpected := "panic:"
|
||||||
actual := b.String()
|
actual := output.String()
|
||||||
|
|
||||||
if strings.Contains(actual, notExpected) {
|
if strings.Contains(actual, notExpected) {
|
||||||
return fmt.Errorf("Got %s", actual)
|
return fmt.Errorf("Got %s", actual)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package integration
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/exec"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
|
@ -81,11 +80,11 @@ func (s *ConstraintSuite) deregisterService(name string, address string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestMatchConstraintGlobal(c *check.C) {
|
func (s *ConstraintSuite) TestMatchConstraintGlobal(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary,
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost",
|
"--consulCatalog.domain=consul.localhost",
|
||||||
"--configFile=fixtures/consul_catalog/simple.toml",
|
|
||||||
"--constraints=tag==api")
|
"--constraints=tag==api")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -106,11 +105,11 @@ func (s *ConstraintSuite) TestMatchConstraintGlobal(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestDoesNotMatchConstraintGlobal(c *check.C) {
|
func (s *ConstraintSuite) TestDoesNotMatchConstraintGlobal(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary,
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost",
|
"--consulCatalog.domain=consul.localhost",
|
||||||
"--configFile=fixtures/consul_catalog/simple.toml",
|
|
||||||
"--constraints=tag==api")
|
"--constraints=tag==api")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -131,11 +130,11 @@ func (s *ConstraintSuite) TestDoesNotMatchConstraintGlobal(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestMatchConstraintProvider(c *check.C) {
|
func (s *ConstraintSuite) TestMatchConstraintProvider(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary,
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost",
|
"--consulCatalog.domain=consul.localhost",
|
||||||
"--configFile=fixtures/consul_catalog/simple.toml",
|
|
||||||
"--consulCatalog.constraints=tag==api")
|
"--consulCatalog.constraints=tag==api")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -156,11 +155,11 @@ func (s *ConstraintSuite) TestMatchConstraintProvider(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestDoesNotMatchConstraintProvider(c *check.C) {
|
func (s *ConstraintSuite) TestDoesNotMatchConstraintProvider(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary,
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost",
|
"--consulCatalog.domain=consul.localhost",
|
||||||
"--configFile=fixtures/consul_catalog/simple.toml",
|
|
||||||
"--consulCatalog.constraints=tag==api")
|
"--consulCatalog.constraints=tag==api")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -181,11 +180,11 @@ func (s *ConstraintSuite) TestDoesNotMatchConstraintProvider(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestMatchMultipleConstraint(c *check.C) {
|
func (s *ConstraintSuite) TestMatchMultipleConstraint(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary,
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost",
|
"--consulCatalog.domain=consul.localhost",
|
||||||
"--configFile=fixtures/consul_catalog/simple.toml",
|
|
||||||
"--consulCatalog.constraints=tag==api",
|
"--consulCatalog.constraints=tag==api",
|
||||||
"--constraints=tag!=us-*")
|
"--constraints=tag!=us-*")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
|
@ -207,11 +206,11 @@ func (s *ConstraintSuite) TestMatchMultipleConstraint(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestDoesNotMatchMultipleConstraint(c *check.C) {
|
func (s *ConstraintSuite) TestDoesNotMatchMultipleConstraint(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary,
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost",
|
"--consulCatalog.domain=consul.localhost",
|
||||||
"--configFile=fixtures/consul_catalog/simple.toml",
|
|
||||||
"--consulCatalog.constraints=tag==api",
|
"--consulCatalog.constraints=tag==api",
|
||||||
"--constraints=tag!=us-*")
|
"--constraints=tag!=us-*")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
|
|
|
@ -3,7 +3,6 @@ package integration
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/exec"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
|
@ -81,10 +80,10 @@ func (s *ConsulCatalogSuite) deregisterService(name string, address string) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConsulCatalogSuite) TestSimpleConfiguration(c *check.C) {
|
func (s *ConsulCatalogSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary,
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500")
|
||||||
"--configFile=fixtures/consul_catalog/simple.toml")
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -96,11 +95,11 @@ func (s *ConsulCatalogSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConsulCatalogSuite) TestSingleService(c *check.C) {
|
func (s *ConsulCatalogSuite) TestSingleService(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary,
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost",
|
"--consulCatalog.domain=consul.localhost")
|
||||||
"--configFile=fixtures/consul_catalog/simple.toml")
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -96,7 +95,7 @@ func (s *ConsulSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
file := s.adaptFile(c, "fixtures/consul/simple.toml", struct{ ConsulHost string }{consulHost})
|
file := s.adaptFile(c, "fixtures/consul/simple.toml", struct{ ConsulHost string }{consulHost})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -112,7 +111,7 @@ func (s *ConsulSuite) TestNominalConfiguration(c *check.C) {
|
||||||
file := s.adaptFile(c, "fixtures/consul/simple.toml", struct{ ConsulHost string }{consulHost})
|
file := s.adaptFile(c, "fixtures/consul/simple.toml", struct{ ConsulHost string }{consulHost})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -211,7 +210,10 @@ func (s *ConsulSuite) TestGlobalConfiguration(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// start traefik
|
// start traefik
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/simple_web.toml", "--consul", "--consul.endpoint="+consulHost+":8500")
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
|
"--consul",
|
||||||
|
"--consul.endpoint="+consulHost+":8500")
|
||||||
|
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -295,8 +297,10 @@ func (s *ConsulSuite) skipTestGlobalConfigurationWithClientTLS(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// start traefik
|
// start traefik
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/simple_web.toml",
|
cmd, _ := s.cmdTraefik(
|
||||||
"--consul", "--consul.endpoint="+consulHost+":8585",
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
|
"--consul",
|
||||||
|
"--consul.endpoint="+consulHost+":8585",
|
||||||
"--consul.tls.ca=resources/tls/ca.cert",
|
"--consul.tls.ca=resources/tls/ca.cert",
|
||||||
"--consul.tls.cert=resources/tls/consul.cert",
|
"--consul.tls.cert=resources/tls/consul.cert",
|
||||||
"--consul.tls.key=resources/tls/consul.key",
|
"--consul.tls.key=resources/tls/consul.key",
|
||||||
|
@ -315,9 +319,9 @@ func (s *ConsulSuite) TestCommandStoreConfig(c *check.C) {
|
||||||
s.setupConsul(c)
|
s.setupConsul(c)
|
||||||
consulHost := s.composeProject.Container(c, "consul").NetworkSettings.IPAddress
|
consulHost := s.composeProject.Container(c, "consul").NetworkSettings.IPAddress
|
||||||
|
|
||||||
cmd := exec.Command(traefikBinary,
|
cmd, _ := s.cmdTraefik(
|
||||||
"storeconfig",
|
"storeconfig",
|
||||||
"--configFile=fixtures/simple_web.toml",
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
"--consul.endpoint="+consulHost+":8500")
|
"--consul.endpoint="+consulHost+":8500")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ func (s *DockerSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
file := s.adaptFileForHost(c, "fixtures/docker/simple.toml")
|
file := s.adaptFileForHost(c, "fixtures/docker/simple.toml")
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -97,7 +96,7 @@ func (s *DockerSuite) TestDefaultDockerContainers(c *check.C) {
|
||||||
name := s.startContainer(c, "swarm:1.0.0", "manage", "token://blablabla")
|
name := s.startContainer(c, "swarm:1.0.0", "manage", "token://blablabla")
|
||||||
|
|
||||||
// Start traefik
|
// Start traefik
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -129,7 +128,7 @@ func (s *DockerSuite) TestDockerContainersWithLabels(c *check.C) {
|
||||||
s.startContainerWithLabels(c, "swarm:1.0.0", labels, "manage", "token://blabla")
|
s.startContainerWithLabels(c, "swarm:1.0.0", labels, "manage", "token://blabla")
|
||||||
|
|
||||||
// Start traefik
|
// Start traefik
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -161,7 +160,7 @@ func (s *DockerSuite) TestDockerContainersWithOneMissingLabels(c *check.C) {
|
||||||
s.startContainerWithLabels(c, "swarm:1.0.0", labels, "manage", "token://blabla")
|
s.startContainerWithLabels(c, "swarm:1.0.0", labels, "manage", "token://blabla")
|
||||||
|
|
||||||
// Start traefik
|
// Start traefik
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -3,7 +3,6 @@ package integration
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
@ -147,7 +146,7 @@ func (s *DynamoDBSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
dynamoURL := "http://" + s.composeProject.Container(c, "dynamo").NetworkSettings.IPAddress + ":8000"
|
dynamoURL := "http://" + s.composeProject.Container(c, "dynamo").NetworkSettings.IPAddress + ":8000"
|
||||||
file := s.adaptFile(c, "fixtures/dynamodb/simple.toml", struct{ DynamoURL string }{dynamoURL})
|
file := s.adaptFile(c, "fixtures/dynamodb/simple.toml", struct{ DynamoURL string }{dynamoURL})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -3,7 +3,6 @@ package integration
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
|
@ -12,25 +11,29 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrorPagesSuite test suites (using libcompose)
|
// ErrorPagesSuite test suites (using libcompose)
|
||||||
type ErrorPagesSuite struct{ BaseSuite }
|
type ErrorPagesSuite struct {
|
||||||
|
BaseSuite
|
||||||
func (ep *ErrorPagesSuite) SetUpSuite(c *check.C) {
|
ErrorPageIP string
|
||||||
ep.createComposeProject(c, "error_pages")
|
BackendIP string
|
||||||
ep.composeProject.Start(c)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ep *ErrorPagesSuite) TestSimpleConfiguration(c *check.C) {
|
func (s *ErrorPagesSuite) SetUpSuite(c *check.C) {
|
||||||
|
s.createComposeProject(c, "error_pages")
|
||||||
|
s.composeProject.Start(c)
|
||||||
|
|
||||||
errorPageHost := ep.composeProject.Container(c, "nginx2").NetworkSettings.IPAddress
|
s.ErrorPageIP = s.composeProject.Container(c, "nginx2").NetworkSettings.IPAddress
|
||||||
backendHost := ep.composeProject.Container(c, "nginx1").NetworkSettings.IPAddress
|
s.BackendIP = s.composeProject.Container(c, "nginx1").NetworkSettings.IPAddress
|
||||||
|
}
|
||||||
|
|
||||||
file := ep.adaptFile(c, "fixtures/error_pages/simple.toml", struct {
|
func (s *ErrorPagesSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
|
|
||||||
|
file := s.adaptFile(c, "fixtures/error_pages/simple.toml", struct {
|
||||||
Server1 string
|
Server1 string
|
||||||
Server2 string
|
Server2 string
|
||||||
}{backendHost, errorPageHost})
|
}{s.BackendIP, s.ErrorPageIP})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
|
||||||
|
|
||||||
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -43,19 +46,16 @@ func (ep *ErrorPagesSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ep *ErrorPagesSuite) TestErrorPage(c *check.C) {
|
func (s *ErrorPagesSuite) TestErrorPage(c *check.C) {
|
||||||
|
|
||||||
errorPageHost := ep.composeProject.Container(c, "nginx2").NetworkSettings.IPAddress
|
|
||||||
backendHost := ep.composeProject.Container(c, "nginx1").NetworkSettings.IPAddress
|
|
||||||
|
|
||||||
//error.toml contains a mis-configuration of the backend host
|
//error.toml contains a mis-configuration of the backend host
|
||||||
file := ep.adaptFile(c, "fixtures/error_pages/error.toml", struct {
|
file := s.adaptFile(c, "fixtures/error_pages/error.toml", struct {
|
||||||
Server1 string
|
Server1 string
|
||||||
Server2 string
|
Server2 string
|
||||||
}{backendHost, errorPageHost})
|
}{s.BackendIP, s.ErrorPageIP})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
|
||||||
|
|
||||||
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -61,9 +60,11 @@ func (s *EtcdSuite) TearDownSuite(c *check.C) {}
|
||||||
|
|
||||||
func (s *EtcdSuite) TestSimpleConfiguration(c *check.C) {
|
func (s *EtcdSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
etcdHost := s.composeProject.Container(c, "etcd").NetworkSettings.IPAddress
|
etcdHost := s.composeProject.Container(c, "etcd").NetworkSettings.IPAddress
|
||||||
|
|
||||||
file := s.adaptFile(c, "fixtures/etcd/simple.toml", struct{ EtcdHost string }{etcdHost})
|
file := s.adaptFile(c, "fixtures/etcd/simple.toml", struct{ EtcdHost string }{etcdHost})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
|
||||||
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -76,9 +77,11 @@ func (s *EtcdSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
|
|
||||||
func (s *EtcdSuite) TestNominalConfiguration(c *check.C) {
|
func (s *EtcdSuite) TestNominalConfiguration(c *check.C) {
|
||||||
etcdHost := s.composeProject.Container(c, "etcd").NetworkSettings.IPAddress
|
etcdHost := s.composeProject.Container(c, "etcd").NetworkSettings.IPAddress
|
||||||
|
|
||||||
file := s.adaptFile(c, "fixtures/etcd/simple.toml", struct{ EtcdHost string }{etcdHost})
|
file := s.adaptFile(c, "fixtures/etcd/simple.toml", struct{ EtcdHost string }{etcdHost})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
|
||||||
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -196,8 +199,10 @@ func (s *EtcdSuite) TestGlobalConfiguration(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// start traefik
|
// start traefik
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/simple_web.toml", "--etcd", "--etcd.endpoint="+etcdHost+":4001")
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
|
"--etcd",
|
||||||
|
"--etcd.endpoint="+etcdHost+":4001")
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -273,7 +278,10 @@ func (s *EtcdSuite) TestGlobalConfiguration(c *check.C) {
|
||||||
func (s *EtcdSuite) TestCertificatesContentstWithSNIConfigHandshake(c *check.C) {
|
func (s *EtcdSuite) TestCertificatesContentstWithSNIConfigHandshake(c *check.C) {
|
||||||
etcdHost := s.composeProject.Container(c, "etcd").NetworkSettings.IPAddress
|
etcdHost := s.composeProject.Container(c, "etcd").NetworkSettings.IPAddress
|
||||||
// start traefik
|
// start traefik
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/simple_web.toml", "--etcd", "--etcd.endpoint="+etcdHost+":4001")
|
cmd, _ := s.cmdTraefik(
|
||||||
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
|
"--etcd",
|
||||||
|
"--etcd.endpoint="+etcdHost+":4001")
|
||||||
|
|
||||||
whoami1IP := s.composeProject.Container(c, "whoami1").NetworkSettings.IPAddress
|
whoami1IP := s.composeProject.Container(c, "whoami1").NetworkSettings.IPAddress
|
||||||
whoami2IP := s.composeProject.Container(c, "whoami2").NetworkSettings.IPAddress
|
whoami2IP := s.composeProject.Container(c, "whoami2").NetworkSettings.IPAddress
|
||||||
|
@ -378,7 +386,10 @@ func (s *EtcdSuite) TestCertificatesContentstWithSNIConfigHandshake(c *check.C)
|
||||||
func (s *EtcdSuite) TestCommandStoreConfig(c *check.C) {
|
func (s *EtcdSuite) TestCommandStoreConfig(c *check.C) {
|
||||||
etcdHost := s.composeProject.Container(c, "etcd").NetworkSettings.IPAddress
|
etcdHost := s.composeProject.Container(c, "etcd").NetworkSettings.IPAddress
|
||||||
|
|
||||||
cmd := exec.Command(traefikBinary, "storeconfig", "--configFile=fixtures/simple_web.toml", "--etcd.endpoint="+etcdHost+":4001")
|
cmd, _ := s.cmdTraefik(
|
||||||
|
"storeconfig",
|
||||||
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
|
"--etcd.endpoint="+etcdHost+":4001")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
@ -41,7 +40,7 @@ func (s *EurekaSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
|
|
||||||
file := s.adaptFile(c, "fixtures/eureka/simple.toml", struct{ EurekaHost string }{s.eurekaIP})
|
file := s.adaptFile(c, "fixtures/eureka/simple.toml", struct{ EurekaHost string }{s.eurekaIP})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -2,7 +2,6 @@ package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/exec"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
|
@ -20,7 +19,7 @@ func (s *FileSuite) SetUpSuite(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/file/simple.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/file/simple.toml"))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -32,7 +31,7 @@ func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
|
|
||||||
// #56 regression test, make sure it does not fail
|
// #56 regression test, make sure it does not fail
|
||||||
func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
|
func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/file/56-simple-panic.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/file/56-simple-panic.toml"))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -43,7 +42,7 @@ func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FileSuite) TestDirectoryConfiguration(c *check.C) {
|
func (s *FileSuite) TestDirectoryConfiguration(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/file/directory.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/file/directory.toml"))
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
|
@ -30,8 +29,8 @@ func (s *HealthCheckSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
Server2 string
|
Server2 string
|
||||||
}{whoami1Host, whoami2Host})
|
}{whoami1Host, whoami2Host})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
|
||||||
|
|
||||||
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -20,7 +20,7 @@ type HTTPSSuite struct{ BaseSuite }
|
||||||
// "snitest.com", which happens to match the CN of 'snitest.com.crt'. The test
|
// "snitest.com", which happens to match the CN of 'snitest.com.crt'. The test
|
||||||
// verifies that traefik presents the correct certificate.
|
// verifies that traefik presents the correct certificate.
|
||||||
func (s *HTTPSSuite) TestWithSNIConfigHandshake(c *check.C) {
|
func (s *HTTPSSuite) TestWithSNIConfigHandshake(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefikWithConfigFile("fixtures/https/https_sni.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/https/https_sni.toml"))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -53,7 +53,7 @@ func (s *HTTPSSuite) TestWithSNIConfigHandshake(c *check.C) {
|
||||||
// SNI hostnames of "snitest.org" and "snitest.com". The test verifies
|
// SNI hostnames of "snitest.org" and "snitest.com". The test verifies
|
||||||
// that traefik routes the requests to the expected backends.
|
// that traefik routes the requests to the expected backends.
|
||||||
func (s *HTTPSSuite) TestWithSNIConfigRoute(c *check.C) {
|
func (s *HTTPSSuite) TestWithSNIConfigRoute(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefikWithConfigFile("fixtures/https/https_sni.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/https/https_sni.toml"))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -111,7 +111,7 @@ func (s *HTTPSSuite) TestWithSNIConfigRoute(c *check.C) {
|
||||||
// TestWithClientCertificateAuthentication
|
// TestWithClientCertificateAuthentication
|
||||||
// The client has to send a certificate signed by a CA trusted by the server
|
// The client has to send a certificate signed by a CA trusted by the server
|
||||||
func (s *HTTPSSuite) TestWithClientCertificateAuthentication(c *check.C) {
|
func (s *HTTPSSuite) TestWithClientCertificateAuthentication(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefikWithConfigFile("fixtures/https/clientca/https_1ca1config.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/https/clientca/https_1ca1config.toml"))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -157,7 +157,7 @@ func (s *HTTPSSuite) TestWithClientCertificateAuthentication(c *check.C) {
|
||||||
// TestWithClientCertificateAuthentication
|
// TestWithClientCertificateAuthentication
|
||||||
// Use two CA:s and test that clients with client signed by either of them can connect
|
// Use two CA:s and test that clients with client signed by either of them can connect
|
||||||
func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipeCAs(c *check.C) {
|
func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipeCAs(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefikWithConfigFile("fixtures/https/clientca/https_2ca1config.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/https/clientca/https_2ca1config.toml"))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -216,7 +216,7 @@ func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipeCAs(c *check.
|
||||||
// TestWithClientCertificateAuthentication
|
// TestWithClientCertificateAuthentication
|
||||||
// Use two CA:s in two different files and test that clients with client signed by either of them can connect
|
// Use two CA:s in two different files and test that clients with client signed by either of them can connect
|
||||||
func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipeCAsMultipleFiles(c *check.C) {
|
func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipeCAsMultipleFiles(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefikWithConfigFile("fixtures/https/clientca/https_2ca2config.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/https/clientca/https_2ca2config.toml"))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -280,7 +280,7 @@ func (s *HTTPSSuite) TestWithRootCAsContentForHTTPSOnBackend(c *check.C) {
|
||||||
|
|
||||||
file := s.adaptFile(c, "fixtures/https/rootcas/https.toml", struct{ BackendHost string }{backend.URL})
|
file := s.adaptFile(c, "fixtures/https/rootcas/https.toml", struct{ BackendHost string }{backend.URL})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd, _ := s.cmdTraefikWithConfigFile(file)
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -301,7 +301,7 @@ func (s *HTTPSSuite) TestWithRootCAsFileForHTTPSOnBackend(c *check.C) {
|
||||||
|
|
||||||
file := s.adaptFile(c, "fixtures/https/rootcas/https_with_file.toml", struct{ BackendHost string }{backend.URL})
|
file := s.adaptFile(c, "fixtures/https/rootcas/https_with_file.toml", struct{ BackendHost string }{backend.URL})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd, _ := s.cmdTraefikWithConfigFile(file)
|
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/utils"
|
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
compose "github.com/libkermit/compose/check"
|
compose "github.com/libkermit/compose/check"
|
||||||
checker "github.com/vdemeester/shakers"
|
checker "github.com/vdemeester/shakers"
|
||||||
|
@ -72,15 +71,8 @@ func (s *BaseSuite) createComposeProject(c *check.C, name string) {
|
||||||
s.composeProject = compose.CreateProject(c, projectName, composeFile)
|
s.composeProject = compose.CreateProject(c, projectName, composeFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: unused
|
func withConfigFile(file string) string {
|
||||||
func (s *BaseSuite) traefikCmd(c *check.C, args ...string) (*exec.Cmd, string) {
|
return "--configFile=" + file
|
||||||
cmd, out, err := utils.RunCommand(traefikBinary, args...)
|
|
||||||
c.Assert(err, checker.IsNil, check.Commentf("Fail to run %s with %v", traefikBinary, args))
|
|
||||||
return cmd, out
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *BaseSuite) cmdTraefikWithConfigFile(file string) (*exec.Cmd, *bytes.Buffer) {
|
|
||||||
return s.cmdTraefik("--configFile=" + file)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *BaseSuite) cmdTraefik(args ...string) (*exec.Cmd, *bytes.Buffer) {
|
func (s *BaseSuite) cmdTraefik(args ...string) (*exec.Cmd, *bytes.Buffer) {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/exec"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
|
@ -41,7 +40,7 @@ func (s *MarathonSuite) SetUpSuite(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) {
|
func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/marathon/simple.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/marathon/simple.toml"))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -2,7 +2,6 @@ package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/exec"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
|
@ -18,7 +17,7 @@ func (s *MesosSuite) SetUpSuite(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MesosSuite) TestSimpleConfiguration(c *check.C) {
|
func (s *MesosSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "--configFile=fixtures/mesos/simple.toml")
|
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/mesos/simple.toml"))
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os/exec"
|
|
||||||
)
|
|
||||||
|
|
||||||
var execCommand = exec.Command
|
|
||||||
|
|
||||||
// RunCommand runs the specified command with arguments and returns
|
|
||||||
// the output and the error if any.
|
|
||||||
func RunCommand(binary string, args ...string) (*exec.Cmd, string, error) {
|
|
||||||
cmd := execCommand(binary, args...)
|
|
||||||
out, err := cmd.CombinedOutput()
|
|
||||||
output := string(out)
|
|
||||||
return cmd, output, err
|
|
||||||
}
|
|
|
@ -1,89 +0,0 @@
|
||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
var traefikBinary = "traefik"
|
|
||||||
|
|
||||||
func TestRunCommand(t *testing.T) {
|
|
||||||
// Override exec.Command :D
|
|
||||||
execCommand = fakeExecCommand
|
|
||||||
_, output, err := RunCommand(traefikBinary, "it", "works")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if output != "it works" {
|
|
||||||
t.Fatalf("Expected 'it works' as output, got : %q", output)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRunCommandError(t *testing.T) {
|
|
||||||
// Override exec.Command :D
|
|
||||||
execCommand = fakeExecCommand
|
|
||||||
_, output, err := RunCommand(traefikBinary, "an", "error")
|
|
||||||
if err == nil {
|
|
||||||
t.Fatalf("Expected an error, got %q", output)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helpers :)
|
|
||||||
|
|
||||||
// Type implementing the io.Writer interface for analyzing output.
|
|
||||||
type String struct {
|
|
||||||
value string
|
|
||||||
}
|
|
||||||
|
|
||||||
// The only function required by the io.Writer interface. Will append
|
|
||||||
// written data to the String.value string.
|
|
||||||
func (s *String) Write(p []byte) (n int, err error) {
|
|
||||||
s.value += string(p)
|
|
||||||
return len(p), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function that mock the exec.Command call (and call the test binary)
|
|
||||||
func fakeExecCommand(command string, args ...string) *exec.Cmd {
|
|
||||||
cs := []string{"-test.run=TestHelperProcess", "--", command}
|
|
||||||
cs = append(cs, args...)
|
|
||||||
cmd := exec.Command(os.Args[0], cs...)
|
|
||||||
cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"}
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHelperProcess(t *testing.T) {
|
|
||||||
if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
args := os.Args
|
|
||||||
|
|
||||||
// Previous arguments are tests stuff, that looks like :
|
|
||||||
// /tmp/go-build970079519/…/_test/integration.test -test.run=TestHelperProcess --
|
|
||||||
cmd, args := args[3], args[4:]
|
|
||||||
// Handle the case where args[0] is dir:...
|
|
||||||
|
|
||||||
switch cmd {
|
|
||||||
case traefikBinary:
|
|
||||||
argsStr := strings.Join(args, " ")
|
|
||||||
switch argsStr {
|
|
||||||
case "an exitCode 127":
|
|
||||||
fmt.Fprint(os.Stderr, "an error has occurred with exitCode 127")
|
|
||||||
os.Exit(127)
|
|
||||||
case "an error":
|
|
||||||
fmt.Fprint(os.Stderr, "an error has occurred")
|
|
||||||
os.Exit(1)
|
|
||||||
case "it works":
|
|
||||||
fmt.Fprint(os.Stdout, "it works")
|
|
||||||
default:
|
|
||||||
fmt.Fprint(os.Stdout, "no arguments")
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
fmt.Fprintf(os.Stderr, "Command %s not found.", cmd)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
// some code here to check arguments perhaps?
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
|
@ -18,12 +18,13 @@ type IPWhitelister struct {
|
||||||
|
|
||||||
// NewIPWhitelister builds a new IPWhitelister given a list of CIDR-Strings to whitelist
|
// NewIPWhitelister builds a new IPWhitelister given a list of CIDR-Strings to whitelist
|
||||||
func NewIPWhitelister(whitelistStrings []string) (*IPWhitelister, error) {
|
func NewIPWhitelister(whitelistStrings []string) (*IPWhitelister, error) {
|
||||||
whitelister := IPWhitelister{}
|
|
||||||
|
|
||||||
if len(whitelistStrings) == 0 {
|
if len(whitelistStrings) == 0 {
|
||||||
return nil, errors.New("no whitelists provided")
|
return nil, errors.New("no whitelists provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
whitelister := IPWhitelister{}
|
||||||
|
|
||||||
for _, whitelistString := range whitelistStrings {
|
for _, whitelistString := range whitelistStrings {
|
||||||
_, whitelist, err := net.ParseCIDR(whitelistString)
|
_, whitelist, err := net.ParseCIDR(whitelistString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -65,6 +66,7 @@ func reject(w http.ResponseWriter) {
|
||||||
w.WriteHeader(statusCode)
|
w.WriteHeader(statusCode)
|
||||||
w.Write([]byte(http.StatusText(statusCode)))
|
w.Write([]byte(http.StatusText(statusCode)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ipFromRemoteAddr(addr string) (*net.IP, error) {
|
func ipFromRemoteAddr(addr string) (*net.IP, error) {
|
||||||
ip, _, err := net.SplitHostPort(addr)
|
ip, _, err := net.SplitHostPort(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue