-
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 random syntax generator tests #7970
Conversation
Reviewed 7 of 7 files at r1. internal/rsg/rsg.go, line 93 [r1] (raw file):
Let's have a random selection here between (at least) two strings with mixed casing. I want to check casing does not throw things out of the window. internal/rsg/yacc/lex.go, line 3 [r1] (raw file):
Are you copying (part of) the internal/rsg/yacc/node.go, line 3 [r1] (raw file):
Ditto internal/rsg/yacc/parse.go, line 3 [r1] (raw file):
Ditto sql/executor.go, line 362 [r1] (raw file):
Please extract this to a separate commit or PR. It's a generally useful addition independently of the RSG. sql/rsg_test.go, line 70 [r1] (raw file):
Pull the magic value into a named constant. sql/rsg_test.go, line 79 [r1] (raw file):
Make this configurable via env var, then modify top level makefile to add this env var and a comment to explain what it does. sql/rsg_test.go, line 107 [r1] (raw file):
I think you can add some "ident" column in here.
Then generate a random selection for identifiers out of Then also generate random CREATE TABLE always with 2 columns and also separate CREATE INDEX statements, all using the same identifiers (so they work on the same tables) but with mixed case, and check that we get an error every time (I am 70% suspicious we are missing something with case normalization). Then also generate some INSERT and DELETE statements for these automatically. sql/rsg_test.go, line 121 [r1] (raw file):
ditto re. constant sql/rsg_test.go, line 136 [r1] (raw file):
dito re. loop bound sql/rsg_test.go, line 214 [r1] (raw file):
ditto sql/rsg_test.go, line 253 [r1] (raw file):
ditto sql/rsg_test.go, line 259 [r1] (raw file):
ditto Comments from Reviewable |
Since #8152 is in this can probably merge soon now. |
Review status: 5 of 63 files reviewed at latest revision, 13 unresolved discussions, some commit checks pending. internal/rsg/rsg.go, line 93 [r1] (raw file):
|
Reviewed 3 of 3 files at r2. internal/rsg/rsg.go, line 93 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 6 unresolved discussions, some commit checks failed. internal/rsg/rsg.go, line 93 [r1] (raw file):
|
This test is designed to be run from a nightly job for some longish time (~1h). Its goal is to find panics introduced in our implementation. Since the executor is not the same go routine as the test, the executor has been changed to include a panic handler that prepends the failed SQL statement in a panic. This uses the yacc package from the docs repo that generates the SQL diagrams. It and the rsg package are included in internal because they are not needed for the operation of the database, only for a test.
I've asked about panic vs error because it will inform where the NormalizeName testing goes. If these things produce panics, then they can go into the existing places. If you expect errors, then they will have to go into a new test that tests for lack of errors, since the current ones can produce valid, error-free statements. Review status: 3 of 6 files reviewed at latest revision, 6 unresolved discussions, some commit checks pending. Comments from Reviewable |
Reviewed 3 of 3 files at r3. internal/rsg/rsg.go, line 93 [r1] (raw file):
|
Review status: 5 of 6 files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. internal/rsg/rsg.go, line 93 [r1] (raw file):
|
LGTM! Very nice work. |
This test is designed to be run from a nightly job for some longish time
(~1h). Its goal is to find panics introduced in our implementation. Since
the executor is not the same go routine as the test, the executor has
been changed to include a panic handler that prepends the failed SQL
statement in a panic.
This uses the yacc package from the docs repo that generates the SQL
diagrams. It and the rsg package are included in internal because they
are not needed for the operation of the database, only for a test.
This change is