Updates and additions on some integration tests
- Use defer to kill traefik process (to fix the still running traefik binaries if the given tests is failing before the kill) - Add TestWithWebConfig - Add *.test to gitignore to ignore the test binaries generated by go. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
5ee6981410
commit
3c9ec55f0a
7 changed files with 28 additions and 19 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,5 +5,5 @@ log
|
||||||
*.iml
|
*.iml
|
||||||
traefik
|
traefik
|
||||||
traefik.toml
|
traefik.toml
|
||||||
|
*.test
|
||||||
vendor/
|
vendor/
|
||||||
|
|
|
@ -10,6 +10,9 @@ import (
|
||||||
check "gopkg.in/check.v1"
|
check "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SimpleSuite
|
||||||
|
type SimpleSuite struct{ BaseSuite }
|
||||||
|
|
||||||
func (s *SimpleSuite) TestNoOrInexistentConfigShouldFail(c *check.C) {
|
func (s *SimpleSuite) TestNoOrInexistentConfigShouldFail(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary)
|
cmd := exec.Command(traefikBinary)
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
|
@ -37,6 +40,7 @@ func (s *SimpleSuite) TestSimpleDefaultConfig(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "fixtures/simple_default.toml")
|
cmd := exec.Command(traefikBinary, "fixtures/simple_default.toml")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
defer cmd.Process.Kill()
|
||||||
|
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
// TODO validate : run on 80
|
// TODO validate : run on 80
|
||||||
|
@ -45,7 +49,18 @@ func (s *SimpleSuite) TestSimpleDefaultConfig(c *check.C) {
|
||||||
// Expected a 404 as we did not comfigure anything
|
// Expected a 404 as we did not comfigure anything
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(resp.StatusCode, checker.Equals, 404)
|
c.Assert(resp.StatusCode, checker.Equals, 404)
|
||||||
|
}
|
||||||
killErr := cmd.Process.Kill()
|
|
||||||
c.Assert(killErr, checker.IsNil)
|
func (s *SimpleSuite) TestWithWebConfig(c *check.C) {
|
||||||
|
cmd := exec.Command(traefikBinary, "fixtures/simple_web.toml")
|
||||||
|
err := cmd.Start()
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
defer cmd.Process.Kill()
|
||||||
|
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
|
||||||
|
resp, err := http.Get("http://127.0.0.1:8080/api")
|
||||||
|
// Expected a 200
|
||||||
|
c.Assert(err, checker.IsNil)
|
||||||
|
c.Assert(resp.StatusCode, checker.Equals, 200)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ func (s *ConsulSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "fixtures/consul/simple.toml")
|
cmd := exec.Command(traefikBinary, "fixtures/consul/simple.toml")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
defer cmd.Process.Kill()
|
||||||
|
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
// TODO validate : run on 80
|
// TODO validate : run on 80
|
||||||
|
@ -21,7 +22,4 @@ func (s *ConsulSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
// Expected a 404 as we did not comfigure anything
|
// Expected a 404 as we did not comfigure anything
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(resp.StatusCode, checker.Equals, 404)
|
c.Assert(resp.StatusCode, checker.Equals, 404)
|
||||||
|
|
||||||
killErr := cmd.Process.Kill()
|
|
||||||
c.Assert(killErr, checker.IsNil)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "fixtures/file/simple.toml")
|
cmd := exec.Command(traefikBinary, "fixtures/file/simple.toml")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
defer cmd.Process.Kill()
|
||||||
|
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
resp, err := http.Get("http://127.0.0.1/")
|
resp, err := http.Get("http://127.0.0.1/")
|
||||||
|
@ -20,9 +21,6 @@ func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
// Expected a 404 as we did not configure anything
|
// Expected a 404 as we did not configure anything
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(resp.StatusCode, checker.Equals, 404)
|
c.Assert(resp.StatusCode, checker.Equals, 404)
|
||||||
|
|
||||||
killErr := cmd.Process.Kill()
|
|
||||||
c.Assert(killErr, checker.IsNil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// #56 regression test, make sure it does not fail
|
// #56 regression test, make sure it does not fail
|
||||||
|
@ -30,6 +28,7 @@ func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "fixtures/file/56-simple-panic.toml")
|
cmd := exec.Command(traefikBinary, "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()
|
||||||
|
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
resp, err := http.Get("http://127.0.0.1/")
|
resp, err := http.Get("http://127.0.0.1/")
|
||||||
|
@ -37,7 +36,4 @@ func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
|
||||||
// Expected a 404 as we did not configure anything
|
// Expected a 404 as we did not configure anything
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(resp.StatusCode, checker.Equals, 404)
|
c.Assert(resp.StatusCode, checker.Equals, 404)
|
||||||
|
|
||||||
killErr := cmd.Process.Kill()
|
|
||||||
c.Assert(killErr, checker.IsNil)
|
|
||||||
}
|
}
|
||||||
|
|
5
integration/fixtures/simple_web.toml
Normal file
5
integration/fixtures/simple_web.toml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
logLevel = "DEBUG"
|
||||||
|
|
||||||
|
[web]
|
||||||
|
|
||||||
|
address = ":8080"
|
|
@ -32,9 +32,6 @@ func init() {
|
||||||
|
|
||||||
var traefikBinary = "../dist/traefik"
|
var traefikBinary = "../dist/traefik"
|
||||||
|
|
||||||
// SimpleSuite
|
|
||||||
type SimpleSuite struct{ BaseSuite }
|
|
||||||
|
|
||||||
// File test suites
|
// File test suites
|
||||||
type FileSuite struct{ BaseSuite }
|
type FileSuite struct{ BaseSuite }
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
cmd := exec.Command(traefikBinary, "fixtures/marathon/simple.toml")
|
cmd := exec.Command(traefikBinary, "fixtures/marathon/simple.toml")
|
||||||
err := cmd.Start()
|
err := cmd.Start()
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
defer cmd.Process.Kill()
|
||||||
|
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
// TODO validate : run on 80
|
// TODO validate : run on 80
|
||||||
|
@ -21,7 +22,4 @@ func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
// Expected a 404 as we did not configure anything
|
// Expected a 404 as we did not configure anything
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
c.Assert(resp.StatusCode, checker.Equals, 404)
|
c.Assert(resp.StatusCode, checker.Equals, 404)
|
||||||
|
|
||||||
killErr := cmd.Process.Kill()
|
|
||||||
c.Assert(killErr, checker.IsNil)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue