1
0
Fork 0

Troubleshoot

pull/1882/head
Bassem Dghaidi 2024-12-02 03:35:20 -08:00 committed by GitHub
parent 4a272e9053
commit db1d01308c
3 changed files with 48 additions and 22 deletions

View File

@ -1,8 +1,8 @@
import {UploadProgress} from '../src/internal/uploadUtils'
import * as uploadUtils from '../src/internal/uploadUtils'
import {TransferProgressEvent} from '@azure/ms-rest-js'
test('upload progress tracked correctly', () => {
const progress = new UploadProgress(1000)
const progress = new uploadUtils.UploadProgress(1000)
expect(progress.contentLength).toBe(1000)
expect(progress.sentBytes).toBe(0)
@ -56,3 +56,25 @@ test('upload progress tracked correctly', () => {
expect(progress.getTransferredBytes()).toBe(1000)
expect(progress.isDone()).toBe(true)
})
// test('upload to azure blob storage is successful', () => {
// const archivePath = 'path/to/archive.tzst'
// const signedUploadURL = 'https://storage10.blob.core.windows.net/cache-container/3fe-60?se=2024-12-002T11%3A08%3A58Z&sv=2024-11-04'
// const options: UploadOptions = {
// useAzureSdk: true,
// uploadChunkSize: 64 * 1024 * 1024,
// uploadConcurrency: 8
// }
// jest.spyOn(uploadUtils.UploadProgress.prototype, 'onProgress').mockImplementation(() => (progress: TransferProgressEvent) => {
// return progress.loadedBytes
// })
// jest.spyOn(uploadUtils.UploadProgress.prototype, 'onProgress').mockImplementation(() => (progress: TransferProgressEvent) => {
// return progress.loadedBytes
// })
// const response = uploadUtils.uploadCacheArchiveSDK(signedUploadURL, archivePath, options)
// expect(response).toBeInstanceOf(Promise)
// })

View File

@ -561,6 +561,7 @@ async function saveCacheV2(
} else {
core.warning(`Failed to save: ${typedError.message}`)
}
throw error
} finally {
// Try to delete the archive to save space
try {

View File

@ -140,14 +140,17 @@ export async function uploadCacheArchiveSDK(
onProgress: uploadProgress.onProgress()
}
// try {
try {
uploadProgress.startDisplayTimer()
core.debug(
`BlobClient: ${blobClient.name}:${blobClient.accountName}:${blobClient.containerName}`
)
const response = await blockBlobClient.uploadFile(archivePath, uploadOptions)
const response = await blockBlobClient.uploadFile(
archivePath,
uploadOptions
)
// TODO: better management of non-retryable errors
if (response._response.status >= 400) {
@ -157,10 +160,10 @@ export async function uploadCacheArchiveSDK(
}
return response
// } catch (error) {
// core.debug(`Error uploading cache archive: ${error}`)
// throw error
// } finally {
// uploadProgress.stopDisplayTimer()
// }
} catch (error) {
core.debug(`Error uploading cache archive: ${error}`)
throw error
} finally {
uploadProgress.stopDisplayTimer()
}
}