From 0587c813e079070ad88e7ddb1f007881a6fd5b9e Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Sat, 7 Mar 2020 22:42:23 +0530 Subject: [PATCH] Fixing flaky test TestUnlinkGroupTeam (#14019) There is a race at the DB level where the goroutine c.App.SyncRolesAndMembership would set the the SchemeAdmin attribute to false. If this happens after UpdateUserToTeamAdmin happens and before the Login, then the user does not have the required permissions to unlink the group and it fails. Thanks to @streamer45 for spotting the issue. Co-authored-by: mattermod --- api4/group_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api4/group_test.go b/api4/group_test.go index a7ef53f265..e5e896651e 100644 --- a/api4/group_test.go +++ b/api4/group_test.go @@ -7,6 +7,7 @@ import ( "fmt" "net/http" "testing" + "time" "github.com/mattermost/mattermost-server/v5/model" "github.com/stretchr/testify/assert" @@ -236,6 +237,7 @@ func TestUnlinkGroupTeam(t *testing.T) { response = th.Client.UnlinkGroupSyncable(g.Id, th.BasicTeam.Id, model.GroupSyncableTypeTeam) assert.NotNil(t, response.Error) + time.Sleep(2 * time.Second) // A hack to let "go c.App.SyncRolesAndMembership" finish before moving on. th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam) ok, response := th.Client.Logout() assert.True(t, ok)