This is an automated email from the ASF dual-hosted git repository. dubeejw pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push: new f767599 Add activation logs strip option. (#2620) f767599 is described below commit f7675991d413b51b4e9a23d033f32df573f13895 Author: David Liu <noellaw2...@126.com> AuthorDate: Sat Sep 16 00:10:47 2017 +0800 Add activation logs strip option. (#2620) * Add activation logs strip option. * Add proper test for strip option. * Remove dead code. --- .../main/scala/whisk/core/entity/WhiskStore.scala | 1 + .../main/scala/whisk/core/controller/Actions.scala | 5 +---- tests/dat/actions/log.js | 7 +++++++ .../whisk/core/cli/test/WskBasicUsageTests.scala | 20 +++++++++++++++++++- tools/cli/go-whisk-cli/commands/activation.go | 2 +- tools/cli/go-whisk-cli/commands/flags.go | 1 + tools/cli/go-whisk-cli/commands/util.go | 7 ++++++- .../go-whisk-cli/wski18n/resources/en_US.all.json | 4 ++++ 8 files changed, 40 insertions(+), 7 deletions(-) diff --git a/common/scala/src/main/scala/whisk/core/entity/WhiskStore.scala b/common/scala/src/main/scala/whisk/core/entity/WhiskStore.scala index 21595b7..6c3f872 100644 --- a/common/scala/src/main/scala/whisk/core/entity/WhiskStore.scala +++ b/common/scala/src/main/scala/whisk/core/entity/WhiskStore.scala @@ -51,6 +51,7 @@ package object types { type EntityStore = ArtifactStore[WhiskEntity] type ActivationStore = ArtifactStore[WhiskActivation] } + protected[core] trait WhiskDocument extends DocumentSerializer with DocumentRevisionProvider { /** diff --git a/core/controller/src/main/scala/whisk/core/controller/Actions.scala b/core/controller/src/main/scala/whisk/core/controller/Actions.scala index e760c1e..6be768c 100644 --- a/core/controller/src/main/scala/whisk/core/controller/Actions.scala +++ b/core/controller/src/main/scala/whisk/core/controller/Actions.scala @@ -60,9 +60,6 @@ import whisk.core.entitlement.Privilege._ object WhiskActionsApi { def requiredProperties = Map(WhiskConfig.actionSequenceMaxLimit -> null) - /** Grace period after action timeout limit to poll for result. */ - protected[core] val blockingInvokeGrace = 5 seconds - /** * Max duration to wait for a blocking activation. * This is the default timeout on a POST request. @@ -593,7 +590,7 @@ trait WhiskActionsApi extends WhiskCollectionAPI with PostActionActivation with * the given original sequence. * * @param origSequence the original sequence that is updated/created which generated the checks - * @param the components of the a sequence to check if they reference the original sequence + * @param components the components of the a sequence to check if they reference the original sequence * @return Future with the number of atomic actions in the current sequence or an appropriate error if there is a cycle or a non-existent action reference */ private def countAtomicActionsAndCheckCycle( diff --git a/tests/dat/actions/log.js b/tests/dat/actions/log.js new file mode 100644 index 0000000..bfbd513 --- /dev/null +++ b/tests/dat/actions/log.js @@ -0,0 +1,7 @@ +/** + * Emit strings to stdout/stderr. + */ +function main() { + console.log("this is stdout"); + console.error("this is stderr"); +} diff --git a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala index b21a218..e9f17e5 100644 --- a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala +++ b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala @@ -307,6 +307,22 @@ class WskBasicUsageTests extends TestHelpers with WskTestHelpers { N = 5) } + it should "ensure timestamp and stream are stripped from log lines" in withAssetCleaner(wskprops) { + val name = "activationLogStripTest" + val auth: Seq[String] = Seq("--auth", wskprops.authKey) + + (wp, assetHelper) => + assetHelper.withCleaner(wsk.action, name) { (action, _) => + action.create(name, Some(TestUtils.getTestActionFilename("log.js"))) + } + + withActivation(wsk.activation, wsk.action.invoke(name)) { activation => + val cmd = Seq("activation", "logs", "--strip", activation.activationId) + val run = wsk.cli(cmd ++ wskprops.overrides ++ auth, expectedExitCode = SUCCESS_EXIT) + run.stdout shouldBe "this is stdout\nthis is stderr\n" + } + } + it should "ensure keys are not omitted from activation record" in withAssetCleaner(wskprops) { val name = "activationRecordTest" @@ -352,7 +368,9 @@ class WskBasicUsageTests extends TestHelpers with WskTestHelpers { "key" -> JsString("limits"), "value" -> ActionLimits(TimeLimit(timeLimit), MemoryLimit(memoryLimit), LogLimit(logLimit)).toJson) - val path = annotations.find { _.fields("key").convertTo[String] == "path" }.get + val path = annotations.find { + _.fields("key").convertTo[String] == "path" + }.get path.fields("value").convertTo[String] should fullyMatch regex (s""".*/$name""") annotations should contain(limitsObj) diff --git a/tools/cli/go-whisk-cli/commands/activation.go b/tools/cli/go-whisk-cli/commands/activation.go index 59e84fe..9021267 100644 --- a/tools/cli/go-whisk-cli/commands/activation.go +++ b/tools/cli/go-whisk-cli/commands/activation.go @@ -401,7 +401,7 @@ func init() { activationGetCmd.Flags().BoolVarP(&flags.activation.last, "last", "l", false, wski18n.T("retrieves the last activation")) activationLogsCmd.Flags().BoolVarP(&flags.activation.last, "last", "l", false, wski18n.T("retrieves the last activation")) - + activationLogsCmd.Flags().BoolVarP(&flags.activation.strip, "strip", "r", false, wski18n.T("strip timestamp and stream information")) activationResultCmd.Flags().BoolVarP(&flags.activation.last, "last", "l", false, wski18n.T("retrieves the last activation")) activationPollCmd.Flags().IntVarP(&flags.activation.exit, "exit", "e", 0, wski18n.T("stop polling after `SECONDS` seconds")) diff --git a/tools/cli/go-whisk-cli/commands/flags.go b/tools/cli/go-whisk-cli/commands/flags.go index 15f9ed4..834c04a 100644 --- a/tools/cli/go-whisk-cli/commands/flags.go +++ b/tools/cli/go-whisk-cli/commands/flags.go @@ -94,6 +94,7 @@ type Flags struct { sinceDays int exit int last bool + strip bool } // rule diff --git a/tools/cli/go-whisk-cli/commands/util.go b/tools/cli/go-whisk-cli/commands/util.go index 9288cae..e8c422f 100644 --- a/tools/cli/go-whisk-cli/commands/util.go +++ b/tools/cli/go-whisk-cli/commands/util.go @@ -273,7 +273,12 @@ func printFullActivationList(activations []whisk.Activation) { func printActivationLogs(logs []string) { for _, log := range logs { - fmt.Printf("%s\n", log) + if (flags.activation.strip){ + fmt.Printf("%s\n", log[39:]) + } else { + fmt.Printf("%s\n", log) + } + } } diff --git a/tools/cli/go-whisk-cli/wski18n/resources/en_US.all.json b/tools/cli/go-whisk-cli/wski18n/resources/en_US.all.json index 39551d0..5f5bdf8 100644 --- a/tools/cli/go-whisk-cli/wski18n/resources/en_US.all.json +++ b/tools/cli/go-whisk-cli/wski18n/resources/en_US.all.json @@ -1064,6 +1064,10 @@ "translation": "retrieves the last activation" }, { + "id": "strip timestamp and stream information", + "translation": "strip timestamp and stream information" + }, + { "id": "stop polling after `SECONDS` seconds", "translation": "stop polling after `SECONDS` seconds" }, -- To stop receiving notification emails like this one, please contact ['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].