Skip to content

Commit

Permalink
Merge pull request #316 from adobe/add-concurrency-option
Browse files Browse the repository at this point in the history
feat: add concurrency flag to create and update
  • Loading branch information
MichaelGoberling authored Jul 20, 2023
2 parents 7675abf + 78eb43d commit ea0da26
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/commands/runtime/action/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ class ActionCreate extends RuntimeBaseCommand {
limits = limits || {}
limits.memory = flags.memory
}
if (flags.concurrency) {
limits = limits || {}
limits.concurrency = flags.concurrency
}

const options = { name }
if (exec) {
Expand Down Expand Up @@ -294,6 +298,10 @@ ActionCreate.flags = {
min: ActionCreate.limits.logsizeMB.min,
max: ActionCreate.limits.logsizeMB.max
}),
concurrency: Flags.integer({
char: 'c',
description: 'the maximum number of action invocations to send to the same container in parallel (default 200, min: 1, max: 500)' // help description for flag
}),
kind: Flags.string({
description: 'the KIND of the action runtime (example: swift:default, nodejs:default)' // help description for flag
}),
Expand Down
34 changes: 32 additions & 2 deletions test/commands/runtime/action/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ describe('instance methods', () => {
test('creates an action with action name, action path, --params flag, limits and kind', () => {
const name = 'hello'
const cmd = rtLib.mockResolved(rtAction, { res: 'fake' })
command.argv = [name, '/action/actionFile.js', '--param', 'a', 'b', '--param', 'c', 'd', '--logsize', '8', '--memory', '128', '--kind', 'nodejs:10']
command.argv = [name, '/action/actionFile.js', '--param', 'a', 'b', '--param', 'c', 'd', '--logsize', '8', '--memory', '128', '--concurrency', '1', '--kind', 'nodejs:10']
rtUtils.getKeyValueArrayFromMergedParameters.mockImplementation((flags, file) => flags && ([{ key: 'fakeParam', value: 'aaa' }, { key: 'fakeParam2', value: 'bbb' }]))
return command.run()
.then(() => {
Expand All @@ -384,7 +384,37 @@ describe('instance methods', () => {
],
limits: {
logs: 8,
memory: 128
memory: 128,
concurrency: 1
}
}
})
expect(stdout.output).toMatch('')
})
})

test('creates an action with action name, action path, --params flag, only concurrency limit and kind', () => {
const name = 'hello'
const cmd = rtLib.mockResolved(rtAction, { res: 'fake' })
command.argv = [name, '/action/actionFile.js', '--param', 'a', 'b', '--param', 'c', 'd', '--concurrency', '1', '--kind', 'nodejs:10']
rtUtils.getKeyValueArrayFromMergedParameters.mockImplementation((flags, file) => flags && ([{ key: 'fakeParam', value: 'aaa' }, { key: 'fakeParam2', value: 'bbb' }]))
return command.run()
.then(() => {
expect(rtUtils.getKeyValueArrayFromMergedParameters).toHaveBeenCalledWith(['a', 'b', 'c', 'd'], undefined)
expect(cmd).toHaveBeenCalledWith({
name,
action: {
name,
exec: {
code: jsFile,
kind: 'nodejs:10'
},
parameters: [
{ key: 'fakeParam', value: 'aaa' },
{ key: 'fakeParam2', value: 'bbb' }
],
limits: {
concurrency: 1
}
}
})
Expand Down

0 comments on commit ea0da26

Please sign in to comment.