Skip to content

Commit

Permalink
test: fix flaky test TestFailSchemaSyncer (pingcap#54958)
Browse files Browse the repository at this point in the history
  • Loading branch information
D3Hunter authored and hawkingrei committed Aug 1, 2024
1 parent a382718 commit cc7316d
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit cc7316d

Please sign in to comment.