Skip to content

Update cli to fail create/update sequences with limits #348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions commands/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,11 @@ func parseAction(cmd *cobra.Command, args []string, update bool) (*whisk.Action,
return nil, whisk.MakeWskError(errors.New(errStr), whisk.NOT_ALLOWED, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
}

if (Flags.action.sequence && (cmd.LocalFlags().Changed(MEMORY_FLAG) || cmd.LocalFlags().Changed(LOG_SIZE_FLAG) || cmd.LocalFlags().Changed(TIMEOUT_FLAG))) {
errStr := wski18n.T("A sequence cannot have a memory limit, a log size limit or a timeout limit.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we transition to using message identifiers instead as in https://github.com/apache/incubator-openwhisk-cli/blob/master/commands/messages.go#L26.

return nil, whisk.MakeWskError(errors.New(errStr), whisk.NOT_ALLOWED, whisk.DISPLAY_MSG, whisk.NO_DISPLAY_USAGE)
}

if Flags.action.copy {
var copiedQualifiedName = new(QualifiedName)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,48 @@ class WskCliBasicUsageTests extends TestHelpers with WskTestHelpers {
expectedExitCode = MISUSE_EXIT)
}

it should "reject create or update of an action sequence that sets a memory limit" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of these might be better suited as go unit tests - i think it makes sense to start adding new tests that are strictly testing the CLI in go.

val name = "badSeqMemLimit"
val file = Some(TestUtils.getTestActionFilename("hello.js"))
val memoryLimit = 512 MB

wsk.action.create(name, file, kind = Some("sequence"), memory = Some(memoryLimit), expectedExitCode = NOT_ALLOWED)
.stderr should include("A sequence cannot have a memory limit, a log size limit or a timeout limit.")
assetHelper.withCleaner(wsk.action, name) { (action, name) =>
action.create(name, file)
}
wsk.action.create(name, file, update = true, kind = Some("sequence"), memory = Some(memoryLimit), expectedExitCode = NOT_ALLOWED)
.stderr should include("A sequence cannot have a memory limit, a log size limit or a timeout limit.")
}

it should "reject create or update of an action sequence that sets a timeout limit" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
val name = "badSeqTimeoutLimit"
val file = Some(TestUtils.getTestActionFilename("hello.js"))
val timeLimit = 60 seconds

wsk.action.create(name, file, kind = Some("sequence"), timeout = Some(timeLimit), expectedExitCode = NOT_ALLOWED)
.stderr should include("A sequence cannot have a memory limit, a log size limit or a timeout limit.")
assetHelper.withCleaner(wsk.action, name) { (action, name) =>
action.create(name, file)
}
wsk.action.create(name, file, update = true, kind = Some("sequence"), timeout = Some(timeLimit), expectedExitCode = NOT_ALLOWED)
.stderr should include("A sequence cannot have a memory limit, a log size limit or a timeout limit.")
}

it should "reject create or update of an action sequence that sets a log size limit" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
val name = "badSeqLogsizeLimit"
val file = Some(TestUtils.getTestActionFilename("hello.js"))
val logLimit = 1 MB

wsk.action.create(name, file, kind = Some("sequence"), logsize = Some(logLimit), expectedExitCode = NOT_ALLOWED)
.stderr should include("A sequence cannot have a memory limit, a log size limit or a timeout limit.")
assetHelper.withCleaner(wsk.action, name) { (action, name) =>
action.create(name, file)
}
wsk.action.create(name, file, update = true, kind = Some("sequence"), logsize = Some(logLimit), expectedExitCode = NOT_ALLOWED)
.stderr should include("A sequence cannot have a memory limit, a log size limit or a timeout limit.")
}

it should "reject action update for sequence with no components" in withAssetCleaner(
wskprops) { (wp, assetHelper) =>
val name = "updateMissingComponents"
Expand Down
4 changes: 4 additions & 0 deletions wski18n/resources/en_US.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,10 @@
"id": "Cannot specify both --kind and --docker at the same time.",
"translation": "Cannot specify both --kind and --docker at the same time."
},
{
"id": "A sequence cannot have a memory limit, a log size limit or a timeout limit.",
"translation": "A sequence cannot have a memory limit, a log size limit or a timeout limit."
},
{
"id": "Relative path '{{.path}}' does not include valid path parameters. Each parameter must be enclosed in curly braces '{}'.",
"translation": "Relative path '{{.path}}' does not include valid path parameters. Each parameter must be enclosed in curly braces '{}'."
Expand Down