From 45ea23ecc1b244aaecd4c442364829f8730d31b9 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Mon, 12 Oct 2015 08:44:56 +0200 Subject: [PATCH] Update integration setups to use libcompose events Now that docker/libcompose#55 is merged, use it \o/ No more sleeps ! Signed-off-by: Vincent Demeester --- Godeps/Godeps.json | 10 ++++---- integration/fixtures/file/simple.toml | 33 ++++++++++++++++++++++++ integration/integration_test.go | 37 ++++++++++++--------------- 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 36e270c9b..248f5b5e3 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -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" diff --git a/integration/fixtures/file/simple.toml b/integration/fixtures/file/simple.toml index 100b58a93..6d799d24b 100644 --- a/integration/fixtures/file/simple.toml +++ b/integration/fixtures/file/simple.toml @@ -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" diff --git a/integration/integration_test.go b/integration/integration_test.go index cf2281520..654cefa5f 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -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 } }