2015-09-27 13:59:51 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"os/exec"
|
|
|
|
"time"
|
|
|
|
|
2017-05-17 13:22:44 +00:00
|
|
|
"github.com/containous/traefik/integration/try"
|
2016-04-02 10:40:21 +00:00
|
|
|
"github.com/go-check/check"
|
2015-09-27 13:59:51 +00:00
|
|
|
checker "github.com/vdemeester/shakers"
|
|
|
|
)
|
|
|
|
|
2016-03-27 14:27:56 +00:00
|
|
|
// File test suites
|
|
|
|
type FileSuite struct{ BaseSuite }
|
|
|
|
|
|
|
|
func (s *FileSuite) SetUpSuite(c *check.C) {
|
|
|
|
s.createComposeProject(c, "file")
|
|
|
|
|
2016-04-02 10:40:21 +00:00
|
|
|
s.composeProject.Start(c)
|
2016-03-27 14:27:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-27 13:59:51 +00:00
|
|
|
func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
2016-01-13 21:46:44 +00:00
|
|
|
cmd := exec.Command(traefikBinary, "--configFile=fixtures/file/simple.toml")
|
2015-09-27 13:59:51 +00:00
|
|
|
err := cmd.Start()
|
|
|
|
c.Assert(err, checker.IsNil)
|
2015-11-03 22:06:31 +00:00
|
|
|
defer cmd.Process.Kill()
|
2015-09-27 13:59:51 +00:00
|
|
|
|
2015-10-17 12:46:31 +00:00
|
|
|
// Expected a 404 as we did not configure anything
|
2017-05-26 13:32:03 +00:00
|
|
|
err = try.GetRequest("http://127.0.0.1:8000/", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound))
|
2015-10-17 12:46:31 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
}
|
|
|
|
|
|
|
|
// #56 regression test, make sure it does not fail
|
|
|
|
func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
|
2016-01-13 21:46:44 +00:00
|
|
|
cmd := exec.Command(traefikBinary, "--configFile=fixtures/file/56-simple-panic.toml")
|
2015-10-17 12:46:31 +00:00
|
|
|
err := cmd.Start()
|
|
|
|
c.Assert(err, checker.IsNil)
|
2015-11-03 22:06:31 +00:00
|
|
|
defer cmd.Process.Kill()
|
2015-10-17 12:46:31 +00:00
|
|
|
|
2015-10-06 19:00:53 +00:00
|
|
|
// Expected a 404 as we did not configure anything
|
2017-05-26 13:32:03 +00:00
|
|
|
err = try.GetRequest("http://127.0.0.1:8000/", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound))
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *FileSuite) TestDirectoryConfiguration(c *check.C) {
|
|
|
|
cmd := exec.Command(traefikBinary, "--configFile=fixtures/file/directory.toml")
|
|
|
|
|
|
|
|
err := cmd.Start()
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
defer cmd.Process.Kill()
|
|
|
|
|
|
|
|
// Expected a 404 as we did not configure anything at /test
|
|
|
|
err = try.GetRequest("http://127.0.0.1:8000/test", 1000*time.Millisecond, try.StatusCodeIs(http.StatusNotFound))
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
// Expected a 502 as there is no backend server
|
|
|
|
err = try.GetRequest("http://127.0.0.1:8000/test2", 1000*time.Millisecond, try.StatusCodeIs(http.StatusBadGateway))
|
2015-09-27 13:59:51 +00:00
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
}
|