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

logictest: improve non-metamorphic test handling #59208

Merged
merged 1 commit into from
Jan 21, 2021

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Jan 20, 2021

This commit refactors how non-metamorphic logic tests are handled.
Previously, if a logic test file had !metamorphic directive, then they
would be skipped when the build happened to be metamorphic (which occurs
in 80% of the time). However, this led to multiple flakes when PRs were
merged with green CI, but they didn't update the corresponding tests
(this happened because those tests were skipped).

Looking over all of those issues, we see that they are due to a couple
of randomizations - of mutations.MaxBatchSize and row.kvBatchSize,
so this commit adds a testing knob to override both of them. Now, for
every config and for every logic test file path we remember whether
non-metamorphic directive was specified and possibly disable the
randomizations of mutations.MaxBatchSize and row.kvBatchSize. This
required a bit of plumbing, but it looks acceptable.

Fixes: #59186.

Release note: None

@yuzefovich yuzefovich requested review from RaduBerinde and a team January 20, 2021 19:14
@yuzefovich yuzefovich requested a review from a team as a code owner January 20, 2021 19:14
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Awesome, thank you! :lgtm_strong:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich)


pkg/sql/logictest/logic.go, line 3108 at r1 (raw file):

	// If set, mutations.MaxBatchSize will be overridden to use the non-test
	// value.
	overrideMaxBatchSize bool

[nit] I would name this forceDefaultMaxBatchSize (override suggests the opposite)


pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic, line 113 at r1 (raw file):

  AND message NOT LIKE '%QueryTxn%'
----
dist sender send  r35: sending batch 2 CPut to (n1,s1):1

This diff has been fixed in a PR that just merged, it should go away if you rebase.

Copy link
Member Author

@yuzefovich yuzefovich 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! 1 of 0 LGTMs obtained (waiting on @RaduBerinde)


pkg/sql/logictest/logic.go, line 3108 at r1 (raw file):

Previously, RaduBerinde wrote…

[nit] I would name this forceDefaultMaxBatchSize (override suggests the opposite)

Done.


pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic, line 113 at r1 (raw file):

Previously, RaduBerinde wrote…

This diff has been fixed in a PR that just merged, it should go away if you rebase.

Thanks, rebased.

I was also curious why this diff was needed in the first place - to me it seems like some of the changes in the diff are wrong (or at least non-intuitive). I bisected it to the enabling of "always on" tracing PR. I'll open up a separate issue and tag Irfan to look into that.

Copy link
Member Author

@yuzefovich yuzefovich 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! 1 of 0 LGTMs obtained (waiting on @RaduBerinde)


pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic, line 113 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

Thanks, rebased.

I was also curious why this diff was needed in the first place - to me it seems like some of the changes in the diff are wrong (or at least non-intuitive). I bisected it to the enabling of "always on" tracing PR. I'll open up a separate issue and tag Irfan to look into that.

Oh, just saw the discussion on the PR that merged the diff. Never mind then.

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm:

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

@RaduBerinde
Copy link
Member

Please stress the _nonmetamorphic tests to make sure they pass reliably.

@yuzefovich
Copy link
Member Author

It turned out that row.kvBatchSize also needs a special treatment, so I updated the commit accordingly. Stressing _nonmetamorphic tests now doesn't trigger a failure, so I'm pretty confident that the commit should now work.

I was afraid that coldata.BatchSize would also need a knob - which appears to not be the case - and that would be prohibitively annoying to override since we use it in hundreds of places.

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm: Great, thanks for working on this!

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

This commit refactors how non-metamorphic logic tests are handled.
Previously, if a logic test file had `!metamorphic` directive, then they
would be skipped when the build happened to be metamorphic (which occurs
in 80% of the time). However, this led to multiple flakes when PRs were
merged with green CI, but they didn't update the corresponding tests
(this happened because those tests were skipped).

Looking over all of those issues, we see that they are due to a couple
of randomizations - of `mutations.MaxBatchSize` and `row.kvBatchSize`,
so this commit adds a testing knob to override both of them. Now, for
every config and for every logic test file path we remember whether
non-metamorphic directive was specified and possibly disable the
randomizations of `mutations.MaxBatchSize` and `row.kvBatchSize`. This
required a bit of plumbing, but it looks acceptable.

Release note: None
@yuzefovich
Copy link
Member Author

Needed to make a minor adjustment to avoid a nil pointer in some cases.

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Jan 21, 2021

Build succeeded:

@craig craig bot merged commit cb97c6b into cockroachdb:master Jan 21, 2021
@yuzefovich yuzefovich deleted the logic-metamorphic branch January 21, 2021 02:29
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.

sql/opt/exec/execbuilder: TestExecBuild failed
3 participants