| 360 | } |
| 361 | |
| 362 | func 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 | |
| 406 | func TestDirect(t *testing.T) { |
| 407 | ctx := context.Background() |