2015-09-27 15:59:51 +02:00
package main
import (
"net/http"
"os/exec"
"time"
2016-04-02 12:40:21 +02:00
"github.com/go-check/check"
2015-09-27 15:59:51 +02:00
checker "github.com/vdemeester/shakers"
)
2016-03-27 16:27:56 +02:00
// Marathon test suites (using libcompose)
type MarathonSuite struct { BaseSuite }
func ( s * MarathonSuite ) SetUpSuite ( c * check . C ) {
s . createComposeProject ( c , "marathon" )
2016-06-06 22:33:29 +02: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 16:27:56 +02:00
}
2015-09-27 15:59:51 +02:00
func ( s * MarathonSuite ) TestSimpleConfiguration ( c * check . C ) {
2016-01-13 22:46:44 +01:00
cmd := exec . Command ( traefikBinary , "--configFile=fixtures/marathon/simple.toml" )
2015-09-27 15:59:51 +02:00
err := cmd . Start ( )
c . Assert ( err , checker . IsNil )
2015-11-03 23:06:31 +01:00
defer cmd . Process . Kill ( )
2015-09-27 15:59:51 +02:00
2015-10-08 22:11:34 +02:00
time . Sleep ( 500 * time . Millisecond )
2015-09-27 15:59:51 +02:00
// TODO validate : run on 80
2016-01-13 22:46:44 +01:00
resp , err := http . Get ( "http://127.0.0.1:8000/" )
2015-09-27 15:59:51 +02:00
2016-03-15 18:57:56 +01: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 15:59:51 +02:00
}