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
|
@ -3,7 +3,6 @@ package integration
|
|||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"github.com/containous/traefik/integration/try"
|
||||
|
@ -12,25 +11,29 @@ import (
|
|||
)
|
||||
|
||||
// ErrorPagesSuite test suites (using libcompose)
|
||||
type ErrorPagesSuite struct{ BaseSuite }
|
||||
|
||||
func (ep *ErrorPagesSuite) SetUpSuite(c *check.C) {
|
||||
ep.createComposeProject(c, "error_pages")
|
||||
ep.composeProject.Start(c)
|
||||
type ErrorPagesSuite struct {
|
||||
BaseSuite
|
||||
ErrorPageIP string
|
||||
BackendIP string
|
||||
}
|
||||
|
||||
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
|
||||
backendHost := ep.composeProject.Container(c, "nginx1").NetworkSettings.IPAddress
|
||||
s.ErrorPageIP = s.composeProject.Container(c, "nginx2").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
|
||||
Server2 string
|
||||
}{backendHost, errorPageHost})
|
||||
}{s.BackendIP, s.ErrorPageIP})
|
||||
defer os.Remove(file)
|
||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
||||
|
||||
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
@ -43,19 +46,16 @@ func (ep *ErrorPagesSuite) TestSimpleConfiguration(c *check.C) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
}
|
||||
|
||||
func (ep *ErrorPagesSuite) TestErrorPage(c *check.C) {
|
||||
|
||||
errorPageHost := ep.composeProject.Container(c, "nginx2").NetworkSettings.IPAddress
|
||||
backendHost := ep.composeProject.Container(c, "nginx1").NetworkSettings.IPAddress
|
||||
func (s *ErrorPagesSuite) TestErrorPage(c *check.C) {
|
||||
|
||||
//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
|
||||
Server2 string
|
||||
}{backendHost, errorPageHost})
|
||||
}{s.BackendIP, s.ErrorPageIP})
|
||||
defer os.Remove(file)
|
||||
cmd := exec.Command(traefikBinary, "--configFile="+file)
|
||||
|
||||
cmd, _ := s.cmdTraefik(withConfigFile(file))
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer cmd.Process.Kill()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue