1
// Copyright 2023 The CubeFS Authors.
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
// implied. See the License for the specific language governing
13
// permissions and limitations under the License.
21
"github.com/cubefs/cubefs/proto"
22
"github.com/cubefs/cubefs/util/routinepool"
23
"github.com/cubefs/cubefs/util/unboundedchan"
24
"github.com/stretchr/testify/require"
27
func TestLcScanner(t *testing.T) {
28
lcScanRoutineNumPerTask = 1
30
scanner := &LcScanner{
33
mw: NewMockMetaWrapper(),
35
adminTask: &proto.AdminTask{
36
Response: &proto.LcNodeRuleTaskResponse{},
39
Expire: &proto.ExpirationConfig{},
41
dirChan: unboundedchan.NewUnboundedChan(10),
42
fileChan: unboundedchan.NewUnboundedChan(10),
43
dirRPoll: routinepool.NewRoutinePool(lcScanRoutineNumPerTask),
44
fileRPoll: routinepool.NewRoutinePool(lcScanRoutineNumPerTask),
45
batchDentries: proto.NewBatchDentries(),
46
currentStat: &proto.LcNodeRuleTaskStatistics{},
48
stopC: make(chan bool),
50
err := scanner.Start()
51
require.NoError(t, err)
52
time.Sleep(time.Second * 5)
53
require.Equal(t, true, scanner.DoneScanning())