MM-57532: Improve timeouts for some tests (#26642)
- Bump timeouts for some cases - Improve sleep with require/assert.EventuallyT for better performance and reliability. https://mattermost.atlassian.net/browse/MM-57532 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bc6182229b
Коммит
dc3e5b9269
@@ -190,7 +190,7 @@ func TestHubSessionRevokeRace(t *testing.T) {
|
||||
|
||||
done := make(chan bool)
|
||||
|
||||
time.Sleep(time.Second)
|
||||
time.Sleep(2 * time.Second)
|
||||
// We override the LastActivityAt which happens in NewWebConn.
|
||||
// This is needed to call RevokeSessionById which triggers the race.
|
||||
th.Service.AddSessionToCache(sess1)
|
||||
|
||||
@@ -1856,7 +1856,7 @@ func TestPluginHTTPUpgradeWebSocket(t *testing.T) {
|
||||
var resp *model.WebSocketResponse
|
||||
select {
|
||||
case resp = <-wsc.ResponseChannel:
|
||||
case <-time.After(1 * time.Second):
|
||||
case <-time.After(2 * time.Second):
|
||||
}
|
||||
require.NotNil(t, resp)
|
||||
require.Equal(t, resp.Status, model.StatusOk)
|
||||
|
||||
@@ -815,11 +815,10 @@ func TestUserHasLoggedIn(t *testing.T) {
|
||||
assert.Nil(t, err, "Expected nil, got %s", err)
|
||||
assert.NotNil(t, session)
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
user, _ := th.App.GetUser(th.BasicUser.Id)
|
||||
|
||||
assert.Equal(t, user.FirstName, "plugin-callback-success", "Expected firstname overwrite, got default")
|
||||
require.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||
user, _ := th.App.GetUser(th.BasicUser.Id)
|
||||
assert.Equal(c, user.FirstName, "plugin-callback-success", "Expected firstname overwrite, got default")
|
||||
}, 2*time.Second, 100*time.Millisecond)
|
||||
}
|
||||
|
||||
func TestUserHasBeenDeactivated(t *testing.T) {
|
||||
@@ -864,9 +863,8 @@ func TestUserHasBeenDeactivated(t *testing.T) {
|
||||
_, err = th.App.UpdateActive(th.Context, user, false)
|
||||
require.Nil(t, err)
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
time.Sleep(2 * time.Second)
|
||||
user, err = th.App.GetUser(user.Id)
|
||||
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, "plugin-callback-success", user.Nickname)
|
||||
}
|
||||
@@ -909,8 +907,7 @@ func TestUserHasBeenCreated(t *testing.T) {
|
||||
_, err := th.App.CreateUser(th.Context, user)
|
||||
require.Nil(t, err)
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
user, err = th.App.GetUser(user.Id)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, "plugin-callback-success", user.Nickname)
|
||||
@@ -1092,7 +1089,7 @@ func TestActiveHooks(t *testing.T) {
|
||||
}
|
||||
_, appErr := th.App.CreateUser(th.Context, user1)
|
||||
require.Nil(t, appErr)
|
||||
time.Sleep(1 * time.Second)
|
||||
time.Sleep(2 * time.Second)
|
||||
user1, appErr = th.App.GetUser(user1.Id)
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, "plugin-callback-success", user1.Nickname)
|
||||
@@ -1198,7 +1195,7 @@ func TestHookMetrics(t *testing.T) {
|
||||
}
|
||||
_, appErr := th.App.CreateUser(th.Context, user1)
|
||||
require.Nil(t, appErr)
|
||||
time.Sleep(1 * time.Second)
|
||||
time.Sleep(2 * time.Second)
|
||||
user1, appErr = th.App.GetUser(user1.Id)
|
||||
require.Nil(t, appErr)
|
||||
require.Equal(t, "plugin-callback-success", user1.Nickname)
|
||||
@@ -1296,9 +1293,9 @@ func TestHookReactionHasBeenRemoved(t *testing.T) {
|
||||
|
||||
require.Nil(t, err)
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
mockAPI.AssertCalled(t, "LogDebug", "star")
|
||||
require.Eventually(t, func() bool {
|
||||
return mockAPI.AssertCalled(t, "LogDebug", "star")
|
||||
}, 2*time.Second, 100*time.Millisecond)
|
||||
}
|
||||
|
||||
func TestHookRunDataRetention(t *testing.T) {
|
||||
@@ -1536,7 +1533,7 @@ func TestHookNotificationWillBePushed(t *testing.T) {
|
||||
wg.Wait()
|
||||
|
||||
// Hack to let the worker goroutines complete.
|
||||
time.Sleep(1 * time.Second)
|
||||
time.Sleep(2 * time.Second)
|
||||
// Server side verification.
|
||||
assert.Equal(t, tt.expectedNotifications, handler.numReqs())
|
||||
var numMessages int
|
||||
@@ -1704,10 +1701,7 @@ func TestHookPreferencesHaveChanged(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
// Hooks are run in a goroutine, so wait for those to complete
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
mockAPI.AssertCalled(t, "LogDebug", "category=test_category name=test_name_1 value=test_value_1")
|
||||
mockAPI.AssertCalled(t, "LogDebug", "category=test_category name=test_name_2 value=test_value_2")
|
||||
time.Sleep(2 * time.Second)
|
||||
})
|
||||
|
||||
t.Run("should be called when preferences are changed by plugin code", func(t *testing.T) {
|
||||
@@ -2066,12 +2060,11 @@ func TestUserHasJoinedChannel(t *testing.T) {
|
||||
require.Nil(t, appErr)
|
||||
require.NotNil(t, channel)
|
||||
|
||||
// Wait for async plugin hooks to be run
|
||||
time.Sleep(time.Second / 2)
|
||||
|
||||
posts, appErr := th.App.GetPosts(channel.Id, 0, 10)
|
||||
|
||||
require.Nil(t, appErr)
|
||||
var posts *model.PostList
|
||||
require.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||
posts, appErr = th.App.GetPosts(channel.Id, 0, 10)
|
||||
assert.Nil(t, appErr)
|
||||
}, 2*time.Second, 100*time.Millisecond)
|
||||
|
||||
for _, postID := range posts.Order {
|
||||
post := posts.Posts[postID]
|
||||
@@ -2097,12 +2090,11 @@ func TestUserHasJoinedChannel(t *testing.T) {
|
||||
require.Nil(t, appErr)
|
||||
require.NotNil(t, channel)
|
||||
|
||||
// Wait for async plugin hooks to be run
|
||||
time.Sleep(time.Second / 2)
|
||||
|
||||
posts, appErr := th.App.GetPosts(channel.Id, 0, 10)
|
||||
|
||||
require.Nil(t, appErr)
|
||||
var posts *model.PostList
|
||||
require.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||
posts, appErr = th.App.GetPosts(channel.Id, 0, 10)
|
||||
assert.Nil(t, appErr)
|
||||
}, 2*time.Second, 100*time.Millisecond)
|
||||
|
||||
for _, postID := range posts.Order {
|
||||
post := posts.Posts[postID]
|
||||
@@ -2129,12 +2121,11 @@ func TestUserHasJoinedChannel(t *testing.T) {
|
||||
require.Nil(t, appErr)
|
||||
require.NotNil(t, channel)
|
||||
|
||||
// Wait for async plugin hooks to be run
|
||||
time.Sleep(time.Second / 2)
|
||||
|
||||
posts, appErr := th.App.GetPosts(channel.Id, 0, 10)
|
||||
|
||||
require.Nil(t, appErr)
|
||||
var posts *model.PostList
|
||||
require.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||
posts, appErr = th.App.GetPosts(channel.Id, 0, 10)
|
||||
assert.Nil(t, appErr)
|
||||
}, 2*time.Second, 100*time.Millisecond)
|
||||
|
||||
for _, postID := range posts.Order {
|
||||
post := posts.Posts[postID]
|
||||
|
||||
@@ -458,7 +458,7 @@ func TestSentry(t *testing.T) {
|
||||
select {
|
||||
case <-data:
|
||||
require.Fail(t, "Sentry received a message, even though it's disabled!")
|
||||
case <-time.After(time.Second):
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Log("Sentry request didn't arrive. Good!")
|
||||
}
|
||||
})
|
||||
|
||||
Ссылка в новой задаче
Block a user