Skip to content

Commit

Permalink
Add new composite tests for parallel downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
sethiay committed Jul 15, 2024
1 parent 8c29ded commit 7f007d9
Show file tree
Hide file tree
Showing 2 changed files with 749 additions and 461 deletions.
28 changes: 28 additions & 0 deletions internal/cache/file/cache_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,3 +877,31 @@ func (cht *cacheHandleTest) Test_Read_Random_Parallel_Download_True() {
assert.False(cht.T(), cacheHit)
assert.ErrorContains(cht.T(), err, util.FallbackToGCSErrMsg)
}

func (cht *cacheHandleTest) Test_Read_RandomWithNoRandomDownload_And_ParallelDownloadsEnabled() {
dst := make([]byte, ReadContentSize)
offset := int64(cht.object.Size - ReadContentSize)
cht.cacheHandle.isSequential = false
cht.cacheHandle.cacheFileForRangeRead = false
cht.cacheHandle.fileDownloadJob = downloader.NewJob(
cht.object,
cht.bucket,
cht.cache,
DefaultSequentialReadSizeMb,
cht.fileSpec,
func() {},
&config.FileCacheConfig{EnableCRC: true, EnableParallelDownloads: true, ParallelDownloadsPerFile: 5, DownloadChunkSizeMB: 2},
semaphore.NewWeighted(math.MaxInt64),
)

// Since, it's a random read, download job will not start.
n, cacheHit, err := cht.cacheHandle.Read(context.Background(), cht.bucket, cht.object, offset, dst)

jobStatus := cht.cacheHandle.fileDownloadJob.GetStatus()
assert.Equal(cht.T(), downloader.NotStarted, jobStatus.Name)
assert.Less(cht.T(), jobStatus.Offset, offset)
assert.Equal(cht.T(), n, 0)
assert.False(cht.T(), cacheHit)
assert.NotNil(cht.T(), err)
assert.True(cht.T(), strings.Contains(err.Error(), util.FallbackToGCSErrMsg))
}
Loading

0 comments on commit 7f007d9

Please sign in to comment.