mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-04 06:43:18 +08:00
Add option for concurrent cache downloads with timeout (#1484)
* Add option for concurrent cache downloads with timeout * Add release notes * Fix lint
This commit is contained in:
27
packages/cache/__tests__/cacheHttpClient.test.ts
vendored
27
packages/cache/__tests__/cacheHttpClient.test.ts
vendored
@@ -84,18 +84,24 @@ test('downloadCache uses storage SDK for Azure storage URLs', async () => {
|
||||
'downloadCacheStorageSDK'
|
||||
)
|
||||
|
||||
const downloadCacheHttpClientConcurrentMock = jest.spyOn(
|
||||
downloadUtils,
|
||||
'downloadCacheHttpClientConcurrent'
|
||||
)
|
||||
|
||||
const archiveLocation = 'http://foo.blob.core.windows.net/bar/baz'
|
||||
const archivePath = '/foo/bar'
|
||||
|
||||
await downloadCache(archiveLocation, archivePath)
|
||||
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledTimes(1)
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledWith(
|
||||
expect(downloadCacheHttpClientConcurrentMock).toHaveBeenCalledTimes(1)
|
||||
expect(downloadCacheHttpClientConcurrentMock).toHaveBeenCalledWith(
|
||||
archiveLocation,
|
||||
archivePath,
|
||||
getDownloadOptions()
|
||||
)
|
||||
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledTimes(0)
|
||||
expect(downloadCacheHttpClientMock).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
@@ -109,20 +115,26 @@ test('downloadCache passes options to download methods', async () => {
|
||||
'downloadCacheStorageSDK'
|
||||
)
|
||||
|
||||
const downloadCacheHttpClientConcurrentMock = jest.spyOn(
|
||||
downloadUtils,
|
||||
'downloadCacheHttpClientConcurrent'
|
||||
)
|
||||
|
||||
const archiveLocation = 'http://foo.blob.core.windows.net/bar/baz'
|
||||
const archivePath = '/foo/bar'
|
||||
const options: DownloadOptions = {downloadConcurrency: 4}
|
||||
|
||||
await downloadCache(archiveLocation, archivePath, options)
|
||||
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledTimes(1)
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalled()
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledWith(
|
||||
expect(downloadCacheHttpClientConcurrentMock).toHaveBeenCalledTimes(1)
|
||||
expect(downloadCacheHttpClientConcurrentMock).toHaveBeenCalled()
|
||||
expect(downloadCacheHttpClientConcurrentMock).toHaveBeenCalledWith(
|
||||
archiveLocation,
|
||||
archivePath,
|
||||
getDownloadOptions(options)
|
||||
)
|
||||
|
||||
expect(downloadCacheStorageSDKMock).toHaveBeenCalledTimes(0)
|
||||
expect(downloadCacheHttpClientMock).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
@@ -138,7 +150,10 @@ test('downloadCache uses http-client when overridden', async () => {
|
||||
|
||||
const archiveLocation = 'http://foo.blob.core.windows.net/bar/baz'
|
||||
const archivePath = '/foo/bar'
|
||||
const options: DownloadOptions = {useAzureSdk: false}
|
||||
const options: DownloadOptions = {
|
||||
useAzureSdk: false,
|
||||
concurrentBlobDownloads: false
|
||||
}
|
||||
|
||||
await downloadCache(archiveLocation, archivePath, options)
|
||||
|
||||
|
||||
7
packages/cache/__tests__/options.test.ts
vendored
7
packages/cache/__tests__/options.test.ts
vendored
@@ -5,7 +5,8 @@ import {
|
||||
getUploadOptions
|
||||
} from '../src/options'
|
||||
|
||||
const useAzureSdk = true
|
||||
const useAzureSdk = false
|
||||
const concurrentBlobDownloads = true
|
||||
const downloadConcurrency = 8
|
||||
const timeoutInMs = 30000
|
||||
const segmentTimeoutInMs = 600000
|
||||
@@ -18,6 +19,7 @@ test('getDownloadOptions sets defaults', async () => {
|
||||
|
||||
expect(actualOptions).toEqual({
|
||||
useAzureSdk,
|
||||
concurrentBlobDownloads,
|
||||
downloadConcurrency,
|
||||
timeoutInMs,
|
||||
segmentTimeoutInMs,
|
||||
@@ -27,7 +29,8 @@ test('getDownloadOptions sets defaults', async () => {
|
||||
|
||||
test('getDownloadOptions overrides all settings', async () => {
|
||||
const expectedOptions: DownloadOptions = {
|
||||
useAzureSdk: false,
|
||||
useAzureSdk: true,
|
||||
concurrentBlobDownloads: false,
|
||||
downloadConcurrency: 14,
|
||||
timeoutInMs: 20000,
|
||||
segmentTimeoutInMs: 3600000,
|
||||
|
||||
Reference in New Issue
Block a user