diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2018-04-23 10:20:02 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <zegerjan@gitlab.com> | 2018-04-23 10:20:02 +0300 |
commit | ecfd1e1b7aefff631745dc62ba53c918020731d5 (patch) | |
tree | 0b39383a363ed6290c5f356aa9743cc9f2f0d8e6 /internal | |
parent | 5d3e20c7fdf41cb756366f6331d6846f0eb8b76a (diff) |
Stop worker monitors in test
Diffstat (limited to 'internal')
-rw-r--r-- | internal/rubyserver/worker.go | 10 | ||||
-rw-r--r-- | internal/rubyserver/worker_test.go | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/internal/rubyserver/worker.go b/internal/rubyserver/worker.go index ea7c22afb..ca566d093 100644 --- a/internal/rubyserver/worker.go +++ b/internal/rubyserver/worker.go @@ -31,9 +31,10 @@ func init() { // it if necessary, in cooperation with the balancer. type worker struct { *supervisor.Process - address string - events <-chan supervisor.Event - shutdown chan struct{} + address string + events <-chan supervisor.Event + shutdown chan struct{} + monitorDone chan struct{} // This is for testing only, so that we can inject a fake balancer balancerUpdate chan balancerProxy @@ -47,6 +48,7 @@ func newWorker(p *supervisor.Process, address string, events <-chan supervisor.E address: address, events: events, shutdown: make(chan struct{}), + monitorDone: make(chan struct{}), balancerUpdate: make(chan balancerProxy), testing: testing, } @@ -171,6 +173,7 @@ func (w *worker) monitor() { case bal = <-w.balancerUpdate: // For testing only. case <-w.shutdown: + close(w.monitorDone) return } } @@ -178,6 +181,7 @@ func (w *worker) monitor() { func (w *worker) stopMonitor() { close(w.shutdown) + <-w.monitorDone } func badPid(pid int) bool { diff --git a/internal/rubyserver/worker_test.go b/internal/rubyserver/worker_test.go index 145ce2b55..5b0599b74 100644 --- a/internal/rubyserver/worker_test.go +++ b/internal/rubyserver/worker_test.go @@ -21,6 +21,7 @@ func TestWorker(t *testing.T) { events := make(chan supervisor.Event) addr := "the address" w := newWorker(&supervisor.Process{Name: "testing"}, addr, events, true) + defer w.stopMonitor() t.Log("ignore health failures during startup") mustIgnore(t, w, func() { events <- healthBadEvent() }) @@ -90,6 +91,7 @@ func TestWorkerHealthChecks(t *testing.T) { events := make(chan supervisor.Event) addr := "the address" w := newWorker(&supervisor.Process{Name: "testing"}, addr, events, true) + defer w.stopMonitor() t.Log("ignore health failures during startup") mustIgnore(t, w, func() { events <- healthBadEvent() }) |