Test queuing more than fs.Config.Transfers
(t *testing.T)
| 591 | |
| 592 | // Test queuing more than fs.Config.Transfers |
| 593 | func TestWriteBackMaxQueue(t *testing.T) { |
| 594 | ctx := context.Background() |
| 595 | ci := fs.GetConfig(ctx) |
| 596 | wb, cancel := newTestWriteBack(t) |
| 597 | defer cancel() |
| 598 | |
| 599 | maxTransfers := ci.Transfers |
| 600 | toTransfer := maxTransfers + 2 |
| 601 | |
| 602 | // put toTransfer things in the queue |
| 603 | pis := []*putItem{} |
| 604 | for range toTransfer { |
| 605 | pi := newPutItem(t) |
| 606 | pis = append(pis, pi) |
| 607 | wb.Add(0, fmt.Sprintf("number%d", 1), 10, true, pi.put) |
| 608 | } |
| 609 | |
| 610 | inProgress, queued := wb.Stats() |
| 611 | assert.Equal(t, toTransfer, queued) |
| 612 | assert.Equal(t, 0, inProgress) |
| 613 | |
| 614 | // now start the first maxTransfers - this should stop the timer |
| 615 | for i := range maxTransfers { |
| 616 | <-pis[i].started |
| 617 | } |
| 618 | |
| 619 | // timer should be stopped now |
| 620 | assertTimerRunning(t, wb, false) |
| 621 | |
| 622 | inProgress, queued = wb.Stats() |
| 623 | assert.Equal(t, toTransfer-maxTransfers, queued) |
| 624 | assert.Equal(t, maxTransfers, inProgress) |
| 625 | |
| 626 | // now finish the first maxTransfers |
| 627 | for i := range maxTransfers { |
| 628 | pis[i].finish(nil) |
| 629 | } |
| 630 | |
| 631 | // now start and finish the remaining transfers one at a time |
| 632 | for i := maxTransfers; i < toTransfer; i++ { |
| 633 | <-pis[i].started |
| 634 | pis[i].finish(nil) |
| 635 | } |
| 636 | waitUntilNoTransfers(t, wb) |
| 637 | |
| 638 | inProgress, queued = wb.Stats() |
| 639 | assert.Equal(t, queued, 0) |
| 640 | assert.Equal(t, inProgress, 0) |
| 641 | } |
| 642 | |
| 643 | func TestWriteBackRename(t *testing.T) { |
| 644 | wb, cancel := newTestWriteBack(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…