Skip to content

Commit

Permalink
sql/logictest: add MVCC range tombstone test configs
Browse files Browse the repository at this point in the history
This patch adds two new test configurations, `fakedist-range-tombstone`
and `3node-tenant-range-tombstone`, for the SQL logic tests. These write
a single, global MVCC range tombstone across the entire user keyspace
during cluster bootstrapping. This should not semantically affect the
test data written above it, but will activate MVCC range tombstone code
paths in the storage layer for testing.

Release justification: non-production code changes

Release note: None
  • Loading branch information
erikgrinaker committed Aug 25, 2022
1 parent a9f4006 commit ea3c48b
Show file tree
Hide file tree
Showing 29 changed files with 3,907 additions and 17 deletions.
12 changes: 12 additions & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ALL_TESTS = [
"//pkg/ccl/logictestccl/tests/3node-tenant:3node-tenant_test",
"//pkg/ccl/logictestccl/tests/5node:5node_test",
"//pkg/ccl/logictestccl/tests/fakedist-disk:fakedist-disk_test",
"//pkg/ccl/logictestccl/tests/fakedist-range-tombstone:fakedist-range-tombstone_test",
"//pkg/ccl/logictestccl/tests/fakedist-vec-off:fakedist-vec-off_test",
"//pkg/ccl/logictestccl/tests/fakedist:fakedist_test",
"//pkg/ccl/logictestccl/tests/local-vec-off:local-vec-off_test",
Expand Down Expand Up @@ -357,6 +358,7 @@ ALL_TESTS = [
"//pkg/sql/logictest/tests/5node-disk:5node-disk_test",
"//pkg/sql/logictest/tests/5node:5node_test",
"//pkg/sql/logictest/tests/fakedist-disk:fakedist-disk_test",
"//pkg/sql/logictest/tests/fakedist-range-tombstone:fakedist-range-tombstone_test",
"//pkg/sql/logictest/tests/fakedist-vec-off:fakedist-vec-off_test",
"//pkg/sql/logictest/tests/fakedist:fakedist_test",
"//pkg/sql/logictest/tests/local-mixed-22.1-22.2:local-mixed-22_1-22_2_test",
Expand All @@ -374,6 +376,7 @@ ALL_TESTS = [
"//pkg/sql/opt/distribution:distribution_test",
"//pkg/sql/opt/exec/execbuilder/tests/5node:5node_test",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist-disk:fakedist-disk_test",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist-range-tombstone:fakedist-range-tombstone_test",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist-vec-off:fakedist-vec-off_test",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist:fakedist_test",
"//pkg/sql/opt/exec/execbuilder/tests/local-vec-off:local-vec-off_test",
Expand Down Expand Up @@ -460,6 +463,7 @@ ALL_TESTS = [
"//pkg/sql/sqlinstance/instanceprovider:instanceprovider_test",
"//pkg/sql/sqlinstance/instancestorage:instancestorage_test",
"//pkg/sql/sqlitelogictest/tests/fakedist-disk:fakedist-disk_test",
"//pkg/sql/sqlitelogictest/tests/fakedist-range-tombstone:fakedist-range-tombstone_test",
"//pkg/sql/sqlitelogictest/tests/fakedist-vec-off:fakedist-vec-off_test",
"//pkg/sql/sqlitelogictest/tests/fakedist:fakedist_test",
"//pkg/sql/sqlitelogictest/tests/local-vec-off:local-vec-off_test",
Expand Down Expand Up @@ -685,6 +689,7 @@ GO_TARGETS = [
"//pkg/ccl/logictestccl/tests/3node-tenant:3node-tenant_test",
"//pkg/ccl/logictestccl/tests/5node:5node_test",
"//pkg/ccl/logictestccl/tests/fakedist-disk:fakedist-disk_test",
"//pkg/ccl/logictestccl/tests/fakedist-range-tombstone:fakedist-range-tombstone_test",
"//pkg/ccl/logictestccl/tests/fakedist-vec-off:fakedist-vec-off_test",
"//pkg/ccl/logictestccl/tests/fakedist:fakedist_test",
"//pkg/ccl/logictestccl/tests/local-vec-off:local-vec-off_test",
Expand Down Expand Up @@ -1455,6 +1460,7 @@ GO_TARGETS = [
"//pkg/sql/logictest/tests/5node-disk:5node-disk_test",
"//pkg/sql/logictest/tests/5node:5node_test",
"//pkg/sql/logictest/tests/fakedist-disk:fakedist-disk_test",
"//pkg/sql/logictest/tests/fakedist-range-tombstone:fakedist-range-tombstone_test",
"//pkg/sql/logictest/tests/fakedist-vec-off:fakedist-vec-off_test",
"//pkg/sql/logictest/tests/fakedist:fakedist_test",
"//pkg/sql/logictest/tests/local-mixed-22.1-22.2:local-mixed-22_1-22_2_test",
Expand All @@ -1481,6 +1487,7 @@ GO_TARGETS = [
"//pkg/sql/opt/distribution:distribution_test",
"//pkg/sql/opt/exec/execbuilder/tests/5node:5node_test",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist-disk:fakedist-disk_test",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist-range-tombstone:fakedist-range-tombstone_test",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist-vec-off:fakedist-vec-off_test",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist:fakedist_test",
"//pkg/sql/opt/exec/execbuilder/tests/local-vec-off:local-vec-off_test",
Expand Down Expand Up @@ -1689,6 +1696,7 @@ GO_TARGETS = [
"//pkg/sql/sqlinstance/instancestorage:instancestorage_test",
"//pkg/sql/sqlinstance:sqlinstance",
"//pkg/sql/sqlitelogictest/tests/fakedist-disk:fakedist-disk_test",
"//pkg/sql/sqlitelogictest/tests/fakedist-range-tombstone:fakedist-range-tombstone_test",
"//pkg/sql/sqlitelogictest/tests/fakedist-vec-off:fakedist-vec-off_test",
"//pkg/sql/sqlitelogictest/tests/fakedist:fakedist_test",
"//pkg/sql/sqlitelogictest/tests/local-vec-off:local-vec-off_test",
Expand Down Expand Up @@ -2119,6 +2127,7 @@ GET_X_DATA_TARGETS = [
"//pkg/ccl/logictestccl/tests/5node:get_x_data",
"//pkg/ccl/logictestccl/tests/fakedist:get_x_data",
"//pkg/ccl/logictestccl/tests/fakedist-disk:get_x_data",
"//pkg/ccl/logictestccl/tests/fakedist-range-tombstone:get_x_data",
"//pkg/ccl/logictestccl/tests/fakedist-vec-off:get_x_data",
"//pkg/ccl/logictestccl/tests/local:get_x_data",
"//pkg/ccl/logictestccl/tests/local-vec-off:get_x_data",
Expand Down Expand Up @@ -2578,6 +2587,7 @@ GET_X_DATA_TARGETS = [
"//pkg/sql/logictest/tests/5node-disk:get_x_data",
"//pkg/sql/logictest/tests/fakedist:get_x_data",
"//pkg/sql/logictest/tests/fakedist-disk:get_x_data",
"//pkg/sql/logictest/tests/fakedist-range-tombstone:get_x_data",
"//pkg/sql/logictest/tests/fakedist-vec-off:get_x_data",
"//pkg/sql/logictest/tests/local:get_x_data",
"//pkg/sql/logictest/tests/local-mixed-22.1-22.2:get_x_data",
Expand All @@ -2599,6 +2609,7 @@ GET_X_DATA_TARGETS = [
"//pkg/sql/opt/exec/execbuilder/tests/5node:get_x_data",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist:get_x_data",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist-disk:get_x_data",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist-range-tombstone:get_x_data",
"//pkg/sql/opt/exec/execbuilder/tests/fakedist-vec-off:get_x_data",
"//pkg/sql/opt/exec/execbuilder/tests/local:get_x_data",
"//pkg/sql/opt/exec/execbuilder/tests/local-vec-off:get_x_data",
Expand Down Expand Up @@ -2727,6 +2738,7 @@ GET_X_DATA_TARGETS = [
"//pkg/sql/sqlitelogictest:get_x_data",
"//pkg/sql/sqlitelogictest/tests/fakedist:get_x_data",
"//pkg/sql/sqlitelogictest/tests/fakedist-disk:get_x_data",
"//pkg/sql/sqlitelogictest/tests/fakedist-range-tombstone:get_x_data",
"//pkg/sql/sqlitelogictest/tests/fakedist-vec-off:get_x_data",
"//pkg/sql/sqlitelogictest/tests/local:get_x_data",
"//pkg/sql/sqlitelogictest/tests/local-vec-off:get_x_data",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/ccl/logictestccl/tests/3node-tenant/generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/ccl/logictestccl/tests/5node/generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions pkg/ccl/logictestccl/tests/fakedist-range-tombstone/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data")
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "fakedist-range-tombstone_test",
size = "enormous",
srcs = ["generated_test.go"],
data = [
"//c-deps:libgeos", # keep
"//pkg/ccl/logictestccl:testdata", # keep
],
shard_count = 3,
tags = ["cpu:2"],
deps = [
"//pkg/build/bazel",
"//pkg/ccl",
"//pkg/ccl/utilccl",
"//pkg/security/securityassets",
"//pkg/security/securitytest",
"//pkg/server",
"//pkg/sql/logictest",
"//pkg/testutils/serverutils",
"//pkg/testutils/skip",
"//pkg/testutils/testcluster",
"//pkg/util/leaktest",
"//pkg/util/randutil",
],
)

get_x_data(name = "get_x_data")

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions pkg/kv/kvserver/client_raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,39 @@ func mustGetInt(v *roachpb.Value) int64 {
return i
}

func TestXXX(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)

stickyEngineRegistry := server.NewStickyInMemEnginesRegistry()
defer stickyEngineRegistry.CloseAllStickyInMemEngines()

ctx := context.Background()
tc := testcluster.StartTestCluster(t, 1,
base.TestClusterArgs{
ReplicationMode: base.ReplicationManual,
ServerArgs: base.TestServerArgs{
StoreSpecs: []base.StoreSpec{
{
InMemory: true,
StickyInMemoryEngineID: "1",
},
},
Knobs: base.TestingKnobs{
Server: &server.TestingKnobs{
StickyEngineRegistry: stickyEngineRegistry,
},
Store: &kvserver.StoreTestingKnobs{
GlobalMVCCRangeTombstone: true,
},
},
},
})
defer tc.Stopper().Stop(ctx)

time.Sleep(5 * time.Second)
}

// TestStoreRecoverFromEngine verifies that the store recovers all ranges and their contents
// after being stopped and recreated.
func TestStoreRecoverFromEngine(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/sql/logictest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ go_library(
"//pkg/base",
"//pkg/cloud/externalconn/providers",
"//pkg/clusterversion",
"//pkg/kv/kvclient/rangefeed",
"//pkg/kv/kvserver",
"//pkg/kv/kvserver/kvserverbase",
"//pkg/roachpb",
"//pkg/security/username",
"//pkg/server",
Expand Down
11 changes: 10 additions & 1 deletion pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ import (
"github.com/cockroachdb/cockroach/pkg/base"
_ "github.com/cockroachdb/cockroach/pkg/cloud/externalconn/providers" // imported to register ExternalConnection providers
"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangefeed"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/server"
Expand Down Expand Up @@ -1197,7 +1199,11 @@ func (t *logicTest) newCluster(
Knobs: base.TestingKnobs{
Store: &kvserver.StoreTestingKnobs{
// The consistency queue makes a lot of noisy logs during logic tests.
DisableConsistencyQueue: true,
DisableConsistencyQueue: true,
GlobalMVCCRangeTombstone: t.cfg.GlobalMVCCRangeTombstone,
EvalKnobs: kvserverbase.BatchEvalTestingKnobs{
DisableInitPutFailOnTombstones: t.cfg.GlobalMVCCRangeTombstone,
},
},
SQLEvalContext: &eval.TestingKnobs{
AssertBinaryExprReturnTypes: true,
Expand All @@ -1217,6 +1223,9 @@ func (t *logicTest) newCluster(
SQLDeclarativeSchemaChanger: &scexec.TestingKnobs{
BeforeStage: corpusCollectionCallback,
},
RangeFeed: rangefeed.TestingKnobs{
IgnoreOnDeleteRangeError: t.cfg.GlobalMVCCRangeTombstone,
},
},
ClusterName: "testclustername",
ExternalIODir: t.sharedIODir,
Expand Down
Loading

0 comments on commit ea3c48b

Please sign in to comment.