diff --git a/src/plugins/process_watcher.go b/src/plugins/process_watcher.go index 8bdba959d..6b62023b4 100644 --- a/src/plugins/process_watcher.go +++ b/src/plugins/process_watcher.go @@ -62,7 +62,7 @@ func (pw *ProcessWatcher) Info() *core.Info { func (pw *ProcessWatcher) Close() { log.Info("ProcessWatcher is wrapping up") - pw.wg.Done() + pw.wg.Wait() } func (pw *ProcessWatcher) Process(message *core.Message) {} diff --git a/src/plugins/process_watcher_test.go b/src/plugins/process_watcher_test.go index bb3ba2ad7..786c7fcdb 100644 --- a/src/plugins/process_watcher_test.go +++ b/src/plugins/process_watcher_test.go @@ -155,9 +155,10 @@ func TestProcessWatcher_getProcUpdates(t *testing.T) { func TestProcessWatcher_Process(t *testing.T) { env := tutils.GetMockEnvWithProcess() - pluginUnderTest := NewProcessWatcher(env, tutils.GetMockNginxBinary()) - messagePipe := core.SetupMockMessagePipe(t, context.TODO(), pluginUnderTest) + + ctx, cancel := context.WithCancel(context.TODO()) + messagePipe := core.SetupMockMessagePipe(t, ctx, pluginUnderTest) pluginUnderTest.Init(messagePipe) messagePipe.Run() @@ -173,6 +174,8 @@ func TestProcessWatcher_Process(t *testing.T) { } } + cancel() + pluginUnderTest.Close() } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/process_watcher.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/process_watcher.go index 8bdba959d..6b62023b4 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/process_watcher.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/process_watcher.go @@ -62,7 +62,7 @@ func (pw *ProcessWatcher) Info() *core.Info { func (pw *ProcessWatcher) Close() { log.Info("ProcessWatcher is wrapping up") - pw.wg.Done() + pw.wg.Wait() } func (pw *ProcessWatcher) Process(message *core.Message) {}