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 <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Agniva De Sarker
2020-03-07 22:42:23 +05:30
коммит произвёл GitHub
родитель c8a923d9e3
Коммит 0587c813e0

Просмотреть файл

@@ -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)