-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: add framework for testing only descriptor validation #54188
Conversation
c7a6b95
to
d29c669
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 32 of 33 files at r1.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @arulajmani)
pkg/sql/catalog/tabledesc/structured.go, line 1434 at r1 (raw file):
// PerformTestingDescriptorValidation can be set as a value on a context to // ensure testing specific descriptor validation happens. var PerformTestingDescriptorValidation = testingDescriptorValidation(true)
super nit: i think this is nicer to read
var PerformTestingDescriptorValidation testingDescriptorValidation = true
pkg/sql/logictest/logic.go, line 1262 at r1 (raw file):
}, //SQLExecutor: &sql.ExecutorTestingKnobs{ // TestingDescriptorValidation: true,
why is this commented out?
This patch adds a new field on the `ExecutorTestingKnobs` called `TestingDescriptorValidation`. This creates the structure to perform certain table descriptor validation only during testing scenarios, i.e, when this knob is turned on. This is achieved by intercepting the context at the `conn_executor` level to include a value that indicates to the validation functions if extra validation should be performed. By intercepting the context at this level, instead of somewhere closer to the Validate calls, we avoid having to find and intercept the context in all possible codepaths -- which was getting quite messy. On the validation side, this patch adds two to be filled functions -- validateCrossReferencesIfTesting and validateTableIfTesting. We don't validate cross references for mutable descriptors, so providing these two functions allows us to preserve this pattern and cover both mutable/immutable descriptors in testing only validation. The functions are currently no-ops and will be filled in in upcoming patches. Currently, the testing knob is turned on by default for all test servers. If you're writing a test and don't want to opt into this validation for some reason, there's a `DisableTestingDescriptorValidation` on server args that can be set. Release note: None
d29c669
to
dd90439
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @otan)
pkg/sql/catalog/tabledesc/structured.go, line 1434 at r1 (raw file):
Previously, otan (Oliver Tan) wrote…
super nit: i think this is nicer to read
var PerformTestingDescriptorValidation testingDescriptorValidation = true
Done.
pkg/sql/logictest/logic.go, line 1262 at r1 (raw file):
Previously, otan (Oliver Tan) wrote…
why is this commented out?
My bad, I intended to remove this but instead left it commented out. This was from a previous approach where this descirptor validation was only for logictests, but in the new approach it's for all tests unless you opt out, making this knob here useless.
bors r=otan |
Build succeeded: |
This patch adds a new field on the
ExecutorTestingKnobs
calledTestingDescriptorValidation
. This creates the structure to performcertain table descriptor validation only during testing scenarios, i.e,
when this knob is turned on. This is achieved by intercepting the
context at the
conn_executor
level to include a value that indicatesto the validation functions if extra validation should be performed.
By intercepting the context at this level, instead of somewhere closer
to the Validate calls, we avoid having to find and intercept the context
in all possible codepaths -- which was getting quite messy.
On the validation side, this patch adds two to be filled functions --
validateCrossReferencesIfTesting and validateTableIfTesting. We don't
validate cross references for mutable descriptors, so providing these
two functions allows us to preserve this pattern and cover both
mutable/immutable descriptors in testing only validation. The functions
are currently no-ops and will be filled in in upcoming patches.
Currently, the testing knob is turned on by default for all test
servers. If you're writing a test and don't want to opt into this
validation for some reason, there's a
DisableTestingDescriptorValidation
on server args that can be set.Release note: None