Skip to content

sql/schemachanger: move end to end testing to one test per-file#83545

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
fqazi:scOneTestPerFile
Jun 30, 2022
Merged

sql/schemachanger: move end to end testing to one test per-file#83545
craig[bot] merged 1 commit intocockroachdb:masterfrom
fqazi:scOneTestPerFile

Conversation

@fqazi
Copy link
Copy Markdown
Collaborator

@fqazi fqazi commented Jun 28, 2022

Previously, we allowed multiple tests per-file for end-to-end
testing inside the declarative schema changer. This was inadequate
because we plan on extending the end-to-end testing to start injecting
additional read/write operations at different stages, which would
make it difficult. To address this, this patch will split tests into
individual files, with one test per file. Additionally, it extends
support to allow multiple statements per-test statement, for transaction
support testing (this is currently unused).

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@fqazi fqazi force-pushed the scOneTestPerFile branch 2 times, most recently from e8da848 to bb2ccc3 Compare June 29, 2022 03:37
@fqazi fqazi marked this pull request as ready for review June 29, 2022 03:41
@fqazi fqazi requested a review from a team June 29, 2022 03:41
@fqazi fqazi force-pushed the scOneTestPerFile branch from bb2ccc3 to 5097057 Compare June 29, 2022 18:17
@@ -1911,12 +1911,12 @@ notified job registry to adopt jobs: [2]
test
ALTER TABLE db.public.tbl ADD COLUMN l INT NOT NULL DEFAULT nextval('db.public.sq1')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this test be removed from this file?

@@ -914,12 +914,12 @@ notified job registry to adopt jobs: [2]
test
ALTER TABLE db.public.tbl ADD COLUMN k INT NOT NULL DEFAULT 42
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmm. this is the 2nd test in this file, shouldn't this break because we only allow one test now?

@fqazi fqazi force-pushed the scOneTestPerFile branch from 5097057 to 444f019 Compare June 30, 2022 02:43
Copy link
Copy Markdown
Collaborator Author

@fqazi fqazi 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 @chengxiong-ruan)


pkg/sql/schemachanger/testdata/alter_table_add_column line 915 at r1 (raw file):

Previously, chengxiong-ruan (Chengxiong Ruan) wrote…

hmm. this is the 2nd test in this file, shouldn't this break because we only allow one test now?

Done.


pkg/sql/schemachanger/testdata/alter_table_add_column line 1912 at r1 (raw file):

Previously, chengxiong-ruan (Chengxiong Ruan) wrote…

should this test be removed from this file?

Ugh really stupid bug with the variable in the loop. Adjusted all the tests, should be one per file now.

@fqazi fqazi requested a review from chengxiong-ruan June 30, 2022 02:45
Copy link
Copy Markdown

@postamar postamar left a comment

Choose a reason for hiding this comment

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

This is close.

Reviewed 3 of 8 files at r1, 10 of 10 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan and @fqazi)


pkg/sql/schemachanger/sctest/end_to_end.go line 171 at r2 (raw file):

			// Run statement phase.
			deps.IncrementPhase()
			deps.LogSideEffectf("# begin %s", deps.Phase())

This line and the two above should be before the for-loop, not in its body.


pkg/sql/schemachanger/sctest/end_to_end.go line 174 at r2 (raw file):

			state, _, err = scrun.RunStatementPhase(ctx, s.TestingKnobs(), s, state)
			require.NoError(t, err, "error in %s", s.Phase())
			deps.LogSideEffectf("# end %s", deps.Phase())

This line should be right after the for-loop, not in its body.

Previously, we allowed multiple tests per-file for end-to-end
testing inside the declarative schema changer. This was inadequate
because we plan on extending the end-to-end testing to start injecting
additional read/write operations at different stages, which would
make it difficult. To address this, this patch will split tests into
individual files, with one test per file. Additionally, it extends
support to allow multiple statements per-test statement, for transaction
support testing (this is currently unused).

Release note: None
@fqazi fqazi force-pushed the scOneTestPerFile branch from 444f019 to 593a111 Compare June 30, 2022 14:15
Copy link
Copy Markdown
Collaborator Author

@fqazi fqazi 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 @chengxiong-ruan and @postamar)


pkg/sql/schemachanger/sctest/end_to_end.go line 171 at r2 (raw file):

Previously, postamar (Marius Posta) wrote…

This line and the two above should be before the for-loop, not in its body.

Done.


pkg/sql/schemachanger/sctest/end_to_end.go line 174 at r2 (raw file):

Previously, postamar (Marius Posta) wrote…

This line should be right after the for-loop, not in its body.

Done.

Copy link
Copy Markdown

@postamar postamar left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 11 of 11 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @chengxiong-ruan and @postamar)

Comment on lines +99 to +101
stmtSqls := make([]string, 0, len(stmts))
for _, stmt := range stmts {
stmtSqls = append(stmtSqls, stmt.SQL)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you help me understand this change, as it pertains to the sctestdeps.WithStatements(stmt.SQL) change below?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This allows the test command to have multiple SQL statements. Below then we execute all the statements in a single transaction.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In what case would we need this capability? I also just see one sql stmt under test in all the logic test file below. Did I miss something?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For transaction testing, it allows us to have a test statement with multiple statements. Only one test is allowed per file.

@fqazi
Copy link
Copy Markdown
Collaborator Author

fqazi commented Jun 30, 2022

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 30, 2022

Build succeeded:

@craig craig bot merged commit 05ca68a into cockroachdb:master Jun 30, 2022
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.

5 participants