Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
timoreimann committed Jul 10, 2017
1 parent 24683b2 commit 9f0c14f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 46 deletions.
6 changes: 4 additions & 2 deletions integration/fixtures/marathon/simple.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
defaultEntryPoints = ["http"]

logLevel = "DEBUG"

[entryPoints]
[entryPoints.http]
address = ":8000"

logLevel = "DEBUG"

[marathon]
watch = true
exposedByDefault = true
10 changes: 0 additions & 10 deletions integration/fixtures/marathon/with-entrypoint.toml

This file was deleted.

63 changes: 29 additions & 34 deletions integration/marathon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/containous/traefik/integration/try"
"github.com/containous/traefik/types"
marathon "github.com/gambol99/go-marathon"
"github.com/go-check/check"
checker "github.com/vdemeester/shakers"
Expand All @@ -15,31 +16,8 @@ import (
type MarathonSuite struct{ BaseSuite }

func (s *MarathonSuite) SetUpSuite(c *check.C) {
fmt.Println("setting up marathon compose file")
s.createComposeProject(c, "marathon")
s.composeProject.Start(c)

// 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) {
Expand All @@ -51,36 +29,53 @@ func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) {
// TODO validate : run on 80
// 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)
}

func (s *MarathonSuite) TestConfigurationUpdate(c *check.C) {
cmd, _ := s.cmdTraefik(withConfigFile("fixtures/marathon/with-entrypoint.toml"))
cmd, output := s.cmdTraefik(withConfigFile("fixtures/marathon/simple.toml"))
err := cmd.Start()
c.Assert(err, checker.IsNil)
defer cmd.Process.Kill()

marathonURL := "http://127.0.0.1:8080"
fmt.Printf("polling Marathon URL %s for availability\n", marathonURL)
// wait for marathon
err = try.GetRequest(fmt.Sprintf("%s/ping", marathonURL), 5*time.Minute, try.StatusCodeIs(http.StatusOK))
c.Assert(err, checker.IsNil)

// Prepare Marathon client.
config := marathon.NewDefaultConfig()
config.URL = marathonURL
client, err := marathon.NewClient(config)
c.Assert(err, checker.IsNil)

showTraefikLog := true
defer func() {
if showTraefikLog {
s.displayTraefikLog(c, output)
}
}()

fmt.Println("Waiting for Marathon to become ready")
err = try.Do(1*time.Minute, func() error {
_, err := client.Ping()
return err
})
c.Assert(err, checker.IsNil)

// Deploy test application via Marathon.
app := marathon.NewDockerApplication().Name("/whoami").CPU(0.1).Memory(32)
app := marathon.NewDockerApplication().
Name("/whoami").
CPU(0.1).
Memory(32).
AddLabel(types.LabelFrontendRule, "PathPrefix:/service")
app.Container.Docker.Container("emilevauge/whoami")

fmt.Println("deploying test application")
deployID, err := client.UpdateApplication(app, false)
fmt.Println("Deploying test application")
deploy, err := client.UpdateApplication(app, false)
c.Assert(err, checker.IsNil)
c.Assert(client.WaitOnDeployment(deployID.DeploymentID, 30*time.Second), checker.IsNil)
fmt.Println("Waiting for Deployment to complete")
c.Assert(client.WaitOnDeployment(deploy.DeploymentID, 30*time.Second), checker.IsNil)

fmt.Println("done.")
fmt.Println("Querying application via Traefik")
err = try.GetRequest("http://127.0.0.1:8000/service", 5*time.Second, try.StatusCodeIs(http.StatusOK))
c.Assert(err, checker.IsNil)
showTraefikLog = false
}

0 comments on commit 9f0c14f

Please sign in to comment.