2015-09-27 13:59:51 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"os/exec"
|
|
|
|
"time"
|
|
|
|
|
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
|
|
|
// Marathon test suites (using libcompose)
|
|
|
|
type MarathonSuite struct{ BaseSuite }
|
|
|
|
|
|
|
|
func (s *MarathonSuite) SetUpSuite(c *check.C) {
|
|
|
|
s.createComposeProject(c, "marathon")
|
2016-06-06 20:33:29 +00:00
|
|
|
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)
|
2016-03-27 14:27:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-27 13:59:51 +00:00
|
|
|
func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) {
|
2016-01-13 21:46:44 +00:00
|
|
|
cmd := exec.Command(traefikBinary, "--configFile=fixtures/marathon/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-08 20:11:34 +00:00
|
|
|
time.Sleep(500 * time.Millisecond)
|
2015-09-27 13:59:51 +00:00
|
|
|
// TODO validate : run on 80
|
2016-01-13 21:46:44 +00:00
|
|
|
resp, err := http.Get("http://127.0.0.1:8000/")
|
2015-09-27 13:59:51 +00:00
|
|
|
|
2016-03-15 17:57:56 +00:00
|
|
|
// Expected a 404 as we did not configure anything
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
c.Assert(resp.StatusCode, checker.Equals, 404)
|
2015-09-27 13:59:51 +00:00
|
|
|
}
|