From d3c4f16eab5f6b6f4792cfe4f81681b11fe9ef1d Mon Sep 17 00:00:00 2001 From: Yahor Yuzefovich Date: Mon, 17 Jul 2023 15:03:44 -0700 Subject: [PATCH] sqlnoccltest: extract new test package that doesn't import CCL This allows for the single test in this package (that expects that CCL code is not loaded) to pass when `ccl` package is loaded by `sql` tests. There is currently no enforcement that `sqlnoccltest` doesn't import `ccl`. This adjustment is needed because the following commit introduces a dependency on `ccl` into `sql_test`. The alternative solution would be to adjust a couple of expected error messages in `TestRemovePartitioningOSS` to match the behavior when `ccl` is loaded. Release note: None --- pkg/BUILD.bazel | 2 ++ pkg/sql/BUILD.bazel | 1 - pkg/sql/sqlnoccltest/BUILD.bazel | 27 ++++++++++++++++++++ pkg/sql/sqlnoccltest/main_test.go | 27 ++++++++++++++++++++ pkg/sql/{ => sqlnoccltest}/partition_test.go | 2 +- 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 pkg/sql/sqlnoccltest/BUILD.bazel create mode 100644 pkg/sql/sqlnoccltest/main_test.go rename pkg/sql/{ => sqlnoccltest}/partition_test.go (99%) diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index 787de18de815..100f0e42a109 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel @@ -556,6 +556,7 @@ ALL_TESTS = [ "//pkg/sql/sqlitelogictest/tests/local:local_test", "//pkg/sql/sqlliveness/slinstance:slinstance_test", "//pkg/sql/sqlliveness/slstorage:slstorage_test", + "//pkg/sql/sqlnoccltest:sqlnoccltest_test", "//pkg/sql/sqlstats/insights/integration:integration_test", "//pkg/sql/sqlstats/insights:insights_test", "//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil:sqlstatsutil_test", @@ -2052,6 +2053,7 @@ GO_TARGETS = [ "//pkg/sql/sqlliveness/slstorage:slstorage_test", "//pkg/sql/sqlliveness/sqllivenesstestutils:sqllivenesstestutils", "//pkg/sql/sqlliveness:sqlliveness", + "//pkg/sql/sqlnoccltest:sqlnoccltest_test", "//pkg/sql/sqlstats/insights/integration:integration_test", "//pkg/sql/sqlstats/insights:insights", "//pkg/sql/sqlstats/insights:insights_test", diff --git a/pkg/sql/BUILD.bazel b/pkg/sql/BUILD.bazel index bc2e2e5b049d..be61e6f0b4ea 100644 --- a/pkg/sql/BUILD.bazel +++ b/pkg/sql/BUILD.bazel @@ -658,7 +658,6 @@ go_test( "mutation_test.go", "mvcc_backfiller_test.go", "normalization_test.go", - "partition_test.go", "pg_metadata_test.go", "pg_oid_test.go", "pgwire_internal_test.go", diff --git a/pkg/sql/sqlnoccltest/BUILD.bazel b/pkg/sql/sqlnoccltest/BUILD.bazel new file mode 100644 index 000000000000..2dee6658ad45 --- /dev/null +++ b/pkg/sql/sqlnoccltest/BUILD.bazel @@ -0,0 +1,27 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_test") + +go_test( + name = "sqlnoccltest_test", + srcs = [ + "main_test.go", + "partition_test.go", + ], + args = ["-test.timeout=295s"], + deps = [ + "//pkg/config/zonepb", + "//pkg/keys", + "//pkg/security/securityassets", + "//pkg/security/securitytest", + "//pkg/server", + "//pkg/sql/catalog/catalogkeys", + "//pkg/sql/catalog/catpb", + "//pkg/sql/catalog/desctestutils", + "//pkg/sql/tests", + "//pkg/testutils/serverutils", + "//pkg/testutils/sqlutils", + "//pkg/util/encoding", + "//pkg/util/leaktest", + "//pkg/util/log", + "//pkg/util/protoutil", + ], +) diff --git a/pkg/sql/sqlnoccltest/main_test.go b/pkg/sql/sqlnoccltest/main_test.go new file mode 100644 index 000000000000..440cf9544366 --- /dev/null +++ b/pkg/sql/sqlnoccltest/main_test.go @@ -0,0 +1,27 @@ +// Copyright 2023 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package sqlnoccltest_test + +import ( + "os" + "testing" + + "github.com/cockroachdb/cockroach/pkg/security/securityassets" + "github.com/cockroachdb/cockroach/pkg/security/securitytest" + "github.com/cockroachdb/cockroach/pkg/server" + "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" +) + +func TestMain(m *testing.M) { + securityassets.SetLoader(securitytest.EmbeddedAssets) + serverutils.InitTestServerFactory(server.TestServerFactory) + os.Exit(m.Run()) +} diff --git a/pkg/sql/partition_test.go b/pkg/sql/sqlnoccltest/partition_test.go similarity index 99% rename from pkg/sql/partition_test.go rename to pkg/sql/sqlnoccltest/partition_test.go index 6da5104d9ae8..ac985d76d4f6 100644 --- a/pkg/sql/partition_test.go +++ b/pkg/sql/sqlnoccltest/partition_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package sql_test +package sqlnoccltest_test import ( "context"