MCPcopy
hub / github.com/rclone/rclone / TestWriteBackMaxQueue

Function TestWriteBackMaxQueue

vfs/vfscache/writeback/writeback_test.go:593–641  ·  view source on GitHub ↗

Test queuing more than fs.Config.Transfers

(t *testing.T)

Source from the content-addressed store, hash-verified

591
592// Test queuing more than fs.Config.Transfers
593func 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
643func TestWriteBackRename(t *testing.T) {
644 wb, cancel := newTestWriteBack(t)

Callers

nothing calls this directly

Calls 9

GetConfigFunction · 0.92
newTestWriteBackFunction · 0.85
newPutItemFunction · 0.85
assertTimerRunningFunction · 0.85
waitUntilNoTransfersFunction · 0.85
AddMethod · 0.65
StatsMethod · 0.45
EqualMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…