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 удалений

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

@@ -53,8 +53,8 @@ func lock(t *testing.T, m *Mutex) {
}()
select {
case <-time.After(1 * time.Second):
require.Fail(t, "failed to lock mutex within 1 second")
case <-time.After(2 * time.Second):
require.Fail(t, "failed to lock mutex within 2 seconds")
case <-done:
}
}
@@ -75,8 +75,8 @@ func unlock(t *testing.T, m *Mutex, panics bool) {
}()
select {
case <-time.After(1 * time.Second):
require.Fail(t, "failed to unlock mutex within 1 second")
case <-time.After(2 * time.Second):
require.Fail(t, "failed to unlock mutex within 2 seconds")
case <-done:
}
}
@@ -122,7 +122,7 @@ func TestMutex(t *testing.T) {
}()
select {
case <-time.After(1 * time.Second):
case <-time.After(2 * time.Second):
case <-done:
require.Fail(t, "second goroutine should not have locked")
}

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

@@ -126,7 +126,7 @@ func TestMemoryStoreSet(t *testing.T) {
assert.NoError(t, err)
assert.True(t, ok)
time.Sleep(time.Second)
time.Sleep(2 * time.Second)
isNil(t, &store, "key")
})
@@ -461,7 +461,7 @@ func TestMemoryStoreDeleteAll(t *testing.T) {
})
}
func isNil(t *testing.T, store *pluginapi.MemoryStore, key string) {
func isNil(t require.TestingT, store *pluginapi.MemoryStore, key string) {
var out []byte
err := store.Get(key, &out)
require.NoError(t, err)