Merge pull request #57 from vdemeester/no-more-sleep-in-integration
Update integration setups to use libcompose events
This commit is contained in:
commit
31c7aba8c4
3 changed files with 55 additions and 25 deletions
10
Godeps/Godeps.json
generated
10
Godeps/Godeps.json
generated
|
@ -189,19 +189,19 @@
|
|||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libcompose/docker",
|
||||
"Rev": "aad672800904307e96a2c21cad1420f3080e0f35"
|
||||
"Rev": "79ef5d150f053a5b12f16b02d8844ed7cf33611a"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libcompose/logger",
|
||||
"Rev": "aad672800904307e96a2c21cad1420f3080e0f35"
|
||||
"Rev": "79ef5d150f053a5b12f16b02d8844ed7cf33611a"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libcompose/lookup",
|
||||
"Rev": "aad672800904307e96a2c21cad1420f3080e0f35"
|
||||
"Rev": "79ef5d150f053a5b12f16b02d8844ed7cf33611a"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libcompose/project",
|
||||
"Rev": "aad672800904307e96a2c21cad1420f3080e0f35"
|
||||
"Rev": "79ef5d150f053a5b12f16b02d8844ed7cf33611a"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libcompose/utils",
|
||||
"Rev": "aad672800904307e96a2c21cad1420f3080e0f35"
|
||||
"Rev": "79ef5d150f053a5b12f16b02d8844ed7cf33611a"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libtrust",
|
||||
"Rev": "9cbd2a1374f46905c68a4eb3694a130610adc62a"
|
||||
|
|
|
@ -9,3 +9,36 @@
|
|||
logLevel = "DEBUG"
|
||||
|
||||
[file]
|
||||
|
||||
# rules
|
||||
[backends]
|
||||
[backends.backend1]
|
||||
[backends.backend1.circuitbreaker]
|
||||
expression = "NetworkErrorRatio() > 0.5"
|
||||
[backends.backend1.servers.server1]
|
||||
url = "http://172.17.0.2:80"
|
||||
weight = 10
|
||||
[backends.backend1.servers.server2]
|
||||
url = "http://172.17.0.3:80"
|
||||
weight = 1
|
||||
[backends.backend2]
|
||||
[backends.backend2.LoadBalancer]
|
||||
method = "drr"
|
||||
[backends.backend2.servers.server1]
|
||||
url = "http://172.17.0.4:80"
|
||||
weight = 1
|
||||
[backends.backend2.servers.server2]
|
||||
url = "http://172.17.0.5:80"
|
||||
weight = 2
|
||||
|
||||
[frontends]
|
||||
[frontends.frontend1]
|
||||
backend = "backend2"
|
||||
[frontends.frontend1.routes.test_1]
|
||||
rule = "Host"
|
||||
value = "test.localhost"
|
||||
[frontends.frontend2]
|
||||
backend = "backend1"
|
||||
[frontends.frontend2.routes.test_2]
|
||||
rule = "Path"
|
||||
value = "/test"
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/docker/libcompose/docker"
|
||||
"github.com/docker/libcompose/project"
|
||||
|
@ -72,7 +71,7 @@ func (s *MarathonSuite) SetUpSuite(c *check.C) {
|
|||
|
||||
type BaseSuite struct {
|
||||
composeProject *project.Project
|
||||
listenChan chan project.ProjectEvent
|
||||
listenChan chan project.Event
|
||||
started chan bool
|
||||
stopped chan bool
|
||||
deleted chan bool
|
||||
|
@ -82,14 +81,12 @@ func (s *BaseSuite) TearDownSuite(c *check.C) {
|
|||
// shutdown and delete compose project
|
||||
if s.composeProject != nil {
|
||||
s.composeProject.Down()
|
||||
// Waiting for libcompose#55 to be merged
|
||||
// <-s.stopped
|
||||
time.Sleep(2 * time.Second)
|
||||
<-s.stopped
|
||||
defer close(s.stopped)
|
||||
|
||||
s.composeProject.Delete()
|
||||
// Waiting for libcompose#55 to be merged
|
||||
// <-s.deleted
|
||||
time.Sleep(2 * time.Second)
|
||||
<-s.deleted
|
||||
defer close(s.deleted)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,32 +100,32 @@ func (s *BaseSuite) createComposeProject(c *check.C, name string) {
|
|||
c.Assert(err, checker.IsNil)
|
||||
s.composeProject = composeProject
|
||||
|
||||
s.listenChan = make(chan project.ProjectEvent)
|
||||
s.started = make(chan bool)
|
||||
s.stopped = make(chan bool)
|
||||
s.deleted = make(chan bool)
|
||||
|
||||
s.listenChan = make(chan project.Event)
|
||||
go s.startListening(c)
|
||||
|
||||
composeProject.AddListener(s.listenChan)
|
||||
|
||||
composeProject.Start()
|
||||
|
||||
// FIXME Wait for compose to start
|
||||
// Waiting for libcompose#55 to be merged
|
||||
// <-s.started
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// Wait for compose to start
|
||||
<-s.started
|
||||
defer close(s.started)
|
||||
}
|
||||
|
||||
func (s *BaseSuite) startListening(c *check.C) {
|
||||
for event := range s.listenChan {
|
||||
// FIXME Remove this when it's working (libcompose#55)
|
||||
// fmt.Fprintf(os.Stdout, "Event: %s (%v)\n", event.Event, event)
|
||||
// FIXME Add a timeout on event
|
||||
if event.Event == project.PROJECT_UP_DONE {
|
||||
// FIXME Add a timeout on event ?
|
||||
if event.EventType == project.EventProjectStartDone {
|
||||
s.started <- true
|
||||
}
|
||||
if event.Event == project.PROJECT_DOWN_DONE {
|
||||
if event.EventType == project.EventProjectDownDone {
|
||||
s.stopped <- true
|
||||
}
|
||||
if event.Event == project.PROJECT_DELETE_DONE {
|
||||
if event.EventType == project.EventProjectDeleteDone {
|
||||
s.deleted <- true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue