Skip to content

Commit

Permalink
range{feed,client},roachpb: standardize mock generation through bazel
Browse files Browse the repository at this point in the history
Fixes #67010. Also clean up some rotted gomock generation in sqlproxyccl
(mockgen usage was removed in #66369).

Release note: None
  • Loading branch information
irfansharif committed Jul 8, 2021
1 parent 36ed61e commit 25082a5
Show file tree
Hide file tree
Showing 215 changed files with 477 additions and 496 deletions.
29 changes: 21 additions & 8 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,29 @@ load("@bazel_gazelle//:def.bzl", "gazelle")
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/util/caller_test @cockroach//pkg/util/caller:caller_test
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/util/json_test @cockroach//pkg/util/json:json_test

# These packages use github.com/golang/mock to generate mocks. The target
# generating mocks for a given package necessarily depends on the package's
# go_library target, which then prevents us from including those mock symbols
# as part of the package's go_library target. We consequently export a second
# target, embedding the first but also including the mock symbols. We need to
# tell gazelle to resolve to this second target instead. See
# pkg/kv/kvclient/rangefeed/BUILD.bazel for an annotated example.
#
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/roachpb //pkg/roachpb:with-mocks
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/kv/kvclient/kvcoord //pkg/kv/kvclient/kvcoord:with-mocks
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangefeed //pkg/kv/kvclient/rangefeed:with-mocks
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangecache //pkg/kv/kvclient/rangecache:with-mocks

# See pkg/roachpb/gen/BUILD.bazel for more details.
#
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/roachpb //pkg/roachpb
# gazelle:resolve proto go roachpb/api.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/app_stats.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/data.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/errors.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/internal_raft.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/io-formats.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/metadata.proto //pkg/roachpb
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/roachpb //pkg/roachpb:with-mocks
# gazelle:resolve proto go roachpb/api.proto //pkg/roachpb:with-mocks
# gazelle:resolve proto go roachpb/app_stats.proto //pkg/roachpb:with-mocks
# gazelle:resolve proto go roachpb/data.proto //pkg/roachpb:with-mocks
# gazelle:resolve proto go roachpb/errors.proto //pkg/roachpb:with-mocks
# gazelle:resolve proto go roachpb/internal_raft.proto //pkg/roachpb:with-mocks
# gazelle:resolve proto go roachpb/io-formats.proto //pkg/roachpb:with-mocks
# gazelle:resolve proto go roachpb/metadata.proto //pkg/roachpb:with-mocks
# gazelle:exclude pkg/roachpb/batch_generated.go
# gazelle:exclude pkg/roachpb/batch_generated-gen.go

Expand Down
9 changes: 9 additions & 0 deletions build/bazelutil/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load(":lint.bzl", "lint_binary")

lint_binary(
name = "lint",
test = "//pkg/testutils/lint:lint_test",
)

# This noop target is a workaround for https://github.com/bazelbuild/bazel-gazelle/issues/1078.
# We use it in //pkg/kv/kvclient/{kvcoord,rangefeed}.
go_library(
name = "noop",
importpath = "noop",
visibility = ["//pkg:__subpackages__"],
)
1 change: 0 additions & 1 deletion pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ ALL_TESTS = [
"//pkg/ccl/streamingccl/streamproducer:streamproducer_test",
"//pkg/ccl/telemetryccl:telemetryccl_test",
"//pkg/ccl/testccl/sqlccl:sqlccl_test",
"//pkg/ccl/testccl/sqlccl:sqltestccl_test",
"//pkg/ccl/testccl/workload/schemachange:schemachange_test",
"//pkg/ccl/utilccl/sampledataccl:sampledataccl_test",
"//pkg/ccl/utilccl:utilccl_test",
Expand Down
2 changes: 1 addition & 1 deletion pkg/acceptance/localcluster/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ go_library(
"//pkg/acceptance/cluster",
"//pkg/base",
"//pkg/config/zonepb",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/rpc",
"//pkg/security",
"//pkg/server/serverpb",
Expand Down
4 changes: 2 additions & 2 deletions pkg/base/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/cli/cliflags",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/settings/cluster",
"//pkg/util",
Expand Down Expand Up @@ -55,7 +55,7 @@ go_test(
],
deps = [
":base",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/testutils",
Expand Down
2 changes: 1 addition & 1 deletion pkg/bench/rttanalysis/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/base",
"//pkg/kv/kvclient/kvcoord",
"//pkg/kv/kvclient/kvcoord:with-mocks",
"//pkg/sql",
"//pkg/testutils",
"//pkg/testutils/serverutils",
Expand Down
4 changes: 2 additions & 2 deletions pkg/blobs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/blobs/blobspb:blobspb_go_proto",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/rpc",
"//pkg/rpc/nodedialer",
"//pkg/util/fileutil",
Expand All @@ -37,7 +37,7 @@ go_test(
embed = [":blobs"],
deps = [
"//pkg/blobs/blobspb:blobspb_go_proto",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/rpc",
"//pkg/rpc/nodedialer",
"//pkg/testutils",
Expand Down
8 changes: 4 additions & 4 deletions pkg/ccl/backupccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ go_library(
"//pkg/kv/kvserver",
"//pkg/kv/kvserver/concurrency/lock",
"//pkg/kv/kvserver/protectedts",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/scheduledjobs",
"//pkg/security",
"//pkg/server/serverpb",
Expand Down Expand Up @@ -159,10 +159,10 @@ go_test(
"//pkg/jobs/jobstest",
"//pkg/keys",
"//pkg/kv",
"//pkg/kv/kvclient/kvcoord",
"//pkg/kv/kvclient/kvcoord:with-mocks",
"//pkg/kv/kvserver",
"//pkg/kv/kvserver/kvserverbase",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/scheduledjobs",
"//pkg/security",
"//pkg/security/securitytest",
Expand Down Expand Up @@ -250,7 +250,7 @@ go_proto_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/build",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/sql/catalog/descpb",
"//pkg/sql/stats",
"//pkg/util/hlc",
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/changefeedccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ go_library(
"//pkg/kv/kvserver/closedts",
"//pkg/kv/kvserver/protectedts",
"//pkg/kv/kvserver/protectedts/ptpb:ptpb_go_proto",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/server/telemetry",
"//pkg/settings",
Expand Down Expand Up @@ -155,7 +155,7 @@ go_test(
"//pkg/kv/kvserver/kvserverbase",
"//pkg/kv/kvserver/protectedts",
"//pkg/kv/kvserver/protectedts/ptpb:ptpb_go_proto",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/server",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/changefeedccl/cdctest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ go_library(
deps = [
"//pkg/ccl/changefeedccl/changefeedbase",
"//pkg/jobs/jobspb",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/sql",
"//pkg/testutils/serverutils",
"//pkg/util/fsm",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/changefeedccl/changefeeddist/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_library(
deps = [
"//pkg/jobs/jobspb",
"//pkg/kv",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/sql",
"//pkg/sql/execinfrapb",
"//pkg/sql/physicalplan",
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/changefeedccl/kvevent/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go_library(
deps = [
"//pkg/ccl/changefeedccl/changefeedbase",
"//pkg/jobs/jobspb",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/util/hlc",
"//pkg/util/log",
"//pkg/util/metric",
Expand All @@ -31,7 +31,7 @@ go_test(
deps = [
":kvevent",
"//pkg/keys",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/settings/cluster",
"//pkg/sql/rowenc",
"//pkg/sql/sem/tree",
Expand Down
6 changes: 3 additions & 3 deletions pkg/ccl/changefeedccl/kvfeed/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ go_library(
"//pkg/jobs/jobspb",
"//pkg/keys",
"//pkg/kv",
"//pkg/kv/kvclient/kvcoord",
"//pkg/roachpb",
"//pkg/kv/kvclient/kvcoord:with-mocks",
"//pkg/roachpb:with-mocks",
"//pkg/settings",
"//pkg/settings/cluster",
"//pkg/sql/covering",
Expand Down Expand Up @@ -56,7 +56,7 @@ go_test(
"//pkg/jobs/jobspb",
"//pkg/keys",
"//pkg/kv",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/server",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/changefeedccl/schemafeed/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ go_library(
"//pkg/jobs/jobspb",
"//pkg/keys",
"//pkg/kv",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/settings/cluster",
"//pkg/sql/catalog",
"//pkg/sql/catalog/catalogkv",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/cliccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ go_library(
"//pkg/cli",
"//pkg/cli/cliflags",
"//pkg/keys",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/server",
"//pkg/settings/cluster",
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/importccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ go_library(
"//pkg/kv",
"//pkg/kv/kvserver/kvserverbase",
"//pkg/kv/kvserver/protectedts",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/server/telemetry",
"//pkg/settings",
Expand Down Expand Up @@ -137,7 +137,7 @@ go_test(
"//pkg/kv",
"//pkg/kv/kvserver",
"//pkg/kv/kvserver/kvserverbase",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/server",
Expand Down
8 changes: 4 additions & 4 deletions pkg/ccl/kvccl/kvfollowerreadsccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ go_library(
"//pkg/base",
"//pkg/ccl/utilccl",
"//pkg/kv",
"//pkg/kv/kvclient/kvcoord",
"//pkg/kv/kvclient/kvcoord:with-mocks",
"//pkg/kv/kvserver",
"//pkg/kv/kvserver/closedts",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/settings",
"//pkg/settings/cluster",
"//pkg/sql",
Expand All @@ -36,11 +36,11 @@ go_test(
"//pkg/ccl/utilccl",
"//pkg/keys",
"//pkg/kv",
"//pkg/kv/kvclient/kvcoord",
"//pkg/kv/kvclient/kvcoord:with-mocks",
"//pkg/kv/kvserver",
"//pkg/kv/kvserver/closedts",
"//pkg/kv/kvserver/concurrency/lock",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/rpc",
"//pkg/security",
"//pkg/security/securitytest",
Expand Down
8 changes: 4 additions & 4 deletions pkg/ccl/kvccl/kvtenantccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ go_library(
"//pkg/config",
"//pkg/config/zonepb",
"//pkg/gossip",
"//pkg/kv/kvclient/kvcoord",
"//pkg/kv/kvclient/kvcoord:with-mocks",
"//pkg/kv/kvclient/kvtenant",
"//pkg/kv/kvclient/rangecache",
"//pkg/roachpb",
"//pkg/kv/kvclient/rangecache:with-mocks",
"//pkg/roachpb:with-mocks",
"//pkg/rpc",
"//pkg/util/contextutil",
"//pkg/util/grpcutil",
Expand Down Expand Up @@ -44,7 +44,7 @@ go_test(
"//pkg/config",
"//pkg/gossip",
"//pkg/kv/kvclient/kvtenant",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/rpc",
"//pkg/security",
"//pkg/security/securitytest",
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/multiregionccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ go_test(
"//pkg/keys",
"//pkg/kv",
"//pkg/kv/kvbase",
"//pkg/kv/kvclient/kvcoord",
"//pkg/kv/kvclient/kvcoord:with-mocks",
"//pkg/kv/kvserver",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/server",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/multiregionccl/multiregionccltestutils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/base",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/testutils/testcluster",
"@com_github_cockroachdb_errors//:errors",
],
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/oidcccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/ccl/utilccl",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/server",
"//pkg/server/serverpb",
"//pkg/server/telemetry",
Expand Down Expand Up @@ -40,7 +40,7 @@ go_test(
deps = [
"//pkg/base",
"//pkg/ccl/utilccl",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/rpc",
"//pkg/security",
"//pkg/security/securitytest",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/partitionccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ go_test(
"//pkg/jobs/jobspb",
"//pkg/keys",
"//pkg/kv/kvserver",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/server",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/serverccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ go_test(
"//pkg/ccl",
"//pkg/ccl/kvccl",
"//pkg/ccl/utilccl",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/server",
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/sqlproxyccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ go_library(
"//pkg/ccl/sqlproxyccl/idle",
"//pkg/ccl/sqlproxyccl/tenant",
"//pkg/ccl/sqlproxyccl/throttler",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security/certmgr",
"//pkg/util/contextutil",
"//pkg/util/grpcutil",
Expand Down Expand Up @@ -61,7 +61,7 @@ go_test(
"//pkg/ccl/sqlproxyccl/tenant",
"//pkg/ccl/sqlproxyccl/tenantdirsvr",
"//pkg/ccl/utilccl",
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/server",
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/sqlproxyccl/cache/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ go_library(
importpath = "github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl/cache",
visibility = ["//visibility:public"],
deps = [
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"//pkg/util/syncutil",
],
)
Expand All @@ -16,7 +16,7 @@ go_test(
srcs = ["cache_test.go"],
embed = [":cache"],
deps = [
"//pkg/roachpb",
"//pkg/roachpb:with-mocks",
"@com_github_stretchr_testify//require",
],
)
Loading

0 comments on commit 25082a5

Please sign in to comment.