Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

sql/logictest: Fixes logic test tabular data output #127773

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

kyle-a-wong
Copy link
Contributor

@kyle-a-wong kyle-a-wong commented Jul 26, 2024

logictest generated test data formats query results in a in a tabular format using tabwriter. when a query result contains \n characters, it formats it such that stays within the same tab cell on output. This works well when there is a single row result, but when there are multiple rows with data that contains \n characters, the input parser doesn't know, nor can it tell, if a cell is multi-lined or not, erroneously reporting that data expected data and actual data don't match.

To Fix, multi-row query responses will now replace \n characters with \\n to ensure tests pass while being well formatted.

Fixes: #127785
Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@kyle-a-wong kyle-a-wong force-pushed the test_logic_data_fix branch 5 times, most recently from a443127 to b945eb6 Compare July 29, 2024 21:48
@kyle-a-wong kyle-a-wong changed the title WIP: Fixes logic test tabular data output sql/logictest: Fixes logic test tabular data output Jul 29, 2024
Copy link

blathers-crl bot commented Jul 30, 2024

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

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

@kyle-a-wong kyle-a-wong force-pushed the test_logic_data_fix branch 3 times, most recently from 7b47930 to dba487b Compare July 30, 2024 03:11
@kyle-a-wong kyle-a-wong marked this pull request as ready for review July 30, 2024 12:22
@kyle-a-wong kyle-a-wong requested review from a team, rafiss, dhartunian and xinhaoz July 30, 2024 12:24
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

nice

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @dhartunian, @kyle-a-wong, and @xinhaoz)


pkg/sql/logictest/logic_test.go line 36 at r1 (raw file):

func TestFormatting(t *testing.T) {
	defer leaktest.AfterTest(t)()
	RunLogicTest(t, TestServerArgs{}, 0, testfile)

do you know why we had to introduce a new test file like this and a new explicit RunLogicTest call? it seems like this should just work if we do mv pkg/sql/logictest/testdata/testdata pkg/sql/logictest/testdata/logic_test/formatting and then run ./dev gen logictest

Copy link
Contributor Author

@kyle-a-wong kyle-a-wong 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 @dhartunian, @rafiss, and @xinhaoz)


pkg/sql/logictest/logic_test.go line 36 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

do you know why we had to introduce a new test file like this and a new explicit RunLogicTest call? it seems like this should just work if we do mv pkg/sql/logictest/testdata/testdata pkg/sql/logictest/testdata/logic_test/formatting and then run ./dev gen logictest

Well the main reason was was because I didn't know about this logictest generation lol. But also I'm not sure it belongs in testdata/logic_test. The intention behind this test is the test that the formatted values generated and output by logic tests is working as intended. Its not really trying to test any logic in the DB and doesn't need to be tested different config.

If my assumptions are wrong or you think it should be tested with different configs / logic tests, I can move it here.

Copy link
Collaborator

@rafiss rafiss 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 @dhartunian, @kyle-a-wong, and @xinhaoz)


pkg/sql/logictest/logic_test.go line 36 at r1 (raw file):

Previously, kyle-a-wong (Kyle Wong) wrote…

Well the main reason was was because I didn't know about this logictest generation lol. But also I'm not sure it belongs in testdata/logic_test. The intention behind this test is the test that the formatted values generated and output by logic tests is working as intended. Its not really trying to test any logic in the DB and doesn't need to be tested different config.

If my assumptions are wrong or you think it should be tested with different configs / logic tests, I can move it here.

i think i'd still prefer it to be in the main testdata directory. that way, it's less likely for the test to be forgotten if the framework changes in the future. since we don't need to run it under all configs, you can add this at the top of the file:

The file can also have a comment saying that it's just testing the logictest framework's formatting logic.

logictest generated test data formats query results
in a in a tabular format using tabwriter. when
a query result contains `\n` characters, it formats
it such that stays within the same tab cell on
output. This works well when there is a single
row result, but when there are multiple rows
with data that contains `\n` characters, the
intput parser doesn't know, nor can it tell,
if a cell is multi-lined or not, erroneously
reporting that data expected data and actual
data don't match.

To Fix, multi-row query responses will now
replace `\n` characters with `\\n` to
ensure tests pass while being well formatted.

Fixes: cockroachdb#127785
Release note: None
Copy link
Contributor Author

@kyle-a-wong kyle-a-wong 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 @dhartunian, @rafiss, and @xinhaoz)


pkg/sql/logictest/logic_test.go line 36 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

i think i'd still prefer it to be in the main testdata directory. that way, it's less likely for the test to be forgotten if the framework changes in the future. since we don't need to run it under all configs, you can add this at the top of the file:

The file can also have a comment saying that it's just testing the logictest framework's formatting logic.

Done.

@kyle-a-wong
Copy link
Contributor Author

Thanks for the reviews and comments!

bors r+

@craig craig bot merged commit 548c0d4 into cockroachdb:master Jul 31, 2024
22 checks passed
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.

pkg/sql/logictest: Test data containing multi-line values causes test to fail
3 participants