diff --git a/commands/action.go b/commands/action.go index bce0bf2a0..608c06e48 100644 --- a/commands/action.go +++ b/commands/action.go @@ -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.") + 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) diff --git a/tests/src/test/scala/whisk/core/cli/test/WskCliBasicUsageTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskCliBasicUsageTests.scala index 94a6ce557..72e096610 100644 --- a/tests/src/test/scala/whisk/core/cli/test/WskCliBasicUsageTests.scala +++ b/tests/src/test/scala/whisk/core/cli/test/WskCliBasicUsageTests.scala @@ -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) => + 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" diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json index 44b8ede20..d4546386f 100644 --- a/wski18n/resources/en_US.all.json +++ b/wski18n/resources/en_US.all.json @@ -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 '{}'."