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

test: fix flaky test TestFailSchemaSyncer #54958

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/ddl/tests/fail/fail_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ type failedSuite struct {
}

func createFailDBSuite(t *testing.T) (s *failedSuite) {
return createFailDBSuiteWithLease(t, 200*time.Millisecond)
}

func createFailDBSuiteWithLease(t *testing.T, lease time.Duration) (s *failedSuite) {
s = new(failedSuite)
var err error
s.store, err = mockstore.NewMockStore(
Expand All @@ -57,7 +61,7 @@ func createFailDBSuite(t *testing.T) (s *failedSuite) {
}),
)
require.NoError(t, err)
session.SetSchemaLease(200 * time.Millisecond)
session.SetSchemaLease(lease)
s.dom, err = session.BootstrapSession(s.store)
require.NoError(t, err)

Expand Down Expand Up @@ -220,7 +224,7 @@ func TestAddIndexFailed(t *testing.T) {
// TestFailSchemaSyncer test when the schema syncer is done,
// should prohibit DML executing until the syncer is restartd by loadSchemaInLoop.
func TestFailSchemaSyncer(t *testing.T) {
s := createFailDBSuite(t)
s := createFailDBSuiteWithLease(t, 10*time.Second)
tk := testkit.NewTestKit(t, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
Expand Down