Skip to content

Commit

Permalink
Merge #73416
Browse files Browse the repository at this point in the history
73416: spanconfig/{sqltranslator,testcluster}: support multi-tenant tests r=irfansharif a=irfansharif

**spanconfig/{sqltranslator,testcluster}: support multi-tenant tests**

We introduce a nimble testing framework for multi-tenant span config
tests, and use it to power tests for spanconfig.SQLTranslator when run
on behalf of secondary tenants. This framework will see further addition
when testing spanconfig.Reconciler -- we'll maintain a handle on each
tenant's reconciler, kvaccessor, and use both to determine what
span config mutations are made after SQL changes.

This commit also leverages the ExcludeDroppedDescriptorsFromLookup
testing knob we introduced in an earlier commit -- it obviates the need
for arbitrary sleeps (which are both fragile and slow). It also packages
a PrintSpanConfigDiffedAgainstDefaults helper that we'll use in a future
PR (#71994).


**sqltranslatorccl: carve standalone package for tests**

Rename-only commit. We'll use subpackages within ccl/spanconfigccl when
testing other components (spanconfig.Reconciler; [#71994](#71994)).


**spanconfig/{watcher,translator}: add testing knobs**

We introduce two testing knobs that we'll use in future commits:

- SQLWatcherCheckpointNoopsEveryDurationOverride, if set, will override
  how often the SQLWatcher checkpoints no-ops (follow up to [#73171](#73171))

- ExcludeDroppedDescriptorsFromLookup will control whether the
  SQLTranslator ignores dropped descriptors. We'll also use this knob
  for the Reconciler ([#71994](#71994)), for the same purpose. Ignoring dropped
  descriptors in tests is a convenient (and faster!) alternative to
  waiting for the descriptor to actually get GC-ed by the GC job. It
  also makes it easier to order events transactionally -- it's
  sufficient for a checkpoint to cross the timestamp when the table is
  dropped, instead of waiting for the GC job to pick it up post TTL.
  This latter form is used in our current sqltranslator tests where we
  sleep arbitrarily:

      # Sleep for 5 seconds, which is more than the TTL on db.t1, so that
      # the gc job can delete the descriptor.
      sleep duration=5

  This is unfortunate and makes for slower tests than necessary. We can
  get rid of it in a subsequent commit.

Release note: None



Co-authored-by: irfan sharif <irfanmahmoudsharif@gmail.com>
  • Loading branch information
craig[bot] and irfansharif committed Dec 6, 2021
2 parents 9ec721a + 8bfbe7f commit f7a62c8
Show file tree
Hide file tree
Showing 31 changed files with 1,244 additions and 516 deletions.
2 changes: 1 addition & 1 deletion pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ALL_TESTS = [
"//pkg/ccl/serverccl/diagnosticsccl:diagnosticsccl_test",
"//pkg/ccl/serverccl/statusccl:statusccl_test",
"//pkg/ccl/serverccl:serverccl_test",
"//pkg/ccl/spanconfigccl:spanconfigccl_test",
"//pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl:spanconfigsqltranslatorccl_test",
"//pkg/ccl/sqlproxyccl/denylist:denylist_test",
"//pkg/ccl/sqlproxyccl/idle:idle_test",
"//pkg/ccl/sqlproxyccl/tenant:tenant_test",
Expand Down
269 changes: 0 additions & 269 deletions pkg/ccl/spanconfigccl/datadriven_test.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "spanconfigccl_test",
name = "spanconfigsqltranslatorccl_test",
srcs = [
"datadriven_test.go",
"main_test.go",
],
data = glob(["testdata/**"]),
deps = [
"//pkg/base",
"//pkg/ccl/kvccl/kvtenantccl",
"//pkg/ccl/partitionccl",
"//pkg/ccl/utilccl",
"//pkg/config/zonepb",
"//pkg/kv",
"//pkg/roachpb:with-mocks",
"//pkg/security",
"//pkg/security/securitytest",
"//pkg/server",
"//pkg/spanconfig",
"//pkg/sql",
"//pkg/sql/catalog/catalogkv",
"//pkg/spanconfig/spanconfigtestutils",
"//pkg/spanconfig/spanconfigtestutils/spanconfigtestcluster",
"//pkg/sql/catalog/descpb",
"//pkg/sql/catalog/descs",
"//pkg/sql/catalog/tabledesc",
"//pkg/sql/sem/tree",
"//pkg/testutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/sqlutils",
"//pkg/testutils/testcluster",
Expand Down
Loading

0 comments on commit f7a62c8

Please sign in to comment.