Skip to content

Commit

Permalink
changefeedccl: update nemeses test to use the declarative schema changer
Browse files Browse the repository at this point in the history
This change updates the nemeses test, which asserts the behavior of changefeeds
under a randomized DML/DDL workload. Previously, the test would only run
with the legacy schema changer. This is not ideal because, by default, the
declarative schema changer is used in production. This change makes it so that
the declarative schema changer is used 90% of the time instead.

Informs: cockroachdb#106906
Epic: none

Release note: None
  • Loading branch information
jayshrivastava committed Aug 2, 2023
1 parent 53835a5 commit b65ea13
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
1 change: 0 additions & 1 deletion pkg/ccl/changefeedccl/cdctest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ go_library(
"//pkg/util/fsm",
"//pkg/util/hlc",
"//pkg/util/log",
"//pkg/util/randutil",
"//pkg/util/syncutil",
"//pkg/util/timeutil",
"@com_github_cockroachdb_errors//:errors",
Expand Down
6 changes: 3 additions & 3 deletions pkg/ccl/changefeedccl/cdctest/nemeses.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

"github.com/cockroachdb/cockroach/pkg/util/fsm"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/randutil"
"github.com/cockroachdb/errors"
)

Expand All @@ -30,7 +29,9 @@ import (
// duplicates, which the two cdctest.Validator implementations verify for the
// real output of a changefeed. The output rows and resolved timestamps of the
// tested feed are fed into them to check for anomalies.
func RunNemesis(f TestFeedFactory, db *gosql.DB, isSinkless bool) (Validator, error) {
func RunNemesis(
f TestFeedFactory, db *gosql.DB, isSinkless bool, rng *rand.Rand,
) (Validator, error) {
// possible additional nemeses:
// - schema changes
// - merges
Expand All @@ -42,7 +43,6 @@ func RunNemesis(f TestFeedFactory, db *gosql.DB, isSinkless bool) (Validator, er
// - sink chaos

ctx := context.Background()
rng, _ := randutil.NewPseudoRand()

eventPauseCount := 10
if isSinkless {
Expand Down
7 changes: 0 additions & 7 deletions pkg/ccl/changefeedccl/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ func maybeDisableDeclarativeSchemaChangesForTest(
return disable
}

// disableDeclarativeSchemaChangesForTest tests that are disabled due to differences
// in changefeed behaviour and are tracked by issue #80545.
func disableDeclarativeSchemaChangesForTest(t testing.TB, sqlDB *sqlutils.SQLRunner) {
sqlDB.Exec(t, "SET use_declarative_schema_changer='off'")
sqlDB.Exec(t, "SET CLUSTER SETTING sql.defaults.use_declarative_schema_changer='off'")
}

func waitForSchemaChange(
t testing.TB, sqlDB *sqlutils.SQLRunner, stmt string, arguments ...interface{},
) {
Expand Down
8 changes: 6 additions & 2 deletions pkg/ccl/changefeedccl/nemeses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/randutil"
)

func TestChangefeedNemeses(t *testing.T) {
Expand All @@ -27,12 +28,15 @@ func TestChangefeedNemeses(t *testing.T) {
skip.UnderRace(t, "takes >1 min under race")

testFn := func(t *testing.T, s TestServer, f cdctest.TestFeedFactory) {
rng, seed := randutil.NewPseudoRand()
t.Logf("random seed: %d", seed)

sqlDB := sqlutils.MakeSQLRunner(s.DB)
disableDeclarativeSchemaChangesForTest(t, sqlDB)
_ = maybeDisableDeclarativeSchemaChangesForTest(t, sqlDB, rng)
// TODO(dan): Ugly hack to disable `eventPause` in sinkless feeds. See comment in
// `RunNemesis` for details.
isSinkless := strings.Contains(t.Name(), "sinkless")
v, err := cdctest.RunNemesis(f, s.DB, isSinkless)
v, err := cdctest.RunNemesis(f, s.DB, isSinkless, rng)
if err != nil {
t.Fatalf("%+v", err)
}
Expand Down

0 comments on commit b65ea13

Please sign in to comment.