1
0
Fork 0

Retry artifact uploads on HTTP 500 (#833)

* Retry on 500

* bump package version

* fix tests

* Remove spurious change

* fix another test

* Roll back package version
pull/836/head
Brian Cristante 2021-06-04 17:09:30 -04:00 committed by GitHub
parent bb2f39337d
commit db21627995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -71,7 +71,7 @@ describe('Download Tests', () => {
setupFailedResponse() setupFailedResponse()
const downloadHttpClient = new DownloadHttpClient() const downloadHttpClient = new DownloadHttpClient()
expect(downloadHttpClient.listArtifacts()).rejects.toThrow( expect(downloadHttpClient.listArtifacts()).rejects.toThrow(
'List Artifacts failed: Artifact service responded with 500' 'List Artifacts failed: Artifact service responded with 400'
) )
}) })
@ -113,7 +113,7 @@ describe('Download Tests', () => {
configVariables.getRuntimeUrl() configVariables.getRuntimeUrl()
) )
).rejects.toThrow( ).rejects.toThrow(
`Get Container Items failed: Artifact service responded with 500` `Get Container Items failed: Artifact service responded with 400`
) )
}) })
@ -166,7 +166,7 @@ describe('Download Tests', () => {
it('Test retryable status codes during artifact download', async () => { it('Test retryable status codes during artifact download', async () => {
// The first http response should return a retryable status call while the subsequent call should return a 200 so // The first http response should return a retryable status call while the subsequent call should return a 200 so
// the download should successfully finish // the download should successfully finish
const retryableStatusCodes = [429, 502, 503, 504] const retryableStatusCodes = [429, 500, 502, 503, 504]
for (const statusCode of retryableStatusCodes) { for (const statusCode of retryableStatusCodes) {
const fileContents = Buffer.from('try, try again\n', defaultEncoding) const fileContents = Buffer.from('try, try again\n', defaultEncoding)
const targetPath = path.join(root, `FileC-${statusCode}.txt`) const targetPath = path.join(root, `FileC-${statusCode}.txt`)
@ -468,7 +468,7 @@ describe('Download Tests', () => {
function setupFailedResponse(): void { function setupFailedResponse(): void {
jest.spyOn(HttpClient.prototype, 'get').mockImplementationOnce(async () => { jest.spyOn(HttpClient.prototype, 'get').mockImplementationOnce(async () => {
const mockMessage = new http.IncomingMessage(new net.Socket()) const mockMessage = new http.IncomingMessage(new net.Socket())
mockMessage.statusCode = 500 mockMessage.statusCode = 400
return new Promise<HttpClientResponse>(resolve => { return new Promise<HttpClientResponse>(resolve => {
resolve({ resolve({
message: mockMessage, message: mockMessage,

View File

@ -107,8 +107,8 @@ test('retry fails after exhausting retries', async () => {
}) })
test('retry fails after non-retryable status code', async () => { test('retry fails after non-retryable status code', async () => {
await testRetry([500, 200], { await testRetry([400, 200], {
responseCode: 500, responseCode: 400,
errorMessage: 'test failed: Artifact service responded with 500' errorMessage: 'test failed: Artifact service responded with 400'
}) })
}) })

View File

@ -72,8 +72,9 @@ export function isRetryableStatusCode(statusCode: number | undefined): boolean {
const retryableStatusCodes = [ const retryableStatusCodes = [
HttpCodes.BadGateway, HttpCodes.BadGateway,
HttpCodes.ServiceUnavailable,
HttpCodes.GatewayTimeout, HttpCodes.GatewayTimeout,
HttpCodes.InternalServerError,
HttpCodes.ServiceUnavailable,
HttpCodes.TooManyRequests, HttpCodes.TooManyRequests,
413 // Payload Too Large 413 // Payload Too Large
] ]