Skip to content

Commit

Permalink
Merge pull request #73446 from Azhng/backport21.2-72556-72692-73363
Browse files Browse the repository at this point in the history
release-21.2: improve statusccl package unit test
  • Loading branch information
Azhng committed Jan 5, 2022
2 parents a3ea612 + 5f7c9ae commit 14bcb15
Show file tree
Hide file tree
Showing 8 changed files with 371 additions and 250 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
/pkg/ccl/oidcccl/ @cockroachdb/sql-queries
/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
Expand Down
1 change: 1 addition & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ALL_TESTS = [
"//pkg/ccl/multitenantccl/tenantcostserver:tenantcostserver_test",
"//pkg/ccl/oidcccl:oidcccl_test",
"//pkg/ccl/partitionccl:partitionccl_test",
"//pkg/ccl/serverccl/statusccl:statusccl_test",
"//pkg/ccl/serverccl:serverccl_test",
"//pkg/ccl/sqlproxyccl/denylist:denylist_test",
"//pkg/ccl/sqlproxyccl/idle:idle_test",
Expand Down
28 changes: 1 addition & 27 deletions pkg/ccl/serverccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"],
Expand All @@ -45,20 +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/serverutils",
"//pkg/testutils/skip",
"//pkg/testutils/sqlutils",
"//pkg/testutils/testcluster",
"//pkg/util",
Expand Down
59 changes: 59 additions & 0 deletions pkg/ccl/serverccl/statusccl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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/serverutils",
"//pkg/testutils/skip",
"//pkg/testutils/sqlutils",
"//pkg/testutils/testcluster",
"//pkg/util/leaktest",
"//pkg/util/log",
"//pkg/util/randutil",
"//pkg/util/timeutil",
"@com_github_stretchr_testify//require",
],
)
34 changes: 34 additions & 0 deletions pkg/ccl/serverccl/statusccl/main_test.go
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt

package serverccl
package statusccl

import (
"context"
Expand Down
Loading

0 comments on commit 14bcb15

Please sign in to comment.