Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cdctest: add mvcc_timestamp, diff, sink_config options to nemesis testing #139155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aerfrei
Copy link
Contributor

@aerfrei aerfrei commented Jan 15, 2025

This work adds to random changefeed settings we pass into changefeeds
in nemesis testing. This commit adds support for: changefeeds without
the diff option specified, the mvcc_timestamp option and the kafka and
pubsub sink configs.

See also: #134119

Epic: CRDB-42866

Release note: None

Copy link

blathers-crl bot commented Jan 15, 2025

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor Author

@aerfrei aerfrei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/ccl/changefeedccl/cdctest/validator.go line 388 at r5 (raw file):

	}

	if *mvccJSONText > updated.AsOfSystemTime() {

Wondering if there's a better assertion that we can make here once the mvcc timestamp exists. If I assert that this mvcc timestamp is within up to 5 seconds of the updated timestamp, the tests fail (a few times in 100).

@asg0451 asg0451 self-requested a review January 15, 2025 21:04
pkg/ccl/changefeedccl/cdctest/validator.go Outdated Show resolved Hide resolved
pkg/ccl/changefeedccl/cdctest/validator.go Outdated Show resolved Hide resolved
pkg/ccl/changefeedccl/cdctest/nemeses.go Outdated Show resolved Hide resolved
pkg/ccl/changefeedccl/cdctest/nemeses.go Show resolved Hide resolved
validators = append(validators, kivV)
}

if cfo.BooleanOptions["mvcc_timestamp"] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe use the constants in options.go instead of string literals

@asg0451
Copy link
Contributor

asg0451 commented Jan 16, 2025

looks reasonable to me. let me know when it's ready for a full review

@aerfrei aerfrei force-pushed the aerin/randomized-options-2 branch from ad8b23c to 78d22d8 Compare January 17, 2025 18:11
@aerfrei aerfrei marked this pull request as ready for review January 17, 2025 18:11
@aerfrei aerfrei requested a review from a team as a code owner January 17, 2025 18:11
@aerfrei aerfrei requested review from asg0451 and wenyihu6 and removed request for a team January 17, 2025 18:11
@aerfrei aerfrei changed the title Add mvcc_timestamp, diff, pubsub_sink_config, kafka_sink_config options to randomized changefeed testing cdctest: add mvcc_timestamp, diff, sink_config options to nemesis testing Jan 17, 2025
Copy link
Contributor Author

@aerfrei aerfrei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ready for re-review

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asg0451 and @wenyihu6)

pkg/ccl/changefeedccl/cdctest/nemeses.go Outdated Show resolved Hide resolved
pkg/ccl/changefeedccl/cdctest/nemeses.go Show resolved Hide resolved
pkg/ccl/changefeedccl/cdctest/validator.go Outdated Show resolved Hide resolved
pkg/ccl/changefeedccl/cdctest/validator.go Outdated Show resolved Hide resolved
}

retry := make(map[string]any)
if !isKafka && rand.Intn(2) < 1 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you clean up this function a bit? a lot of if isKafka && , maybe it can be nested or pulled out into a function that handles kafka specific stuff

compression := compressions[rand.Intn(len(compressions))]
base["Compression"] = compression
if compression == "GZIP" {
level := rand.Intn(10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you allow -1 too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

jsonData, err := json.Marshal(nonEmptyConfig)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you return error here or panic or something?

return err
}

if *mvccJSONText > updated.AsOfSystemTime() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also do a sanity check like > 0 or > yesterday?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
keyJSONAsArray, ok := keyJSON.AsArray()
if !ok || len(keyJSONAsArray) != len(v.primaryKeyCols) {
return errors.Errorf(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably append to v.failures here instead of returning error. ditto for (some but not all) other errors in this method

Comment on lines 161 to 163
if err != nil {
t.Fatalf("got %v expected %v", err, nil)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer assert.NoError(t, err) or require.NoError(t, err) for these

if err != nil {
t.Fatalf("got %v expected %v", err, nil)
}
if f := v.Failures(); f != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and assert.Empty() here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using the assertValidatorFailures now (with no failures) to match the rest of the file

@aerfrei aerfrei force-pushed the aerin/randomized-options-2 branch from 78d22d8 to f78327a Compare January 21, 2025 21:07
Copy link
Contributor Author

@aerfrei aerfrei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asg0451 and @wenyihu6)

compression := compressions[rand.Intn(len(compressions))]
base["Compression"] = compression
if compression == "GZIP" {
level := rand.Intn(10)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return err
}

if *mvccJSONText > updated.AsOfSystemTime() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@aerfrei aerfrei force-pushed the aerin/randomized-options-2 branch from f78327a to 0f6c777 Compare January 21, 2025 21:44
Copy link
Contributor Author

@aerfrei aerfrei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asg0451 and @wenyihu6)

if err != nil {
t.Fatalf("got %v expected %v", err, nil)
}
if f := v.Failures(); f != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using the assertValidatorFailures now (with no failures) to match the rest of the file

@aerfrei aerfrei force-pushed the aerin/randomized-options-2 branch from 0f6c777 to 080fcfc Compare January 22, 2025 14:56
…ting

This work adds to random changefeed settings we pass into changefeeds
in nemesis testing. This commit adds support for: changefeeds without
the diff option specified, the mvcc_timestamp option and the kafka and
pubsub sink configs.

See also: cockroachdb#134119

Epic: CRDB-42866

Release note: None
@aerfrei aerfrei force-pushed the aerin/randomized-options-2 branch from 080fcfc to 0dc5872 Compare January 22, 2025 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants