diff --git a/jobs/jobs_watcher.go b/jobs/jobs_watcher.go index e0f57a5cf6..464cce994a 100644 --- a/jobs/jobs_watcher.go +++ b/jobs/jobs_watcher.go @@ -26,6 +26,8 @@ type Watcher struct { func (srv *JobServer) MakeWatcher(workers *Workers, pollingInterval int) *Watcher { return &Watcher{ + stop: make(chan struct{}), + stopped: make(chan struct{}), pollingInterval: pollingInterval, workers: workers, srv: srv, @@ -34,8 +36,6 @@ func (srv *JobServer) MakeWatcher(workers *Workers, pollingInterval int) *Watche func (watcher *Watcher) Start() { mlog.Debug("Watcher Started") - watcher.stop = make(chan struct{}) - watcher.stopped = make(chan struct{}) // Delay for some random number of milliseconds before starting to ensure that multiple // instances of the jobserver don't poll at a time too close to each other. rand.Seed(time.Now().UTC().UnixNano()) @@ -61,6 +61,9 @@ func (watcher *Watcher) Stop() { mlog.Debug("Watcher Stopping") close(watcher.stop) <-watcher.stopped + + watcher.stop = make(chan struct{}) + watcher.stopped = make(chan struct{}) } func (watcher *Watcher) PollAndNotify() { diff --git a/jobs/server_test.go b/jobs/server_test.go index 4e02726d7c..9c550c54d9 100644 --- a/jobs/server_test.go +++ b/jobs/server_test.go @@ -11,7 +11,6 @@ import ( ) func TestStartWorkers(t *testing.T) { - t.Skip("MM-42412") t.Run("uninitialized", func(t *testing.T) { jobServer, _, _ := makeJobServer(t) err := jobServer.StartWorkers() @@ -44,7 +43,6 @@ func TestStartWorkers(t *testing.T) { } func TestStopWorkers(t *testing.T) { - t.Skip("MM-42412") t.Run("uninitialized", func(t *testing.T) { jobServer, _, _ := makeJobServer(t) err := jobServer.StopWorkers()