2017-07-06 14:28:13 +00:00
|
|
|
package integration
|
2015-09-27 13:59:51 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2019-07-15 08:22:03 +00:00
|
|
|
"os"
|
2015-09-27 13:59:51 +00:00
|
|
|
"time"
|
|
|
|
|
2016-04-02 10:40:21 +00:00
|
|
|
"github.com/go-check/check"
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/integration/try"
|
2015-09-27 13:59:51 +00:00
|
|
|
checker "github.com/vdemeester/shakers"
|
|
|
|
)
|
|
|
|
|
2020-05-11 10:06:07 +00:00
|
|
|
// File tests suite.
|
2016-03-27 14:27:56 +00:00
|
|
|
type FileSuite struct{ BaseSuite }
|
|
|
|
|
|
|
|
func (s *FileSuite) SetUpSuite(c *check.C) {
|
|
|
|
s.createComposeProject(c, "file")
|
2021-11-25 10:10:06 +00:00
|
|
|
s.composeUp(c)
|
2016-03-27 14:27:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-27 13:59:51 +00:00
|
|
|
func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
2019-07-15 08:22:03 +00:00
|
|
|
file := s.adaptFile(c, "fixtures/file/simple.toml", struct{}{})
|
|
|
|
defer os.Remove(file)
|
|
|
|
cmd, display := s.traefikCmd(withConfigFile(file))
|
2017-09-13 08:34:04 +00:00
|
|
|
defer display(c)
|
2015-09-27 13:59:51 +00:00
|
|
|
err := cmd.Start()
|
|
|
|
c.Assert(err, checker.IsNil)
|
2020-10-09 07:32:03 +00:00
|
|
|
defer s.killCmd(cmd)
|
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)
|
|
|
|
}
|
|
|
|
|
2020-05-11 10:06:07 +00:00
|
|
|
// #56 regression test, make sure it does not fail?
|
2015-10-17 12:46:31 +00:00
|
|
|
func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
|
2017-09-13 08:34:04 +00:00
|
|
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/file/56-simple-panic.toml"))
|
|
|
|
defer display(c)
|
2015-10-17 12:46:31 +00:00
|
|
|
err := cmd.Start()
|
|
|
|
c.Assert(err, checker.IsNil)
|
2020-10-09 07:32:03 +00:00
|
|
|
defer s.killCmd(cmd)
|
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) {
|
2017-09-13 08:34:04 +00:00
|
|
|
cmd, display := s.traefikCmd(withConfigFile("fixtures/file/directory.toml"))
|
|
|
|
defer display(c)
|
2017-05-26 13:32:03 +00:00
|
|
|
err := cmd.Start()
|
|
|
|
c.Assert(err, checker.IsNil)
|
2020-10-09 07:32:03 +00:00
|
|
|
defer s.killCmd(cmd)
|
2017-05-26 13:32:03 +00:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|