refactor: Deflake and Try package

- feat: add CI multiplier
- refactor: readability
- feat: custom Sleep function
- refactor(integration): use custom Sleep
- feat: show Try progress
- feat(try): try response with status code
- refactor(try): use a dedicate package.
- refactor(integration): Try everywhere
- feat(CI): pass CI env var to Integration Tests.
- refactor(acme): increase timeout.
- feat(acme): show Traefik logs
- refactor(integration): use `http.StatusXXX`
- refactor: remove Sleep
This commit is contained in:
Fernandez Ludovic 2017-05-17 15:22:44 +02:00 committed by Ludovic Fernandez
parent ff3481f06b
commit 2610023131
25 changed files with 751 additions and 613 deletions

View file

@ -5,8 +5,8 @@ import (
"os/exec"
"time"
"github.com/containous/traefik/integration/try"
"github.com/go-check/check"
checker "github.com/vdemeester/shakers"
)
@ -16,18 +16,28 @@ type MarathonSuite struct{ BaseSuite }
func (s *MarathonSuite) SetUpSuite(c *check.C) {
s.createComposeProject(c, "marathon")
s.composeProject.Start(c)
// wait for marathon
// err := utils.TryRequest("http://127.0.0.1:8080/ping", 60*time.Second, func(res *http.Response) error {
// body, err := ioutil.ReadAll(res.Body)
// if err != nil {
// return err
// }
// if !strings.Contains(string(body), "ping") {
// return errors.New("Incorrect marathon config")
// }
// return nil
// })
// c.Assert(err, checker.IsNil)
// FIXME Doesn't work...
//// "github.com/gambol99/go-marathon"
//config := marathon.NewDefaultConfig()
//
//marathonClient, err := marathon.NewClient(config)
//if err != nil {
// c.Fatalf("Error creating Marathon client. %v", err)
//}
//
//// Wait for Marathon to elect itself leader
//err = try.Do(30*time.Second, func() error {
// leader, err := marathonClient.Leader()
//
// if err != nil || len(leader) == 0 {
// return fmt.Errorf("Leader not found. %v", err)
// }
//
// return nil
//})
//
//c.Assert(err, checker.IsNil)
}
func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) {
@ -36,11 +46,9 @@ func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) {
c.Assert(err, checker.IsNil)
defer cmd.Process.Kill()
time.Sleep(500 * time.Millisecond)
// TODO validate : run on 80
resp, err := http.Get("http://127.0.0.1:8000/")
// Expected a 404 as we did not configure anything
err = try.GetRequest("http://127.0.0.1:8000/", 500*time.Millisecond, try.StatusCodeIs(http.StatusNotFound))
c.Assert(err, checker.IsNil)
c.Assert(resp.StatusCode, checker.Equals, 404)
}