fix: fix flaky TestWorkspaceProxy_Server_PrometheusEnabled (#12645)

This commit is contained in:
Marcin Tojek 2024-03-18 16:43:41 +01:00 committed by GitHub
parent 2cd5fbc712
commit 0e8ebb9b22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 4 deletions

View File

@ -3,7 +3,6 @@ package cli_test
import (
"bufio"
"context"
"errors"
"fmt"
"net/http"
"net/http/httptest"
@ -76,7 +75,8 @@ func TestWorkspaceProxy_Server_PrometheusEnabled(t *testing.T) {
_, _ = w.Write([]byte(`{"app_security_key": "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789123456012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789123456"}`))
return
}
if r.URL.Path == "/api/v2/workspaceproxies/me/coordinate" {
if r.URL.Path == "/api/v2/workspaceproxies/me/coordinate" ||
r.URL.Path == "/api/v2/buildinfo" {
// Slow down proxy registration, so that test runner can check if Prometheus endpoint is exposed.
wg.Wait()
@ -107,8 +107,7 @@ func TestWorkspaceProxy_Server_PrometheusEnabled(t *testing.T) {
// Start "wsproxy server" command
clitest.StartWithAssert(t, inv, func(t *testing.T, err error) {
assert.Error(t, err)
assert.False(t, errors.Is(err, context.Canceled), "error was expected, but context was canceled")
// actually no assertions are needed as the test verifies only Prometheus endpoint
})
pty.ExpectMatchContext(ctx, "Started HTTP listener at")