From 0cf37d0f3cba4ae010ad51317b4b4f16421fe656 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Tue, 15 Dec 2020 19:19:53 +0530 Subject: [PATCH] MM-3124: Fix racy test TestPluginPanicLogs (#16541) We shutdown all plugins prior to checking the log buffer so that there are no active plugins writing to the buffer when we read the contents. https://mattermost.atlassian.net/browse/MM-31324 ```release-note NONE ``` --- app/plugin_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/plugin_test.go b/app/plugin_test.go index 19a8bb9041..34a86a4bf3 100644 --- a/app/plugin_test.go +++ b/app/plugin_test.go @@ -715,7 +715,6 @@ func TestPluginPanicLogs(t *testing.T) { } `, }, th.App, th.App.NewPluginAPI) - defer tearDown() post := &model.Post{ UserId: th.BasicUser.Id, @@ -725,6 +724,9 @@ func TestPluginPanicLogs(t *testing.T) { } _, err := th.App.CreatePost(post, th.BasicChannel, false, true) assert.Nil(t, err) + // We shutdown plugins first so that the read on the log buffer is race-free. + th.App.Srv().ShutDownPlugins() + tearDown() testlib.AssertLog(t, th.LogBuffer, mlog.LevelDebug, "panic: some text from panic") })