MCPcopy
hub / github.com/rclone/rclone / TestInternalMaxChunkSizeRespected

Function TestInternalMaxChunkSizeRespected

backend/cache/cache_internal_test.go:671–706  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

669}
670
671func TestInternalMaxChunkSizeRespected(t *testing.T) {
672 if runtime.GOOS == "windows" && runtime.GOARCH == "386" {
673 t.Skip("Skip test on windows/386")
674 }
675 id := fmt.Sprintf("timcsr%v", time.Now().Unix())
676 rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, false, true, map[string]string{"workers": "1"})
677
678 cfs, err := runInstance.getCacheFs(rootFs)
679 require.NoError(t, err)
680 chunkSize := cfs.ChunkSize()
681 totalChunks := 20
682
683 // create some rand test data
684 testData := randStringBytes(int(int64(totalChunks-1)*chunkSize + chunkSize/2))
685 runInstance.writeRemoteBytes(t, rootFs, "data.bin", testData)
686 o, err := cfs.NewObject(context.Background(), runInstance.encryptRemoteIfNeeded(t, "data.bin"))
687 require.NoError(t, err)
688 co, ok := o.(*cache.Object)
689 require.True(t, ok)
690
691 for i := range 4 { // read first 4
692 _ = runInstance.readDataFromObj(t, co, chunkSize*int64(i), chunkSize*int64(i+1), false)
693 }
694 cfs.CleanUpCache(true)
695 // the last 2 **must** be in the cache
696 require.True(t, boltDb.HasChunk(co, chunkSize*2))
697 require.True(t, boltDb.HasChunk(co, chunkSize*3))
698
699 for i := 4; i < 6; i++ { // read next 2
700 _ = runInstance.readDataFromObj(t, co, chunkSize*int64(i), chunkSize*int64(i+1), false)
701 }
702 cfs.CleanUpCache(true)
703 // the last 2 **must** be in the cache
704 require.True(t, boltDb.HasChunk(co, chunkSize*4))
705 require.True(t, boltDb.HasChunk(co, chunkSize*5))
706}
707
708func TestInternalExpiredEntriesRemoved(t *testing.T) {
709 id := fmt.Sprintf("tieer%v", time.Now().Unix())

Callers

nothing calls this directly

Calls 10

randStringBytesFunction · 0.85
newCacheFsMethod · 0.80
getCacheFsMethod · 0.80
ChunkSizeMethod · 0.80
writeRemoteBytesMethod · 0.80
encryptRemoteIfNeededMethod · 0.80
readDataFromObjMethod · 0.80
CleanUpCacheMethod · 0.80
NewObjectMethod · 0.65
HasChunkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…