From bdba3facec74d67000072379254b5d7d7aa584e4 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sat, 29 Jan 2022 15:53:21 +0800 Subject: [PATCH] ddl: improve test Signed-off-by: Weizhen Wang --- ddl/callback_test.go | 3 --- ddl/column.go | 6 ++++-- ddl/column_type_change_test.go | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ddl/callback_test.go b/ddl/callback_test.go index 3364970bf38f4..c8975da252cad 100644 --- a/ddl/callback_test.go +++ b/ddl/callback_test.go @@ -26,9 +26,6 @@ import ( "go.uber.org/zap" ) -// TestReorgGoroutineRunning is only used in test to indicate the reorg goroutine has been started. -var TestReorgGoroutineRunning = make(chan interface{}) - type TestInterceptor struct { *BaseInterceptor diff --git a/ddl/column.go b/ddl/column.go index d7007adc16647..6ef4e2f82fb5b 100644 --- a/ddl/column.go +++ b/ddl/column.go @@ -41,7 +41,6 @@ import ( "github.com/pingcap/tidb/sessionctx/stmtctx" "github.com/pingcap/tidb/table" "github.com/pingcap/tidb/tablecodec" - "github.com/pingcap/tidb/testkit" "github.com/pingcap/tidb/types" "github.com/pingcap/tidb/util" "github.com/pingcap/tidb/util/collate" @@ -1152,12 +1151,15 @@ func (w *worker) updatePhysicalTableRow(t table.PhysicalTable, oldColInfo, colIn return w.writePhysicalTableRecord(t, typeUpdateColumnWorker, nil, oldColInfo, colInfo, reorgInfo) } +// TestReorgGoroutineRunning is only used in test to indicate the reorg goroutine has been started. +var TestReorgGoroutineRunning = make(chan interface{}) + // updateColumnAndIndexes handles the modify column reorganization state for a table. func (w *worker) updateColumnAndIndexes(t table.Table, oldCol, col *model.ColumnInfo, idxes []*model.IndexInfo, reorgInfo *reorgInfo) error { failpoint.Inject("mockInfiniteReorgLogic", func(val failpoint.Value) { if val.(bool) { a := new(interface{}) - testkit.TestReorgGoroutineRunning <- a + TestReorgGoroutineRunning <- a for { time.Sleep(30 * time.Millisecond) if w.reorgCtx.isReorgCanceled() { diff --git a/ddl/column_type_change_test.go b/ddl/column_type_change_test.go index 81b84f8a6ba8d..b013734f8abb5 100644 --- a/ddl/column_type_change_test.go +++ b/ddl/column_type_change_test.go @@ -2060,7 +2060,7 @@ func TestCancelCTCInReorgStateWillCauseGoroutineLeak(t *testing.T) { // This ddl will be hang over in the failpoint loop, waiting for outside cancel. _, alterErr = tk1.Exec("alter table ctc_goroutine_leak modify column a tinyint") }() - <-testkit.TestReorgGoroutineRunning + <-TestReorgGoroutineRunning tk.MustExec("admin cancel ddl jobs " + strconv.Itoa(int(jobID))) wg.Wait() require.Equal(t, "[ddl:8214]Cancelled DDL job", alterErr.Error())