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

script(cdc): don't check line width for test files #4872

Closed
wants to merge 1 commit into from

Conversation

lance6716
Copy link
Contributor

Signed-off-by: lance6716 [email protected]

What problem does this PR solve?

Issue Number: ref #4287

What is changed and how it works?

When I write tests, I think a long string literal (like generated SQL) is good to read. But it can't pass CI.

Check List

Tests

  • Manual test (add detailed scripts or steps below)

Release note

 `None`.

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note-none Denotes a PR that doesn't merit a release note. label Mar 11, 2022
@ti-chi-bot ti-chi-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 11, 2022
@lance6716 lance6716 added require-LGT1 Indicates that the PR requires an LGTM. area/ticdc Issues or PRs related to TiCDC. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 11, 2022
Copy link
Member

@Rustin170506 Rustin170506 left a comment

Choose a reason for hiding this comment

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

I personally feel that the test needs to be kept at normal width as well. It is no different from the core code. Both need to ensure good readability. But if you have a strong opinion about it, I'm ok with that.

@lance6716
Copy link
Contributor Author

I personally feel that the test needs to be kept at normal width as well. It is no different from the core code. Both need to ensure good readability. But if you have a strong opinion about it, I'm ok with that.

I made some test file changes like this
https://github.com/pingcap/tiflow/pull/4587/files#diff-7a385c2f760ae6ee8284c0ec6a649a8953602ae51fca4dd19f7ee28c806e2a4eR87

			expected: &preparedDMLs{
-				sqls:     []string{"DELETE FROM `common_1`.`uk_without_pk` WHERE `a1` = ? AND `a3` = ? LIMIT 1;"},
+				sqls:     []string{"DELETE FROM `common_1`.`uk_without_pk` WHERE `a1` = ? AND `a3` = ? LIMIT 1"},
				values:   [][]interface{}{{1, 1}},
				rowCount: 1,
			},

That's not very easy to find a good layout to pass the CI

@codecov-commenter
Copy link

Codecov Report

Merging #4872 (98b3d5a) into master (9607554) will increase coverage by 0.3849%.
The diff coverage is 71.0363%.

Flag Coverage Δ
cdc 60.4684% <71.0363%> (+0.5462%) ⬆️
dm 52.4167% <ø> (+0.3878%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@               Coverage Diff                @@
##             master      #4872        +/-   ##
================================================
+ Coverage   55.6402%   56.0251%   +0.3849%     
================================================
  Files           494        522        +28     
  Lines         61283      65160      +3877     
================================================
+ Hits          34098      36506      +2408     
- Misses        23750      25084      +1334     
- Partials       3435       3570       +135     

Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

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

I personally feel that the test needs to be kept at normal width as well. It is no different from the core code. Both need to ensure good readability. But if you have a strong opinion about it, I'm ok with that.

Agree, without width limit, we may write tests like crazy long, see

expected := []string{
// nolint:stylecheck
`INSERT INTO t VALUES(585520728116297738,1,9223372036854775807,123.123,123456789012.1234567890120000000,"\0\0\0\0\0\0\0A","1000-01-01","9999-12-31 23:59:59","1973-12-30 15:30:00","23:59:59",1970,"x","x\"x","blob","text","enum2","a,b"),(585520728116297737,1,9223372036854775807,123.123,123456789012.1234567890120000000,"\0\0\0\0\0\0\0A","1000-01-01","9999-12-31 23:59:59","1973-12-30 15:30:00","23:59:59",1970,"x","x\",\nx","blob","text","enum2","a,b"),(585520728116297736,1,9223372036854775807,123.123,123456789012.1234567890120000000,"\0\0\0\0\0\0\0A","1000-01-01","9999-12-31 23:59:59","1973-12-30 15:30:00","23:59:59",1970,"x","x\",\nx","blob","�text\n","enum2"," a,b ");`,
// nolint:stylecheck
`INSERT INTO t VALUES(10,1,9223372036854775807,123.123,123456789012.1234567890120000000,"\0\0\0\0\0\0\0A","1000-01-01","9999-12-31 23:59:59","1973-12-30 15:30:00","23:59:59",1970,"test:x","x\"x","blob","text","enum2","a,b"),(9,1,9223372036854775807,123.123,123456789012.1234567890120000000,"\0\0\0\0\0\0\0A","1000-01-01","9999-12-31 23:59:59","1973-12-30 15:30:00","23:59:59",1970,"test:x","x\",\nx","blob","text","enum2","a,b"),(8,1,9223372036854775807,123.123,123456789012.1234567890120000000,"\0\0\0\0\0\0\0A","1000-01-01","9999-12-31 23:59:59","1973-12-30 15:30:00","23:59:59",1970,"test:x","x\",\nx","blob","�text\n","enum2"," a,b ");`,
}

updateValue: []string{
`{"sink-uri":"blackhole://","opts":{},"create-time":"2020-02-02T00:00:00.000000+00:00","start-ts":421980685886554116,"target-ts":0,"admin-job-type":0,"sort-engine":"memory","sort-dir":"","config":{"case-sensitive":true,"enable-old-value":false,"force-replicate":false,"check-gc-safe-point":true,"filter":{"rules":["*.*"],"ignore-txn-start-ts":null,"ddl-allow-list":null},"mounter":{"worker-num":16},"sink":{"dispatchers":null,"protocol":"open-protocol"},"cyclic-replication":{"enable":false,"replica-id":0,"filter-replica-ids":null,"id-buckets":0,"sync-ddl":false},"scheduler":{"type":"table-number","polling-time":-1},"consistent":{"level":"normal","storage":"local"}},"state":"normal","history":null,"error":null,"sync-point-enabled":false,"sync-point-interval":600000000000}`,
`{"resolved-ts":421980720003809281,"checkpoint-ts":421980719742451713,"admin-job-type":0}`,
`{"checkpoint-ts":421980720003809281,"resolved-ts":421980720003809281,"count":0,"error":null}`,
`{"tables":{"45":{"start-ts":421980685886554116,"mark-table-id":0}},"operation":null,"admin-job-type":0}`,
`{"45":{"workload":1}}`,
`{"id":"6bbc01c8-0605-4f86-a0f9-b3119109b225","address":"127.0.0.1:8300"}`,
},

@lance6716
Copy link
Contributor Author

ok, I will use str+str to split the long string literal in my original pr.

@lance6716 lance6716 closed this Mar 11, 2022
@overvenus
Copy link
Member

ok, I will use str+str to split the long string literal in my original pr.

try SQL formatter https://www.dpriver.com/pp/sqlformat.htm

	longLongLongSQL := `
DELETE FROM `common_1`.`uk_without_pk`
WHERE  `a1` = ?
       AND `a3` = ?
LIMIT 1`

@lance6716 lance6716 deleted the change-limit-script branch October 13, 2022 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ticdc Issues or PRs related to TiCDC. release-note-none Denotes a PR that doesn't merit a release note. require-LGT1 Indicates that the PR requires an LGTM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants