diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2bb935bdff7f..695a918ced8a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -134,6 +134,7 @@ /pkg/ccl/oidcccl/ @cockroachdb/server-prs /pkg/ccl/partitionccl/ @cockroachdb/sql-schema @cockroachdb/multiregion /pkg/ccl/serverccl/ @cockroachdb/server-prs +/pkg/ccl/serverccl/statusccl @cockroachdb/sql-observability /pkg/ccl/telemetryccl/ @cockroachdb/obs-inf-prs /pkg/ccl/testccl/sqlccl/ @cockroachdb/sql-queries /pkg/ccl/testccl/workload/schemachange/ @cockroachdb/sql-schema diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index 2ca6052d9c9b..c9b28e7d8773 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel @@ -31,6 +31,7 @@ ALL_TESTS = [ "//pkg/ccl/oidcccl:oidcccl_test", "//pkg/ccl/partitionccl:partitionccl_test", "//pkg/ccl/serverccl/diagnosticsccl:diagnosticsccl_test", + "//pkg/ccl/serverccl/statusccl:statusccl_test", "//pkg/ccl/serverccl:serverccl_test", "//pkg/ccl/spanconfigccl:spanconfigccl_test", "//pkg/ccl/sqlproxyccl/denylist:denylist_test", diff --git a/pkg/ccl/serverccl/BUILD.bazel b/pkg/ccl/serverccl/BUILD.bazel index 50323a416b59..ef0ed35485d1 100644 --- a/pkg/ccl/serverccl/BUILD.bazel +++ b/pkg/ccl/serverccl/BUILD.bazel @@ -2,27 +2,9 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "serverccl", - srcs = [ - "doc.go", - "tenant_test_utils.go", - ], + srcs = ["doc.go"], importpath = "github.com/cockroachdb/cockroach/pkg/ccl/serverccl", visibility = ["//visibility:public"], - deps = [ - "//pkg/base", - "//pkg/roachpb:with-mocks", - "//pkg/security", - "//pkg/server/serverpb", - "//pkg/sql/pgwire", - "//pkg/sql/sqlstats/persistedsqlstats", - "//pkg/sql/tests", - "//pkg/testutils/serverutils", - "//pkg/testutils/sqlutils", - "//pkg/util/httputil", - "//pkg/util/log", - "//pkg/util/protoutil", - "@com_github_stretchr_testify//require", - ], ) go_test( @@ -33,8 +15,6 @@ go_test( "main_test.go", "role_authentication_test.go", "server_sql_test.go", - "tenant_grpc_test.go", - "tenant_status_test.go", "tenant_vars_test.go", ], embed = [":serverccl"], @@ -45,21 +25,14 @@ go_test( "//pkg/ccl/utilccl", "//pkg/ccl/utilccl/licenseccl", "//pkg/roachpb:with-mocks", - "//pkg/rpc", "//pkg/security", "//pkg/security/securitytest", "//pkg/server", "//pkg/server/serverpb", "//pkg/sql", - "//pkg/sql/catalog/catconstants", - "//pkg/sql/catalog/descpb", - "//pkg/sql/idxusage", "//pkg/sql/pgwire/pgcode", - "//pkg/sql/sqlstats", "//pkg/sql/tests", - "//pkg/testutils", "//pkg/testutils/serverutils", - "//pkg/testutils/skip", "//pkg/testutils/sqlutils", "//pkg/testutils/testcluster", "//pkg/util", @@ -68,7 +41,6 @@ go_test( "//pkg/util/log", "//pkg/util/randutil", "//pkg/util/timeutil", - "@com_github_cockroachdb_errors//:errors", "@com_github_elastic_gosigar//:gosigar", "@com_github_lib_pq//:pq", "@com_github_prometheus_client_model//go", diff --git a/pkg/ccl/serverccl/statusccl/BUILD.bazel b/pkg/ccl/serverccl/statusccl/BUILD.bazel new file mode 100644 index 000000000000..a75643787674 --- /dev/null +++ b/pkg/ccl/serverccl/statusccl/BUILD.bazel @@ -0,0 +1,61 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") + +go_library( + name = "statusccl", + srcs = ["tenant_test_utils.go"], + importpath = "github.com/cockroachdb/cockroach/pkg/ccl/serverccl/statusccl", + visibility = ["//visibility:public"], + deps = [ + "//pkg/base", + "//pkg/roachpb:with-mocks", + "//pkg/security", + "//pkg/server/serverpb", + "//pkg/sql/pgwire", + "//pkg/sql/sqlstats/persistedsqlstats", + "//pkg/sql/tests", + "//pkg/testutils/serverutils", + "//pkg/testutils/sqlutils", + "//pkg/util/httputil", + "//pkg/util/log", + "//pkg/util/protoutil", + "@com_github_stretchr_testify//require", + ], +) + +go_test( + name = "statusccl_test", + srcs = [ + "main_test.go", + "tenant_grpc_test.go", + "tenant_status_test.go", + ], + embed = [":statusccl"], + deps = [ + "//pkg/base", + "//pkg/ccl", + "//pkg/ccl/kvccl", + "//pkg/ccl/utilccl", + "//pkg/roachpb:with-mocks", + "//pkg/rpc", + "//pkg/security", + "//pkg/security/securitytest", + "//pkg/server", + "//pkg/server/serverpb", + "//pkg/sql/catalog/catconstants", + "//pkg/sql/catalog/descpb", + "//pkg/sql/idxusage", + "//pkg/sql/sqlstats", + "//pkg/sql/tests", + "//pkg/testutils", + "//pkg/testutils/serverutils", + "//pkg/testutils/skip", + "//pkg/testutils/sqlutils", + "//pkg/testutils/testcluster", + "//pkg/util/leaktest", + "//pkg/util/log", + "//pkg/util/randutil", + "//pkg/util/timeutil", + "@com_github_cockroachdb_errors//:errors", + "@com_github_stretchr_testify//require", + ], +) diff --git a/pkg/ccl/serverccl/statusccl/main_test.go b/pkg/ccl/serverccl/statusccl/main_test.go new file mode 100644 index 000000000000..6f7436229e1c --- /dev/null +++ b/pkg/ccl/serverccl/statusccl/main_test.go @@ -0,0 +1,34 @@ +// Copyright 2021 The Cockroach Authors. +// +// Licensed as a CockroachDB Enterprise file under the Cockroach Community +// License (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt + +package statusccl + +import ( + "os" + "testing" + + _ "github.com/cockroachdb/cockroach/pkg/ccl" + "github.com/cockroachdb/cockroach/pkg/ccl/utilccl" + "github.com/cockroachdb/cockroach/pkg/security" + "github.com/cockroachdb/cockroach/pkg/security/securitytest" + "github.com/cockroachdb/cockroach/pkg/server" + "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" + "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" + "github.com/cockroachdb/cockroach/pkg/util/randutil" +) + +func TestMain(m *testing.M) { + defer utilccl.TestingEnableEnterprise()() + security.SetAssetLoader(securitytest.EmbeddedAssets) + randutil.SeedForTests() + serverutils.InitTestServerFactory(server.TestServerFactory) + serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) + os.Exit(m.Run()) +} + +//go:generate ../../../util/leaktest/add-leaktest.sh *_test.go diff --git a/pkg/ccl/serverccl/tenant_grpc_test.go b/pkg/ccl/serverccl/statusccl/tenant_grpc_test.go similarity index 99% rename from pkg/ccl/serverccl/tenant_grpc_test.go rename to pkg/ccl/serverccl/statusccl/tenant_grpc_test.go index 6417932b08b2..ee2d54189eb1 100644 --- a/pkg/ccl/serverccl/tenant_grpc_test.go +++ b/pkg/ccl/serverccl/statusccl/tenant_grpc_test.go @@ -6,7 +6,7 @@ // // https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt -package serverccl +package statusccl import ( "context" diff --git a/pkg/ccl/serverccl/tenant_status_test.go b/pkg/ccl/serverccl/statusccl/tenant_status_test.go similarity index 99% rename from pkg/ccl/serverccl/tenant_status_test.go rename to pkg/ccl/serverccl/statusccl/tenant_status_test.go index 03c1a4b1f877..136afa80dfd4 100644 --- a/pkg/ccl/serverccl/tenant_status_test.go +++ b/pkg/ccl/serverccl/statusccl/tenant_status_test.go @@ -6,7 +6,7 @@ // // https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt -package serverccl +package statusccl import ( "context" diff --git a/pkg/ccl/serverccl/tenant_test_utils.go b/pkg/ccl/serverccl/statusccl/tenant_test_utils.go similarity index 99% rename from pkg/ccl/serverccl/tenant_test_utils.go rename to pkg/ccl/serverccl/statusccl/tenant_test_utils.go index ba882aee8041..f0afda6378ba 100644 --- a/pkg/ccl/serverccl/tenant_test_utils.go +++ b/pkg/ccl/serverccl/statusccl/tenant_test_utils.go @@ -6,7 +6,7 @@ // // https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt -package serverccl +package statusccl import ( "context"