Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: fix flaky TestWorkspaceProxy_Server_PrometheusEnabled #12645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions enterprise/cli/proxyserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cli_test
import (
"bufio"
"context"
"errors"
"fmt"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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")

Expand Down