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

Move executor test setup code from TestT to TestMain #28440

Closed
Tracked by #26854
unconsolable opened this issue Sep 27, 2021 · 0 comments · Fixed by #28441
Closed
Tracked by #26854

Move executor test setup code from TestT to TestMain #28440

unconsolable opened this issue Sep 27, 2021 · 0 comments · Fixed by #28441
Assignees
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@unconsolable
Copy link
Contributor

Enhancement

As currently tests under executor packages are using both pingcap/check and testify, we should move the test setup code in TestT to main_test.go to set up all of the tests written by both frameworks.

func TestT(t *testing.T) {
CustomVerboseFlag = true
*CustomParallelSuiteFlag = true
logLevel := os.Getenv("log_level")
err := logutil.InitLogger(logutil.NewLogConfig(logLevel, logutil.DefaultLogFormat, "", logutil.EmptyFileLogConfig, false))
if err != nil {
t.Fatal(err)
}
autoid.SetStep(5000)
config.UpdateGlobal(func(conf *config.Config) {
conf.Log.SlowThreshold = 30000 // 30s
conf.TiKVClient.AsyncCommit.SafeWindow = 0
conf.TiKVClient.AsyncCommit.AllowedClockDrift = 0
})
tikv.EnableFailpoints()
tmpDir := config.GetGlobalConfig().TempStoragePath
_ = os.RemoveAll(tmpDir) // clean the uncleared temp file during the last run.
_ = os.MkdirAll(tmpDir, 0755)
testleak.BeforeTest()
TestingT(t)
testleak.AfterTestT(t)()
}

From my point of view, code related to pingcap/check can still be here, while code related to testleak can be replaced by goleak enabled in TestMain. All the other code will be better to move to TestMain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant