MM-61698: Fix TestWebHubCloseConnOnDBFail properly (#29577)

Finally I figured out why the log message for
/api/v4/websocket does not appear. It is because
the log gets generated only when the request returns,
and for websockets, the request doesn't return
until the client closes. And because we were closing
the client in a defer clause, the flushing of the logger
would happen before closing the client, therefore
leading to a race condition of the log not appearing
from time to time.

https://mattermost.atlassian.net/browse/MM-61698
```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2024-12-12 18:55:44 +05:30
коммит произвёл GitHub
родитель 832b5a3332
Коммит d20dbc3b88

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

@@ -3147,7 +3147,7 @@ func TestWebHubCloseConnOnDBFail(t *testing.T) {
wsClient, err := th.CreateWebSocketClientWithClient(cli)
require.NoError(t, err)
defer wsClient.Close()
wsClient.Close()
require.NoError(t, th.TestLogger.Flush())
}