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' import {TransferProgressEvent} from '@azure/ms-rest-js'
test('upload progress tracked correctly', () => { test('upload progress tracked correctly', () => {
const progress = new UploadProgress(1000) const progress = new uploadUtils.UploadProgress(1000)
expect(progress.contentLength).toBe(1000) expect(progress.contentLength).toBe(1000)
expect(progress.sentBytes).toBe(0) expect(progress.sentBytes).toBe(0)
@ -56,3 +56,25 @@ test('upload progress tracked correctly', () => {
expect(progress.getTransferredBytes()).toBe(1000) expect(progress.getTransferredBytes()).toBe(1000)
expect(progress.isDone()).toBe(true) 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 { } else {
core.warning(`Failed to save: ${typedError.message}`) core.warning(`Failed to save: ${typedError.message}`)
} }
throw error
} finally { } finally {
// Try to delete the archive to save space // Try to delete the archive to save space
try { try {

View File

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