Display Traefik logs in integration test
This commit is contained in:
parent
5305a16350
commit
bdeb7bfb9f
23 changed files with 147 additions and 94 deletions
|
@ -178,7 +178,7 @@ func (dc *DomainsCertificates) renewCertificates(acmeCert *Certificate, domain D
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Errorf("Certificate to renew not found for domain %s", domain.Main)
|
return fmt.Errorf("certificate to renew not found for domain %s", domain.Main)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *DomainsCertificates) addCertificateForDomains(acmeCert *Certificate, domain Domain) (*DomainsCertificate, error) {
|
func (dc *DomainsCertificates) addCertificateForDomains(acmeCert *Certificate, domain Domain) (*DomainsCertificate, error) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ func (c *challengeProvider) getCertificate(domain string) (cert *tls.Certificate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Errorf("Cannot find challenge cert for domain %s", domain)
|
return fmt.Errorf("cannot find challenge cert for domain %s", domain)
|
||||||
}
|
}
|
||||||
notify := func(err error, time time.Duration) {
|
notify := func(err error, time time.Duration) {
|
||||||
log.Errorf("Error getting cert: %v, retrying in %s", err, time)
|
log.Errorf("Error getting cert: %v, retrying in %s", err, time)
|
||||||
|
|
|
@ -16,7 +16,7 @@ Given the complexity of the subject, it is possible that the heuristic fails.
|
||||||
Apart from filing an issue and waiting for the feature request / bug report to get addressed, one workaround for such situations is to customize the Marathon template file to the individual needs.
|
Apart from filing an issue and waiting for the feature request / bug report to get addressed, one workaround for such situations is to customize the Marathon template file to the individual needs.
|
||||||
|
|
||||||
!!! note
|
!!! note
|
||||||
This does _not_ require rebuilding Traefik but only to point the `filename` configuration parameter to a customized version of the `marathon.tmpl` file on Traefik startup.
|
This does _not_ require rebuilding Traefik but only to point the `filename` configuration parameter to a customized version of the `marathon.tmpl` file on Traefik startup.
|
||||||
|
|
||||||
## Port detection
|
## Port detection
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ func (s *AccessLogSuite) TestAccessLog(c *check.C) {
|
||||||
os.Remove(traefikTestLogFile)
|
os.Remove(traefikTestLogFile)
|
||||||
|
|
||||||
// Start Traefik
|
// Start Traefik
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/access_log_config.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/access_log_config.toml"))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containous/traefik/integration/try"
|
"github.com/containous/traefik/integration/try"
|
||||||
|
@ -101,8 +102,10 @@ func (s *AcmeSuite) retrieveAcmeCertificate(c *check.C, testCase AcmeTestCase) {
|
||||||
OnDemand: testCase.onDemand,
|
OnDemand: testCase.onDemand,
|
||||||
OnHostRule: !testCase.onDemand,
|
OnHostRule: !testCase.onDemand,
|
||||||
})
|
})
|
||||||
|
defer os.Remove(file)
|
||||||
|
|
||||||
cmd, output := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -120,8 +123,6 @@ func (s *AcmeSuite) retrieveAcmeCertificate(c *check.C, testCase AcmeTestCase) {
|
||||||
_, err := client.Get("https://127.0.0.1:5001")
|
_, err := client.Get("https://127.0.0.1:5001")
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
// TODO: waiting a refactor of integration tests
|
|
||||||
s.displayTraefikLog(c, output)
|
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
tr = &http.Transport{
|
tr = &http.Transport{
|
||||||
|
|
|
@ -80,12 +80,13 @@ func (s *ConstraintSuite) deregisterService(name string, address string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestMatchConstraintGlobal(c *check.C) {
|
func (s *ConstraintSuite) TestMatchConstraintGlobal(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
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",
|
||||||
"--constraints=tag==api")
|
"--constraints=tag==api")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -105,12 +106,13 @@ func (s *ConstraintSuite) TestMatchConstraintGlobal(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestDoesNotMatchConstraintGlobal(c *check.C) {
|
func (s *ConstraintSuite) TestDoesNotMatchConstraintGlobal(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
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",
|
||||||
"--constraints=tag==api")
|
"--constraints=tag==api")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -130,12 +132,13 @@ func (s *ConstraintSuite) TestDoesNotMatchConstraintGlobal(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestMatchConstraintProvider(c *check.C) {
|
func (s *ConstraintSuite) TestMatchConstraintProvider(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
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",
|
||||||
"--consulCatalog.constraints=tag==api")
|
"--consulCatalog.constraints=tag==api")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -155,12 +158,13 @@ func (s *ConstraintSuite) TestMatchConstraintProvider(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestDoesNotMatchConstraintProvider(c *check.C) {
|
func (s *ConstraintSuite) TestDoesNotMatchConstraintProvider(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
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",
|
||||||
"--consulCatalog.constraints=tag==api")
|
"--consulCatalog.constraints=tag==api")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -180,13 +184,14 @@ func (s *ConstraintSuite) TestDoesNotMatchConstraintProvider(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestMatchMultipleConstraint(c *check.C) {
|
func (s *ConstraintSuite) TestMatchMultipleConstraint(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
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",
|
||||||
"--consulCatalog.constraints=tag==api",
|
"--consulCatalog.constraints=tag==api",
|
||||||
"--constraints=tag!=us-*")
|
"--constraints=tag!=us-*")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -206,13 +211,14 @@ func (s *ConstraintSuite) TestMatchMultipleConstraint(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConstraintSuite) TestDoesNotMatchMultipleConstraint(c *check.C) {
|
func (s *ConstraintSuite) TestDoesNotMatchMultipleConstraint(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
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",
|
||||||
"--consulCatalog.constraints=tag==api",
|
"--consulCatalog.constraints=tag==api",
|
||||||
"--constraints=tag!=us-*")
|
"--constraints=tag!=us-*")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -104,10 +104,11 @@ func (s *ConsulCatalogSuite) deregisterService(name string, address string) erro
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConsulCatalogSuite) TestSimpleConfiguration(c *check.C) {
|
func (s *ConsulCatalogSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500")
|
"--consulCatalog.endpoint="+s.consulIP+":8500")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -119,15 +120,20 @@ func (s *ConsulCatalogSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConsulCatalogSuite) TestSingleService(c *check.C) {
|
func (s *ConsulCatalogSuite) TestSingleService(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
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")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
||||||
|
// Wait for Traefik to turn ready.
|
||||||
|
err = try.GetRequest("http://127.0.0.1:8000/", 2*time.Second, try.StatusCodeIs(http.StatusNotFound))
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
nginx := s.composeProject.Container(c, "nginx1")
|
nginx := s.composeProject.Container(c, "nginx1")
|
||||||
|
|
||||||
err = s.registerService("test", nginx.NetworkSettings.IPAddress, 80, []string{})
|
err = s.registerService("test", nginx.NetworkSettings.IPAddress, 80, []string{})
|
||||||
|
@ -143,12 +149,13 @@ func (s *ConsulCatalogSuite) TestSingleService(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConsulCatalogSuite) TestExposedByDefaultFalseSingleService(c *check.C) {
|
func (s *ConsulCatalogSuite) TestExposedByDefaultFalseSingleService(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.exposedByDefault=false",
|
"--consulCatalog.exposedByDefault=false",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost")
|
"--consulCatalog.domain=consul.localhost")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -168,12 +175,13 @@ func (s *ConsulCatalogSuite) TestExposedByDefaultFalseSingleService(c *check.C)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConsulCatalogSuite) TestExposedByDefaultFalseSimpleServiceMultipleNode(c *check.C) {
|
func (s *ConsulCatalogSuite) TestExposedByDefaultFalseSimpleServiceMultipleNode(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.exposedByDefault=false",
|
"--consulCatalog.exposedByDefault=false",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost")
|
"--consulCatalog.domain=consul.localhost")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -198,12 +206,13 @@ func (s *ConsulCatalogSuite) TestExposedByDefaultFalseSimpleServiceMultipleNode(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConsulCatalogSuite) TestExposedByDefaultTrueSimpleServiceMultipleNode(c *check.C) {
|
func (s *ConsulCatalogSuite) TestExposedByDefaultTrueSimpleServiceMultipleNode(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.exposedByDefault=true",
|
"--consulCatalog.exposedByDefault=true",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost")
|
"--consulCatalog.domain=consul.localhost")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -232,12 +241,13 @@ func (s *ConsulCatalogSuite) TestExposedByDefaultTrueSimpleServiceMultipleNode(c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConsulCatalogSuite) TestRefreshConfigWithMultipleNodeWithoutHealthCheck(c *check.C) {
|
func (s *ConsulCatalogSuite) TestRefreshConfigWithMultipleNodeWithoutHealthCheck(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.exposedByDefault=true",
|
"--consulCatalog.exposedByDefault=true",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost")
|
"--consulCatalog.domain=consul.localhost")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -283,20 +293,17 @@ func (s *ConsulCatalogSuite) TestRefreshConfigWithMultipleNodeWithoutHealthCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ConsulCatalogSuite) TestBasicAuthSimpleService(c *check.C) {
|
func (s *ConsulCatalogSuite) TestBasicAuthSimpleService(c *check.C) {
|
||||||
cmd, output := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
withConfigFile("fixtures/consul_catalog/simple.toml"),
|
||||||
"--consulCatalog",
|
"--consulCatalog",
|
||||||
"--consulCatalog.exposedByDefault=true",
|
"--consulCatalog.exposedByDefault=true",
|
||||||
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
"--consulCatalog.endpoint="+s.consulIP+":8500",
|
||||||
"--consulCatalog.domain=consul.localhost")
|
"--consulCatalog.domain=consul.localhost")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
||||||
defer func() {
|
|
||||||
s.displayTraefikLog(c, output)
|
|
||||||
}()
|
|
||||||
|
|
||||||
nginx := s.composeProject.Container(c, "nginx1")
|
nginx := s.composeProject.Container(c, "nginx1")
|
||||||
|
|
||||||
err = s.registerService("test", nginx.NetworkSettings.IPAddress, 80, []string{
|
err = s.registerService("test", nginx.NetworkSettings.IPAddress, 80, []string{
|
||||||
|
|
|
@ -95,7 +95,8 @@ 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, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
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 +112,8 @@ 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, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -210,10 +212,11 @@ func (s *ConsulSuite) TestGlobalConfiguration(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// start traefik
|
// start traefik
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/simple_web.toml"),
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
"--consul",
|
"--consul",
|
||||||
"--consul.endpoint="+consulHost+":8500")
|
"--consul.endpoint="+consulHost+":8500")
|
||||||
|
defer display(c)
|
||||||
|
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -297,7 +300,7 @@ func (s *ConsulSuite) skipTestGlobalConfigurationWithClientTLS(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// start traefik
|
// start traefik
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/simple_web.toml"),
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
"--consul",
|
"--consul",
|
||||||
"--consul.endpoint="+consulHost+":8585",
|
"--consul.endpoint="+consulHost+":8585",
|
||||||
|
@ -305,6 +308,7 @@ func (s *ConsulSuite) skipTestGlobalConfigurationWithClientTLS(c *check.C) {
|
||||||
"--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",
|
||||||
"--consul.tls.insecureskipverify")
|
"--consul.tls.insecureskipverify")
|
||||||
|
defer display(c)
|
||||||
|
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
@ -319,10 +323,11 @@ 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, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
"storeconfig",
|
"storeconfig",
|
||||||
withConfigFile("fixtures/simple_web.toml"),
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
"--consul.endpoint="+consulHost+":8500")
|
"--consul.endpoint="+consulHost+":8500")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,8 @@ 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, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
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,7 +97,8 @@ 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, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -128,7 +130,8 @@ 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, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -160,7 +163,8 @@ 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, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -147,7 +147,8 @@ 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, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -33,7 +33,8 @@ func (s *ErrorPagesSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
}{s.BackendIP, s.ErrorPageIP})
|
}{s.BackendIP, s.ErrorPageIP})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -55,7 +56,8 @@ func (s *ErrorPagesSuite) TestErrorPage(c *check.C) {
|
||||||
}{s.BackendIP, s.ErrorPageIP})
|
}{s.BackendIP, s.ErrorPageIP})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -64,7 +64,8 @@ func (s *EtcdSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
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, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -81,7 +82,8 @@ func (s *EtcdSuite) TestNominalConfiguration(c *check.C) {
|
||||||
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, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -200,10 +202,11 @@ func (s *EtcdSuite) TestGlobalConfiguration(c *check.C) {
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// start traefik
|
// start traefik
|
||||||
cmd, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/simple_web.toml"),
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
"--etcd",
|
"--etcd",
|
||||||
"--etcd.endpoint="+etcdHost+":4001")
|
"--etcd.endpoint="+etcdHost+":4001")
|
||||||
|
defer display(c)
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -279,10 +282,11 @@ 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, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
withConfigFile("fixtures/simple_web.toml"),
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
"--etcd",
|
"--etcd",
|
||||||
"--etcd.endpoint="+etcdHost+":4001")
|
"--etcd.endpoint="+etcdHost+":4001")
|
||||||
|
defer display(c)
|
||||||
|
|
||||||
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
|
||||||
|
@ -387,10 +391,11 @@ 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, _ := s.cmdTraefik(
|
cmd, display := s.traefikCmd(
|
||||||
"storeconfig",
|
"storeconfig",
|
||||||
withConfigFile("fixtures/simple_web.toml"),
|
withConfigFile("fixtures/simple_web.toml"),
|
||||||
"--etcd.endpoint="+etcdHost+":4001")
|
"--etcd.endpoint="+etcdHost+":4001")
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,8 @@ 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, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -19,7 +19,8 @@ func (s *FileSuite) SetUpSuite(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/file/simple.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/file/simple.toml"))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -31,7 +32,8 @@ 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, _ := s.cmdTraefik(withConfigFile("fixtures/file/56-simple-panic.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/file/56-simple-panic.toml"))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -42,8 +44,8 @@ func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FileSuite) TestDirectoryConfiguration(c *check.C) {
|
func (s *FileSuite) TestDirectoryConfiguration(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/file/directory.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/file/directory.toml"))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -24,7 +24,7 @@ type GRPCSuite struct{ BaseSuite }
|
||||||
|
|
||||||
type myserver struct{}
|
type myserver struct{}
|
||||||
|
|
||||||
func (suite *GRPCSuite) SetUpSuite(c *check.C) {
|
func (s *GRPCSuite) SetUpSuite(c *check.C) {
|
||||||
var err error
|
var err error
|
||||||
LocalhostCert, err = ioutil.ReadFile("./resources/tls/local.cert")
|
LocalhostCert, err = ioutil.ReadFile("./resources/tls/local.cert")
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
@ -72,7 +72,7 @@ func callHelloClientGRPC() (string, error) {
|
||||||
return r.Message, nil
|
return r.Message, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *GRPCSuite) TestGRPC(c *check.C) {
|
func (s *GRPCSuite) TestGRPC(c *check.C) {
|
||||||
lis, err := net.Listen("tcp", ":0")
|
lis, err := net.Listen("tcp", ":0")
|
||||||
_, port, err := net.SplitHostPort(lis.Addr().String())
|
_, port, err := net.SplitHostPort(lis.Addr().String())
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
@ -83,7 +83,7 @@ func (suite *GRPCSuite) TestGRPC(c *check.C) {
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
file := suite.adaptFile(c, "fixtures/grpc/config.toml", struct {
|
file := s.adaptFile(c, "fixtures/grpc/config.toml", struct {
|
||||||
CertContent string
|
CertContent string
|
||||||
KeyContent string
|
KeyContent string
|
||||||
GRPCServerPort string
|
GRPCServerPort string
|
||||||
|
@ -94,7 +94,8 @@ func (suite *GRPCSuite) TestGRPC(c *check.C) {
|
||||||
})
|
})
|
||||||
|
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd, _ := suite.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
|
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
|
@ -34,7 +34,8 @@ func (s *HealthCheckSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
}{s.whoami1IP, s.whoami2IP})
|
}{s.whoami1IP, s.whoami2IP})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
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 +113,8 @@ func (s *HealthCheckSuite) doTestMultipleEntrypoints(c *check.C, fixture string)
|
||||||
}{s.whoami1IP, s.whoami2IP})
|
}{s.whoami1IP, s.whoami2IP})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
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,8 @@ 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.cmdTraefik(withConfigFile("fixtures/https/https_sni.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_sni.toml"))
|
||||||
|
defer display(c)
|
||||||
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 +54,8 @@ 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.cmdTraefik(withConfigFile("fixtures/https/https_sni.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/https_sni.toml"))
|
||||||
|
defer display(c)
|
||||||
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 +113,8 @@ 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.cmdTraefik(withConfigFile("fixtures/https/clientca/https_1ca1config.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/clientca/https_1ca1config.toml"))
|
||||||
|
defer display(c)
|
||||||
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 +160,8 @@ 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.cmdTraefik(withConfigFile("fixtures/https/clientca/https_2ca1config.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/clientca/https_2ca1config.toml"))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -217,7 +221,8 @@ 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.cmdTraefik(withConfigFile("fixtures/https/clientca/https_2ca2config.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/https/clientca/https_2ca2config.toml"))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -281,7 +286,8 @@ 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.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -302,7 +308,8 @@ 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.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
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,6 +12,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/containous/traefik/log"
|
||||||
"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"
|
||||||
|
@ -87,12 +88,21 @@ func (s *BaseSuite) cmdTraefik(args ...string) (*exec.Cmd, *bytes.Buffer) {
|
||||||
return cmd, &out
|
return cmd, &out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *BaseSuite) traefikCmd(args ...string) (*exec.Cmd, func(*check.C)) {
|
||||||
|
cmd, out := s.cmdTraefik(args...)
|
||||||
|
return cmd, func(c *check.C) {
|
||||||
|
if c.Failed() {
|
||||||
|
s.displayTraefikLog(c, out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *BaseSuite) displayTraefikLog(c *check.C, output *bytes.Buffer) {
|
func (s *BaseSuite) displayTraefikLog(c *check.C, output *bytes.Buffer) {
|
||||||
if output == nil || output.Len() == 0 {
|
if output == nil || output.Len() == 0 {
|
||||||
fmt.Printf("%s: No Traefik logs present.", c.TestName())
|
log.Printf("%s: No Traefik logs.", c.TestName())
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s: Traefik logs: ", c.TestName())
|
log.Printf("%s: Traefik logs: ", c.TestName())
|
||||||
fmt.Println(output.String())
|
log.Println(output.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,8 @@ type LogRotationSuite struct{ BaseSuite }
|
||||||
|
|
||||||
func (s *LogRotationSuite) TestAccessLogRotation(c *check.C) {
|
func (s *LogRotationSuite) TestAccessLogRotation(c *check.C) {
|
||||||
// Start Traefik
|
// Start Traefik
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/access_log_config.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/access_log_config.toml"))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -68,7 +69,8 @@ func (s *LogRotationSuite) TestAccessLogRotation(c *check.C) {
|
||||||
|
|
||||||
func (s *LogRotationSuite) TestTraefikLogRotation(c *check.C) {
|
func (s *LogRotationSuite) TestTraefikLogRotation(c *check.C) {
|
||||||
// Start Traefik
|
// Start Traefik
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/traefik_log_config.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/traefik_log_config.toml"))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -88,7 +88,8 @@ func (s *MarathonSuite) TestConfigurationUpdate(c *check.C) {
|
||||||
MarathonURL string
|
MarathonURL string
|
||||||
}{s.marathonURL})
|
}{s.marathonURL})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd, output := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
@ -103,16 +104,6 @@ func (s *MarathonSuite) TestConfigurationUpdate(c *check.C) {
|
||||||
client, err := marathon.NewClient(config)
|
client, err := marathon.NewClient(config)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
// Show the Traefik log if any assertion fails. If the entire test runs
|
|
||||||
// to a successful completion, we flip the flag at the very end and don't
|
|
||||||
// display anything.
|
|
||||||
showTraefikLog := true
|
|
||||||
defer func() {
|
|
||||||
if showTraefikLog {
|
|
||||||
s.displayTraefikLog(c, output)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Create test application to be deployed.
|
// Create test application to be deployed.
|
||||||
app := marathon.NewDockerApplication().
|
app := marathon.NewDockerApplication().
|
||||||
Name("/whoami").
|
Name("/whoami").
|
||||||
|
@ -146,6 +137,4 @@ func (s *MarathonSuite) TestConfigurationUpdate(c *check.C) {
|
||||||
// Query application via Traefik.
|
// Query application via Traefik.
|
||||||
err = try.GetRequest("http://127.0.0.1:8000/app", 30*time.Second, try.StatusCodeIs(http.StatusOK))
|
err = try.GetRequest("http://127.0.0.1:8000/app", 30*time.Second, try.StatusCodeIs(http.StatusOK))
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
showTraefikLog = false
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ func (s *MesosSuite) SetUpSuite(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MesosSuite) TestSimpleConfiguration(c *check.C) {
|
func (s *MesosSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/mesos/simple.toml"))
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/mesos/simple.toml"))
|
||||||
|
defer display(c)
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
defer cmd.Process.Kill()
|
defer cmd.Process.Kill()
|
||||||
|
|
|
@ -24,7 +24,8 @@ func (s *TimeoutSuite) TestForwardingTimeouts(c *check.C) {
|
||||||
}{httpTimeoutEndpoint})
|
}{httpTimeoutEndpoint})
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
|
|
||||||
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
||||||
|
defer display(c)
|
||||||
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 @@ import (
|
||||||
// WebsocketSuite
|
// WebsocketSuite
|
||||||
type WebsocketSuite struct{ BaseSuite }
|
type WebsocketSuite struct{ BaseSuite }
|
||||||
|
|
||||||
func (suite *WebsocketSuite) TestBase(c *check.C) {
|
func (s *WebsocketSuite) TestBase(c *check.C) {
|
||||||
var upgrader = gorillawebsocket.Upgrader{} // use default options
|
var upgrader = gorillawebsocket.Upgrader{} // use default options
|
||||||
|
|
||||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -41,14 +41,15 @@ func (suite *WebsocketSuite) TestBase(c *check.C) {
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
file := suite.adaptFile(c, "fixtures/websocket/config.toml", struct {
|
file := s.adaptFile(c, "fixtures/websocket/config.toml", struct {
|
||||||
WebsocketServer string
|
WebsocketServer string
|
||||||
}{
|
}{
|
||||||
WebsocketServer: srv.URL,
|
WebsocketServer: srv.URL,
|
||||||
})
|
})
|
||||||
|
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd, _ := suite.cmdTraefik(withConfigFile(file), "--debug")
|
cmd, display := s.traefikCmd(withConfigFile(file), "--debug")
|
||||||
|
defer display(c)
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
@ -69,7 +70,7 @@ func (suite *WebsocketSuite) TestBase(c *check.C) {
|
||||||
c.Assert(string(msg), checker.Equals, "OK")
|
c.Assert(string(msg), checker.Equals, "OK")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *WebsocketSuite) TestWrongOrigin(c *check.C) {
|
func (s *WebsocketSuite) TestWrongOrigin(c *check.C) {
|
||||||
var upgrader = gorillawebsocket.Upgrader{} // use default options
|
var upgrader = gorillawebsocket.Upgrader{} // use default options
|
||||||
|
|
||||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -90,14 +91,15 @@ func (suite *WebsocketSuite) TestWrongOrigin(c *check.C) {
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
file := suite.adaptFile(c, "fixtures/websocket/config.toml", struct {
|
file := s.adaptFile(c, "fixtures/websocket/config.toml", struct {
|
||||||
WebsocketServer string
|
WebsocketServer string
|
||||||
}{
|
}{
|
||||||
WebsocketServer: srv.URL,
|
WebsocketServer: srv.URL,
|
||||||
})
|
})
|
||||||
|
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd, _ := suite.cmdTraefik(withConfigFile(file), "--debug")
|
cmd, display := s.traefikCmd(withConfigFile(file), "--debug")
|
||||||
|
defer display(c)
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
@ -117,7 +119,7 @@ func (suite *WebsocketSuite) TestWrongOrigin(c *check.C) {
|
||||||
c.Assert(err, checker.ErrorMatches, "bad status")
|
c.Assert(err, checker.ErrorMatches, "bad status")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *WebsocketSuite) TestOrigin(c *check.C) {
|
func (s *WebsocketSuite) TestOrigin(c *check.C) {
|
||||||
// use default options
|
// use default options
|
||||||
var upgrader = gorillawebsocket.Upgrader{}
|
var upgrader = gorillawebsocket.Upgrader{}
|
||||||
|
|
||||||
|
@ -139,14 +141,15 @@ func (suite *WebsocketSuite) TestOrigin(c *check.C) {
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
file := suite.adaptFile(c, "fixtures/websocket/config.toml", struct {
|
file := s.adaptFile(c, "fixtures/websocket/config.toml", struct {
|
||||||
WebsocketServer string
|
WebsocketServer string
|
||||||
}{
|
}{
|
||||||
WebsocketServer: srv.URL,
|
WebsocketServer: srv.URL,
|
||||||
})
|
})
|
||||||
|
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd, _ := suite.cmdTraefik(withConfigFile(file), "--debug")
|
cmd, display := s.traefikCmd(withConfigFile(file), "--debug")
|
||||||
|
defer display(c)
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
@ -176,7 +179,7 @@ func (suite *WebsocketSuite) TestOrigin(c *check.C) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *WebsocketSuite) TestWrongOriginIgnoredByServer(c *check.C) {
|
func (s *WebsocketSuite) TestWrongOriginIgnoredByServer(c *check.C) {
|
||||||
var upgrader = gorillawebsocket.Upgrader{CheckOrigin: func(r *http.Request) bool {
|
var upgrader = gorillawebsocket.Upgrader{CheckOrigin: func(r *http.Request) bool {
|
||||||
return true
|
return true
|
||||||
}}
|
}}
|
||||||
|
@ -199,14 +202,15 @@ func (suite *WebsocketSuite) TestWrongOriginIgnoredByServer(c *check.C) {
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
file := suite.adaptFile(c, "fixtures/websocket/config.toml", struct {
|
file := s.adaptFile(c, "fixtures/websocket/config.toml", struct {
|
||||||
WebsocketServer string
|
WebsocketServer string
|
||||||
}{
|
}{
|
||||||
WebsocketServer: srv.URL,
|
WebsocketServer: srv.URL,
|
||||||
})
|
})
|
||||||
|
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd, _ := suite.cmdTraefik(withConfigFile(file), "--debug")
|
cmd, display := s.traefikCmd(withConfigFile(file), "--debug")
|
||||||
|
defer display(c)
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
@ -236,7 +240,7 @@ func (suite *WebsocketSuite) TestWrongOriginIgnoredByServer(c *check.C) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *WebsocketSuite) TestSSLTermination(c *check.C) {
|
func (s *WebsocketSuite) TestSSLTermination(c *check.C) {
|
||||||
var upgrader = gorillawebsocket.Upgrader{} // use default options
|
var upgrader = gorillawebsocket.Upgrader{} // use default options
|
||||||
|
|
||||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -256,14 +260,15 @@ func (suite *WebsocketSuite) TestSSLTermination(c *check.C) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
file := suite.adaptFile(c, "fixtures/websocket/config_https.toml", struct {
|
file := s.adaptFile(c, "fixtures/websocket/config_https.toml", struct {
|
||||||
WebsocketServer string
|
WebsocketServer string
|
||||||
}{
|
}{
|
||||||
WebsocketServer: srv.URL,
|
WebsocketServer: srv.URL,
|
||||||
})
|
})
|
||||||
|
|
||||||
defer os.Remove(file)
|
defer os.Remove(file)
|
||||||
cmd, _ := suite.cmdTraefik(withConfigFile(file), "--debug")
|
cmd, display := s.traefikCmd(withConfigFile(file), "--debug")
|
||||||
|
defer display(c)
|
||||||
|
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
Loading…
Reference in a new issue