MCPcopy
hub / github.com/cubefs/cubefs / TestDownload

Function TestDownload

blobstore/blobnode/work_shard_recover_test.go:362–404  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

360}
361
362func TestDownload(t *testing.T) {
363 ctx := context.Background()
364 repair, _, getter, replicas := InitMockRepair(codemode.EC6P6)
365 repairBids := []proto.BlobID{1, 2, 4, 5, 6, 7}
366 idxs := replicas.Indexes()
367 err := repair.allocBuf(ctx, idxs)
368 require.NoError(t, err)
369
370 failVuids := []proto.Vuid{replicas[0].Vuid, replicas[1].Vuid}
371 for _, fail := range failVuids {
372 getter.setFail(fail, errors.New("fake error"))
373 }
374 repair.download(ctx, repairBids, replicas)
375
376 for _, fail := range failVuids {
377 for _, bid := range repairBids {
378 _, err := repair.GetShard(fail.Index(), bid)
379 require.Error(t, err)
380 require.EqualError(t, errShardDataNotPrepared, err.Error())
381 }
382 }
383
384 var well []proto.Vuid
385 for _, repl := range replicas {
386 isFail := false
387 for _, fail := range failVuids {
388 if fail == repl.Vuid {
389 isFail = true
390 break
391 }
392 }
393 if !isFail {
394 well = append(well, repl.Vuid)
395 }
396 }
397
398 for _, repl := range well {
399 for _, bid := range repairBids {
400 _, err := repair.GetShard(repl.Index(), bid)
401 require.NoError(t, err)
402 }
403 }
404}
405
406func TestDirect(t *testing.T) {
407 ctx := context.Background()

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
InitMockRepairFunction · 0.85
IndexesMethod · 0.80
allocBufMethod · 0.80
setFailMethod · 0.80
GetShardMethod · 0.65
IndexMethod · 0.65
ErrorMethod · 0.65
downloadMethod · 0.45

Tested by

no test coverage detected