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

Unstable test dump_test.TestDumpBlock #32008

Closed
Ehco1996 opened this issue Jan 27, 2022 · 5 comments · Fixed by #32009 or #32667
Closed

Unstable test dump_test.TestDumpBlock #32008

Ehco1996 opened this issue Jan 27, 2022 · 5 comments · Fixed by #32009 or #32667
Assignees
Labels
component/dumpling This is related to Dumpling of TiDB. type/enhancement The issue or PR belongs to an enhancement.

Comments

@Ehco1996
Copy link
Contributor

=== RUN   TestDumpBlock
    dump_test.go:62:
        	Error Trace:	dump_test.go:62
        	Error:      	Target error should be in err chain:
        	            	expected: "canceling query due to user request"
        	            	in chain: "context canceled"
        	Test:       	TestDumpBlock
--- FAIL: TestDumpBlock (0.00s)
=== RUN   TestDumpBlock
    dump_test.go:62:
        	Error Trace:	dump_test.go:62
        	Error:      	Target error should be in err chain:
        	            	expected: "canceling query due to user request"
        	            	in chain: "context canceled"
        	Test:       	TestDumpBlock
--- FAIL: TestDumpBlock (0.00s)
=== RUN   TestDumpBlock
@hawkingrei
Copy link
Member

[](https://ci.pingcap.net/blue/organizations/jenkins/tidb_ghpr_unit_test/detail/tidb_ghpr_unit_test/36807/pipeline/#step-59-log-234)[](https://ci.pingcap.net/blue/organizations/jenkins/tidb_ghpr_unit_test/detail/tidb_ghpr_unit_test/36807/pipeline/#step-59-log-235)[](https://ci.pingcap.net/blue/organizations/jenkins/tidb_ghpr_unit_test/detail/tidb_ghpr_unit_test/36807/pipeline/#step-59-log-236)[](https://ci.pingcap.net/blue/organizations/jenkins/tidb_ghpr_unit_test/detail/tidb_ghpr_unit_test/36807/pipeline/#step-59-log-237)[](https://ci.pingcap.net/blue/organizations/jenkins/tidb_ghpr_unit_test/detail/tidb_ghpr_unit_test/36807/pipeline/#step-59-log-238)[](https://ci.pingcap.net/blue/organizations/jenkins/tidb_ghpr_unit_test/detail/tidb_ghpr_unit_test/36807/pipeline/#step-59-log-239)[2022-02-21T15:21:43.613Z] === FAIL: dumpling/export TestDumpBlock (1.00s)

[2022-02-21T15:21:43.613Z]     dump_test.go:65: 

[2022-02-21T15:21:43.613Z]         	Error Trace:	dump_test.go:65

[2022-02-21T15:21:43.613Z]         	Error:      	Target error should be in err chain:

[2022-02-21T15:21:43.613Z]         	            	expected: "canceling query due to user request"

[2022-02-21T15:21:43.613Z]         	            	in chain: "context canceled"

[2022-02-21T15:21:43.613Z]         	Test:       	TestDumpBlock

it still happen.

@Ehco1996
Copy link
Contributor Author

Ehco1996 commented Feb 23, 2022

i found even if i pass a cancelled ctx to simpleQueryWithArgs, it may return nil error sometimes😂

maybe there is a bug on sqlmock

in ShowCreateDatabase
out ShowCreateDatabase (0x0,0x0)
    dump_test.go:66:
        	Error Trace:	dump_test.go:66
        	Error:      	Target error should be in err chain:
        	            	expected: "canceling query due to user request"
        	            	in chain: "context canceled"
        	Test:       	TestDumpBlock
--- FAIL: TestDumpBlock (1.00s)
=== RUN   TestDumpBlock

@hawkingrei
Copy link
Member

TestDumpBlock

Can you migrate this test case to use testkit? Most of them use testkit.

@Ehco1996 Ehco1996 added the component/dumpling This is related to Dumpling of TiDB. label Feb 28, 2022
@Ehco1996
Copy link
Contributor Author

i found even if i pass a cancelled ctx to simpleQueryWithArgs, it may return nil error sometimes😂

maybe there is a bug on sqlmock

in ShowCreateDatabase
out ShowCreateDatabase (0x0,0x0)
    dump_test.go:66:
        	Error Trace:	dump_test.go:66
        	Error:      	Target error should be in err chain:
        	            	expected: "canceling query due to user request"
        	            	in chain: "context canceled"
        	Test:       	TestDumpBlock
--- FAIL: TestDumpBlock (1.00s)
=== RUN   TestDumpBlock

@lichunzhu i found the root cause: default query delay for sqlMock is 0, and it not handle cancelled ctx rightly. e.g:

this branch would be trigged even if ctx is cancelld sometimes

so i add WillDelayFor for this test in https://github.com/pingcap/tidb/pull/32667/files, sqlmock does the same thing in thier own test https://github.com/DATA-DOG/go-sqlmock/blob/699dcdfa20ba013453a750bedd46364983ab35aa/sqlmock_go18_test.go#L183

@Ehco1996 Ehco1996 added type/bug The issue is confirmed as a bug. type/enhancement The issue or PR belongs to an enhancement. and removed type/bug The issue is confirmed as a bug. labels Feb 28, 2022
@Ehco1996
Copy link
Contributor Author

TestDumpBlock

Can you migrate this test case to use testkit? Most of them use testkit.

I think sqlmock would be more appropriate for this scenario as there is no concept of a session in dumpling like tidb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/dumpling This is related to Dumpling of TiDB. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
2 participants