test: use static port for Prometheus (#14972)

Fixes: https://github.com/coder/internal/issues/92
This commit is contained in:
Marcin Tojek
2024-10-04 13:17:18 +02:00
committed by GitHub
parent 4369f2b4b5
commit 9acf6acd76

View File

@ -59,10 +59,11 @@ func Test_ProxyServer_Headers(t *testing.T) {
assert.EqualValues(t, 1, atomic.LoadInt64(&called))
}
//nolint:paralleltest,tparallel // Test uses a static port.
func TestWorkspaceProxy_Server_PrometheusEnabled(t *testing.T) {
t.Parallel()
prometheusPort := testutil.RandomPort(t)
// Ephemeral ports have a tendency to conflict and fail with `bind: address already in use` error.
// This workaround forces a static port for Prometheus that hopefully won't be used by other tests.
prometheusPort := 32002
var wg sync.WaitGroup
wg.Add(1)