-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add retry count parameter to function uploads (#4841)
* feat: add retry count parameter to function uploads * chore: add newline * chore: add test * refactor: use retry count from backoff library Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5b112e3
commit e917f69
Showing
2 changed files
with
60 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const test = require('ava') | ||
const sinon = require('sinon') | ||
const { v4: generateUUID } = require('uuid') | ||
|
||
const { uploadFiles } = require('../../../../src/utils/deploy/upload-files') | ||
|
||
test('Adds a retry count to function upload requests', async (t) => { | ||
const uploadDeployFunction = sinon.stub() | ||
const mockError = new Error('Uh-oh') | ||
|
||
mockError.status = 500 | ||
|
||
uploadDeployFunction.onCall(0).throws(mockError) | ||
uploadDeployFunction.onCall(1).throws(mockError) | ||
uploadDeployFunction.onCall(2).resolves() | ||
|
||
const mockApi = { | ||
uploadDeployFunction, | ||
} | ||
const deployId = generateUUID() | ||
const files = [ | ||
{ | ||
assetType: 'function', | ||
filepath: '/some/path/func1.zip', | ||
normalizedPath: 'func1.zip', | ||
runtime: 'js', | ||
}, | ||
] | ||
const options = { | ||
concurrentUpload: 1, | ||
maxRetry: 3, | ||
statusCb: sinon.stub(), | ||
} | ||
|
||
await uploadFiles(mockApi, deployId, files, options) | ||
|
||
t.is(uploadDeployFunction.callCount, 3) | ||
t.is(uploadDeployFunction.firstCall.args[0].xNfRetryCount, undefined) | ||
t.is(uploadDeployFunction.secondCall.args[0].xNfRetryCount, 1) | ||
t.is(uploadDeployFunction.thirdCall.args[0].xNfRetryCount, 2) | ||
}) |
e917f69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📊 Benchmark results
Package size: 222 MB