From 81d8cc2f0281569db99a0fdb3402e05d247c37fe Mon Sep 17 00:00:00 2001 From: David Hartunian Date: Mon, 14 Jun 2021 11:12:45 -0400 Subject: [PATCH] server: TestTelemetrySQLStatsIndependence uses test reg server Previously, this test hit the real registration server which caused goroutine leaks when the reg server was unavailable. The test now creates a test reg server to handle the stats calls. The test is no longer skipped. Resolves #63851 Release note: None --- pkg/server/stats_test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/server/stats_test.go b/pkg/server/stats_test.go index 51d3f7f01631..c77369d90425 100644 --- a/pkg/server/stats_test.go +++ b/pkg/server/stats_test.go @@ -26,8 +26,8 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" "github.com/cockroachdb/cockroach/pkg/sql/tests" "github.com/cockroachdb/cockroach/pkg/testutils" + "github.com/cockroachdb/cockroach/pkg/testutils/diagutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" - "github.com/cockroachdb/cockroach/pkg/testutils/skip" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/timeutil" @@ -39,13 +39,19 @@ func TestTelemetrySQLStatsIndependence(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) - // This test fails if the central reporting server from CRL - // breaks. It should be improved to customize the reporting URL and - // mock the registration collector with an in-memory server. - skip.WithIssue(t, 63851) - ctx := context.Background() params, _ := tests.CreateTestServerParams() + + r := diagutils.NewServer() + defer r.Close() + + url := r.URL() + params.Knobs.Server = &TestingKnobs{ + DiagnosticsTestingKnobs: diagnostics.TestingKnobs{ + OverrideReportingURL: &url, + }, + } + s, sqlDB, _ := serverutils.StartServer(t, params) defer s.Stopper().Stop(ctx)