MCPcopy
hub / github.com/cubefs/cubefs / testTaskInspectMgrDo

Function testTaskInspectMgrDo

blobstore/blobnode/task_inspect_mgr_test.go:41–117  ·  view source on GitHub ↗
(t *testing.T, mode codemode.CodeMode)

Source from the content-addressed store, hash-verified

39}
40
41func testTaskInspectMgrDo(t *testing.T, mode codemode.CodeMode) {
42 replicas := genMockVol(1, mode)
43 bids := []proto.BlobID{1, 2, 3, 4, 5, 6, 7}
44 sizes := []int64{10, 1024, 1024, 1024, 1024, 1024, 1024}
45 getter := NewMockGetterWithBids(replicas, mode, bids, sizes)
46 mgr := NewInspectTaskMgr(1, getter, newMockReporter(t))
47 task := proto.VolumeInspectTask{
48 TaskID: "InspectTask_XXX",
49 Mode: mode,
50 Replicas: replicas,
51 }
52 ret := mgr.doInspect(context.Background(), &task)
53 require.NoError(t, ret.Err())
54 require.Equal(t, 0, len(ret.MissedShards))
55
56 getter.MarkDelete(context.Background(), replicas[0].Vuid, 1)
57 ret = mgr.doInspect(context.Background(), &task)
58 require.NoError(t, ret.Err())
59 require.Equal(t, 0, len(ret.MissedShards))
60
61 // normal
62 var expectMissedShard []*proto.MissedShard
63 ret = mgr.doInspect(context.Background(), &task)
64 require.NoError(t, ret.Err())
65 verifyInspectResult(t, expectMissedShard, ret.MissedShards)
66
67 // delete one bid
68 getter.Delete(context.Background(), replicas[0].Vuid, 1)
69 expectMissedShard = append(expectMissedShard, &proto.MissedShard{Vuid: replicas[0].Vuid, Bid: 1})
70 ret = mgr.doInspect(context.Background(), &task)
71 require.NoError(t, ret.Err())
72 verifyInspectResult(t, expectMissedShard, ret.MissedShards)
73
74 // delete other bid 2
75 getter.Delete(context.Background(), replicas[1].Vuid, 2)
76 expectMissedShard = append(expectMissedShard, &proto.MissedShard{Vuid: replicas[1].Vuid, Bid: 2})
77 ret = mgr.doInspect(context.Background(), &task)
78 require.NoError(t, ret.Err())
79 verifyInspectResult(t, expectMissedShard, ret.MissedShards)
80
81 // delete m
82 delStartIdx := 1
83 delEndIdx := mode.Tactic().M
84 for _, replica := range replicas[delStartIdx:delEndIdx] {
85 getter.Delete(context.Background(), replica.Vuid, 1)
86 expectMissedShard = append(expectMissedShard, &proto.MissedShard{Vuid: replica.Vuid, Bid: 1})
87 }
88
89 ret = mgr.doInspect(context.Background(), &task)
90 require.NoError(t, ret.Err())
91 verifyInspectResult(t, expectMissedShard, ret.MissedShards)
92
93 delStartIdx = delEndIdx
94 delEndIdx = delEndIdx + 1
95 for _, replica := range replicas[delStartIdx:delEndIdx] {
96 getter.Delete(context.Background(), replica.Vuid, 1)
97 expectMissedShard = append(expectMissedShard, &proto.MissedShard{Vuid: replica.Vuid, Bid: 1})
98 }

Callers

nothing calls this directly

Calls 15

doInspectMethod · 0.95
NewFunction · 0.92
genMockVolFunction · 0.85
NewMockGetterWithBidsFunction · 0.85
NewInspectTaskMgrFunction · 0.85
newMockReporterFunction · 0.85
verifyInspectResultFunction · 0.85
setFailMethod · 0.80
setWellMethod · 0.80
ErrMethod · 0.65
MarkDeleteMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected