rabbah commented on a change in pull request #3202: Support action 
continuations in the controller
URL: 
https://github.com/apache/incubator-openwhisk/pull/3202#discussion_r162955796
 
 

 ##########
 File path: tests/src/test/scala/system/basic/WskConductorTests.scala
 ##########
 @@ -0,0 +1,311 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package system.basic
+
+import scala.concurrent.duration.DurationInt
+import scala.language.postfixOps
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import common.ActivationResult
+import common.StreamLogging
+import common.JsHelpers
+import common.TestHelpers
+import common.TestUtils
+import common.BaseWsk
+import common.WskProps
+import common.WskTestHelpers
+
+import spray.json._
+import spray.json.DefaultJsonProtocol._
+import spray.json.JsObject
+import spray.json.pimpAny
+
+import whisk.core.entity.size.SizeInt
+import whisk.core.WhiskConfig
+import whisk.http.Messages._
+
+@RunWith(classOf[JUnitRunner])
+abstract class WskConductorTests extends TestHelpers with WskTestHelpers with 
JsHelpers with StreamLogging {
+
+  implicit val wskprops = WskProps()
+  val wsk: BaseWsk
+  val allowedActionDuration = 120 seconds
+
+  val testString = "this is a test"
+  val invalid = "invalid#Action"
+  val missing = "missingAction"
+
+  val whiskConfig = new WhiskConfig(Map(WhiskConfig.actionSequenceMaxLimit -> 
null))
+  assert(whiskConfig.isValid)
+  val limit = whiskConfig.actionSequenceLimit.toInt
+
+  behavior of "Whisk conductor controller"
+
+  it should "invoke a conductor action with no dynamic steps" in 
withAssetCleaner(wskprops) { (wp, assetHelper) =>
+    val echo = "echo" // echo conductor action
+    assetHelper.withCleaner(wsk.action, echo) { (action, _) =>
+      action.create(
+        echo,
+        Some(TestUtils.getTestActionFilename("echo.js")),
+        annotations = Map("conductor" -> true.toJson))
+    }
+
+    // a normal result
+    val run = wsk.action.invoke(echo, Map("payload" -> testString.toJson))
+    withActivation(wsk.activation, run) { activation =>
+      activation.response.status shouldBe "success"
+      activation.response.result shouldBe Some(JsObject("payload" -> 
testString.toJson))
+      checkConductorLogsAndAnnotations(activation, 1) // echo
+    }
+
+    // an error result
+    val secondrun = wsk.action.invoke(echo, Map("error" -> testString.toJson))
+    withActivation(wsk.activation, secondrun) { activation =>
+      activation.response.status shouldBe "application error"
+      activation.response.result shouldBe Some(JsObject("error" -> 
testString.toJson))
+      checkConductorLogsAndAnnotations(activation, 1) // echo
+    }
+
+    // a wrapped result { params: result } is unwrapped by the controller
+    val thirdrun = wsk.action.invoke(echo, Map("params" -> JsObject("payload" 
-> testString.toJson)))
+    withActivation(wsk.activation, thirdrun) { activation =>
+      activation.response.status shouldBe "success"
+      activation.response.result shouldBe Some(JsObject("payload" -> 
testString.toJson))
+      checkConductorLogsAndAnnotations(activation, 1) // echo
+    }
+
+    // an invalid action name
+    val invalidrun =
+      wsk.action.invoke(echo, Map("payload" -> testString.toJson, "action" -> 
invalid.toJson))
+    withActivation(wsk.activation, invalidrun) { activation =>
+      activation.response.status shouldBe "application error"
+      activation.response.result.get.fields.get("error") shouldBe Some(
+        JsString(compositionComponentInvalid(JsString(invalid))))
+      checkConductorLogsAndAnnotations(activation, 1) // echo
+    }
+
+    // an undefined action
+    val undefinedrun = wsk.action.invoke(echo, Map("payload" -> 
testString.toJson, "action" -> missing.toJson))
+    withActivation(wsk.activation, undefinedrun) { activation =>
+      activation.response.status shouldBe "application error"
+      activation.response.result.get.fields.get("error") shouldBe 
Some(JsString(compositionComponentNotFound(missing)))
+      checkConductorLogsAndAnnotations(activation, 1) // echo
 
 Review comment:
   is there a separate  integration test for the not entitled case?
   how about invoking an action which is actually not an action (eg say a 
trigger).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to