@@ -3513,35 +3513,32 @@ func TestClientDisconnectKillsAutocommitInsert(t *testing.T) {
35133513 if prepared {
35143514 name = "prepared"
35153515 }
3516- t .Run (name , func (t * testing.T ) {
3517- ts .RunTests (t , nil , func (dbt * testkit.DBTestKit ) {
3518- tableName := "issue57531_insert_" + name
3519- dbt .MustExec ("drop table if exists " + tableName )
3520- dbt .MustExec ("create table " + tableName + " (a int primary key, b int)" )
3521- runClientDisconnectAutocommitInsert (t , dbt , tableName , fmt .Sprintf ("insert into %s values (1, sleep(300))" , tableName ), prepared )
3516+ for _ , insertCase := range []struct {
3517+ name string
3518+ buildSQL func (tableName string ) string
3519+ }{
3520+ {
3521+ name : "single_row" ,
3522+ buildSQL : func (tableName string ) string {
3523+ return fmt .Sprintf ("insert into %s values (1, sleep(300))" , tableName )
3524+ },
3525+ },
3526+ {
3527+ name : "multi_rows" ,
3528+ buildSQL : func (tableName string ) string {
3529+ return fmt .Sprintf ("insert into %s values (1, 1), (2, sleep(300)), (3, 3), (4, 4), (5, 5)" , tableName )
3530+ },
3531+ },
3532+ } {
3533+ t .Run (name + "/" + insertCase .name , func (t * testing.T ) {
3534+ ts .RunTests (t , nil , func (dbt * testkit.DBTestKit ) {
3535+ tableName := "issue57531_insert_" + name + "_" + insertCase .name
3536+ dbt .MustExec ("drop table if exists " + tableName )
3537+ dbt .MustExec ("create table " + tableName + " (a int primary key, b int)" )
3538+ runClientDisconnectAutocommitInsert (t , dbt , tableName , insertCase .buildSQL (tableName ), prepared )
3539+ })
35223540 })
3523- })
3524- }
3525- }
3526-
3527- func TestClientDisconnectCancelsAutocommitInsertPrewrite (t * testing.T ) {
3528- ts := servertestkit .CreateTidbTestSuite (t )
3529- enableFastConnectionAliveMonitor (t )
3530-
3531- for _ , prepared := range []bool {false , true } {
3532- name := "query"
3533- if prepared {
3534- name = "prepared"
35353541 }
3536- t .Run (name , func (t * testing.T ) {
3537- ts .RunTests (t , nil , func (dbt * testkit.DBTestKit ) {
3538- tableName := "issue57531_prewrite_" + name
3539- dbt .MustExec ("drop table if exists " + tableName )
3540- dbt .MustExec ("create table " + tableName + " (a int primary key, b int)" )
3541- testfailpoint .Enable (t , "github.com/pingcap/tidb/pkg/store/mockstore/unistore/rpcPrewriteResult" , `return("notLeader")` )
3542- runClientDisconnectAutocommitInsert (t , dbt , tableName , fmt .Sprintf ("insert into %s values (1, 1)" , tableName ), prepared )
3543- })
3544- })
35453542 }
35463543}
35473544
0 commit comments