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
```
Этот коммит содержится в:
Agniva De Sarker
2024-04-05 19:28:49 +05:30
коммит произвёл GitHub
родитель bc6182229b
Коммит dc3e5b9269
14 изменённых файлов: 65 добавлений и 87 удалений

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

@@ -33,7 +33,7 @@ func TestEchoCommand(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, r1, "Echo command failed to execute")
time.Sleep(100 * time.Millisecond)
time.Sleep(time.Second)
p1, _, err := client.GetPostsForChannel(context.Background(), channel1.Id, 0, 2, "", false, false)
require.NoError(t, err)
@@ -187,8 +187,6 @@ func TestLoadTestHelpCommands(t *testing.T) {
rs, _, err := client.ExecuteCommand(context.Background(), channel.Id, "/test help")
require.NoError(t, err)
require.True(t, strings.Contains(rs.Text, "Mattermost testing commands to help"), rs.Text)
time.Sleep(2 * time.Second)
}
func TestLoadTestSetupCommands(t *testing.T) {
@@ -208,8 +206,6 @@ func TestLoadTestSetupCommands(t *testing.T) {
rs, _, err := client.ExecuteCommand(context.Background(), channel.Id, "/test setup fuzz 1 1 1")
require.NoError(t, err)
require.Equal(t, "Created environment", rs.Text, rs.Text)
time.Sleep(2 * time.Second)
}
func TestLoadTestUsersCommands(t *testing.T) {
@@ -229,8 +225,6 @@ func TestLoadTestUsersCommands(t *testing.T) {
rs, _, err := client.ExecuteCommand(context.Background(), channel.Id, "/test users fuzz 1 2")
require.NoError(t, err)
require.Equal(t, "Added users", rs.Text, rs.Text)
time.Sleep(2 * time.Second)
}
func TestLoadTestChannelsCommands(t *testing.T) {
@@ -250,8 +244,6 @@ func TestLoadTestChannelsCommands(t *testing.T) {
rs, _, err := client.ExecuteCommand(context.Background(), channel.Id, "/test channels fuzz 1 2")
require.NoError(t, err)
require.Equal(t, "Added channels", rs.Text, rs.Text)
time.Sleep(2 * time.Second)
}
func TestLoadTestPostsCommands(t *testing.T) {
@@ -271,8 +263,6 @@ func TestLoadTestPostsCommands(t *testing.T) {
rs, _, err := client.ExecuteCommand(context.Background(), channel.Id, "/test posts fuzz 2 3 2")
require.NoError(t, err)
require.Equal(t, "Added posts", rs.Text, rs.Text)
time.Sleep(2 * time.Second)
}
func TestLeaveCommands(t *testing.T) {
@@ -352,7 +342,7 @@ func TestMeCommand(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, r1, "Command failed to execute")
time.Sleep(100 * time.Millisecond)
time.Sleep(time.Second)
p1, _, err := client.GetPostsForChannel(context.Background(), channel.Id, 0, 2, "", false, false)
require.NoError(t, err)
@@ -454,8 +444,7 @@ func TestShrugCommand(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, r1, "Command failed to execute")
time.Sleep(100 * time.Millisecond)
time.Sleep(time.Second)
p1, _, err := client.GetPostsForChannel(context.Background(), channel.Id, 0, 2, "", false, false)
require.NoError(t, err)
require.Len(t, p1.Order, 2, "Command failed to send")
@@ -480,8 +469,7 @@ func commandAndTest(t *testing.T, th *TestHelper, status string) {
require.NoError(t, err)
require.NotEqual(t, "Command failed to execute", r1)
time.Sleep(1000 * time.Millisecond)
time.Sleep(2 * time.Second)
rstatus, _, err := client.GetUserStatus(context.Background(), user.Id, "")
require.NoError(t, err)
require.Equal(t, status, rstatus.Status, "Error setting status")