Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
lcwangchao committed Aug 23, 2024
1 parent 66be4e7 commit e562cbb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 60 deletions.
15 changes: 0 additions & 15 deletions ttl/ttlworker/del_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,6 @@ func TestTTLDeleteTaskDoDelete(t *testing.T) {

t1 := newMockTTLTbl(t, "t1")
s := newMockSession(t)
<<<<<<< HEAD:ttl/ttlworker/del_test.go
invokes := 0
s.executeSQL = func(ctx context.Context, sql string, args ...interface{}) ([]chunk.Row, error) {
invokes++
s.sessionInfoSchema = newMockInfoSchema(t1.TableInfo, t2.TableInfo, t3.TableInfo, t4.TableInfo)
if strings.Contains(sql, "`t1`") {
return nil, nil
=======
var sqls []string
var retryErrBatches []int
var nonRetryBatches []int
Expand All @@ -207,7 +199,6 @@ func TestTTLDeleteTaskDoDelete(t *testing.T) {

if !strings.Contains(sql, "`t1`") {
require.FailNow(t, "")
>>>>>>> 1bf01f41083 (ttl: fix the issue that TTL job may hang some time when shrink the delete worker count (#55572)):pkg/ttl/ttlworker/del_test.go
}

defer func() {
Expand Down Expand Up @@ -397,17 +388,11 @@ func TestTTLDeleteTaskWorker(t *testing.T) {
pool := newMockSessionPool(t)
pool.se = s

<<<<<<< HEAD:ttl/ttlworker/del_test.go
sqlMap := make(map[string]struct{})
s.executeSQL = func(ctx context.Context, sql string, args ...interface{}) ([]chunk.Row, error) {
pool.lastSession.sessionInfoSchema = newMockInfoSchema(t1.TableInfo, t2.TableInfo, t3.TableInfo)
=======
sqlMap := make(map[string]int)
t3Retried := make(chan struct{})
t4Retried := make(chan struct{})
s.executeSQL = func(ctx context.Context, sql string, args ...any) ([]chunk.Row, error) {
pool.lastSession.sessionInfoSchema = newMockInfoSchema(t1.TableInfo, t2.TableInfo, t3.TableInfo, t4.TableInfo)
>>>>>>> 1bf01f41083 (ttl: fix the issue that TTL job may hang some time when shrink the delete worker count (#55572)):pkg/ttl/ttlworker/del_test.go
if strings.Contains(sql, "`t1`") {
// success
return nil, nil
Expand Down
48 changes: 3 additions & 45 deletions ttl/ttlworker/task_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@ import (
"testing"
"time"

<<<<<<< HEAD:ttl/ttlworker/task_manager_test.go
"github.com/pingcap/errors"
"github.com/pingcap/tidb/ttl/cache"
"github.com/pingcap/tidb/ttl/session"
=======
"github.com/pingcap/errors"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/ttl/cache"
"github.com/pingcap/tidb/pkg/ttl/session"
"github.com/pingcap/tidb/pkg/util/logutil"
>>>>>>> 1bf01f41083 (ttl: fix the issue that TTL job may hang some time when shrink the delete worker count (#55572)):pkg/ttl/ttlworker/task_manager_test.go
"github.com/pingcap/tidb/util/logutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// NewTaskManager is an exported version of newTaskManager for test
Expand Down Expand Up @@ -151,8 +145,6 @@ func TestResizeWorkers(t *testing.T) {
scanWorker2.checkWorkerStatus(workerStatusStopped, false, nil)
assert.NotNil(t, m.runningTasks[0].result)
}
<<<<<<< HEAD:ttl/ttlworker/task_manager_test.go
=======

func TestTaskFinishedCondition(t *testing.T) {
tbl := newMockTTLTbl(t, "t1")
Expand Down Expand Up @@ -197,37 +189,3 @@ func TestTaskFinishedCondition(t *testing.T) {
require.True(t, task.finished(logger))
}
}

type mockKVStore struct {
kv.Storage
}

type mockTiKVStore struct {
mockKVStore
tikv.Storage
regionCache *tikv.RegionCache
}

func (s *mockTiKVStore) GetRegionCache() *tikv.RegionCache {
return s.regionCache
}

func TestGetMaxRunningTasksLimit(t *testing.T) {
variable.TTLRunningTasks.Store(1)
require.Equal(t, 1, getMaxRunningTasksLimit(&mockTiKVStore{}))

variable.TTLRunningTasks.Store(2)
require.Equal(t, 2, getMaxRunningTasksLimit(&mockTiKVStore{}))

variable.TTLRunningTasks.Store(-1)
require.Equal(t, variable.MaxConfigurableConcurrency, getMaxRunningTasksLimit(nil))
require.Equal(t, variable.MaxConfigurableConcurrency, getMaxRunningTasksLimit(&mockKVStore{}))
require.Equal(t, variable.MaxConfigurableConcurrency, getMaxRunningTasksLimit(&mockTiKVStore{}))

s := &mockTiKVStore{regionCache: tikv.NewRegionCache(nil)}
s.GetRegionCache().SetRegionCacheStore(1, "", "", tikvrpc.TiKV, 1, nil)
s.GetRegionCache().SetRegionCacheStore(2, "", "", tikvrpc.TiKV, 1, nil)
s.GetRegionCache().SetRegionCacheStore(3, "", "", tikvrpc.TiFlash, 1, nil)
require.Equal(t, 2, getMaxRunningTasksLimit(s))
}
>>>>>>> 1bf01f41083 (ttl: fix the issue that TTL job may hang some time when shrink the delete worker count (#55572)):pkg/ttl/ttlworker/task_manager_test.go

0 comments on commit e562cbb

Please sign in to comment.