dubee closed pull request #3503: move CLI node tests to CLI repo and sync node 
default tests
URL: https://github.com/apache/incubator-openwhisk/pull/3503
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/tests/src/test/scala/system/basic/WskActionTests.scala 
b/tests/src/test/scala/system/basic/WskActionTests.scala
index 7836b03d16..274cf990ef 100644
--- a/tests/src/test/scala/system/basic/WskActionTests.scala
+++ b/tests/src/test/scala/system/basic/WskActionTests.scala
@@ -38,6 +38,7 @@ abstract class WskActionTests extends TestHelpers with 
WskTestHelpers with JsHel
 
   implicit val wskprops = WskProps()
   val wsk: BaseWsk
+  val cli = false
 
   val testString = "this is a test"
   val testResult = JsObject("count" -> testString.split(" ").length.toJson)
@@ -230,7 +231,7 @@ abstract class WskActionTests extends TestHelpers with 
WskTestHelpers with JsHel
       action.create(name, Some(TestUtils.getTestActionFilename("empty.js")))
     }
     val rr = wsk.action.get(name)
-    wsk.parseJsonString(rr.stdout).getFieldPath("exec", "code") shouldBe 
Some(JsString(""))
+    getJSONFromResponse(rr.stdout, cli).getFieldPath("exec", "code") shouldBe 
Some(JsString(""))
   }
 
   it should "blocking invoke of nested blocking actions" in 
withAssetCleaner(wskprops) { (wp, assetHelper) =>
diff --git a/tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala 
b/tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala
index e0e73169a6..2f5d8d3219 100644
--- a/tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala
@@ -90,4 +90,36 @@ abstract class WskBasicNodeDefaultTests extends TestHelpers 
with WskTestHelpers
     val firstNewline = stdout.indexOf("\n")
     stdout.substring(firstNewline + 1).parseJson.asJsObject
   }
+
+  it should "Ensure that NodeJS actions can have a non-default entrypoint" in 
withAssetCleaner(wskprops) {
+    (wp, assetHelper) =>
+      val name = "niamNpmAction"
+      val file = Some(TestUtils.getTestActionFilename("niam.js"))
+
+      assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+        action.create(name, file, main = Some("niam"))
+      }
+
+      withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
+        val response = activation.response
+        response.result.get.fields.get("error") shouldBe empty
+        response.result.get.fields.get("greetings") should 
be(Some(JsString("Hello from a non-standard entrypoint.")))
+      }
+  }
+
+  it should "Ensure that zipped actions are encoded and uploaded as NodeJS 
actions" in withAssetCleaner(wskprops) {
+    (wp, assetHelper) =>
+      val name = "zippedNpmAction"
+      val file = Some(TestUtils.getTestActionFilename("zippedaction.zip"))
+
+      assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+        action.create(name, file, kind = Some("nodejs:default"))
+      }
+
+      withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
+        val response = activation.response
+        response.result.get.fields.get("error") shouldBe empty
+        response.result.get.fields.get("author") shouldBe defined
+      }
+  }
 }
diff --git a/tests/src/test/scala/system/basic/WskCliBasicNode6Tests.scala 
b/tests/src/test/scala/system/basic/WskCliBasicNode6Tests.scala
deleted file mode 100644
index 9bcec867d1..0000000000
--- a/tests/src/test/scala/system/basic/WskCliBasicNode6Tests.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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 common.Wsk
-
-import org.junit.runner.RunWith
-import org.scalatest.junit.JUnitRunner
-
-@RunWith(classOf[JUnitRunner])
-class WskCliBasicNode6Tests extends WskBasicNode6Tests {
-  override val wsk: Wsk = new Wsk
-}
diff --git a/tests/src/test/scala/system/basic/WskCliBasicNode8Tests.scala 
b/tests/src/test/scala/system/basic/WskCliBasicNode8Tests.scala
deleted file mode 100644
index a6beb9f336..0000000000
--- a/tests/src/test/scala/system/basic/WskCliBasicNode8Tests.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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 common.Wsk
-
-import org.junit.runner.RunWith
-import org.scalatest.junit.JUnitRunner
-
-@RunWith(classOf[JUnitRunner])
-class WskCliBasicNode8Tests extends WskBasicNode8Tests {
-  override val wsk: Wsk = new Wsk
-}
diff --git 
a/tests/src/test/scala/system/basic/WskCliBasicNodeDefaultTests.scala 
b/tests/src/test/scala/system/basic/WskCliBasicNodeDefaultTests.scala
deleted file mode 100644
index 80f25caba3..0000000000
--- a/tests/src/test/scala/system/basic/WskCliBasicNodeDefaultTests.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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 common.Wsk
-
-import org.junit.runner.RunWith
-import org.scalatest.junit.JUnitRunner
-
-@RunWith(classOf[JUnitRunner])
-class WskCliBasicNodeDefaultTests extends WskBasicNodeDefaultTests {
-  override val wsk: Wsk = new Wsk
-}
diff --git a/tests/src/test/scala/system/basic/WskRestSequenceTests.scala 
b/tests/src/test/scala/system/basic/WskRestSequenceTests.scala
index bef4823c53..916b575166 100644
--- a/tests/src/test/scala/system/basic/WskRestSequenceTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestSequenceTests.scala
@@ -21,6 +21,7 @@ import org.junit.runner.RunWith
 import org.scalatest.junit.JUnitRunner
 
 import common.rest.WskRest
+import whisk.core.WhiskConfig
 
 /**
  * Tests sequence execution
@@ -29,4 +30,6 @@ import common.rest.WskRest
 @RunWith(classOf[JUnitRunner])
 class WskRestSequenceTests extends WskSequenceTests {
   override val wsk: common.rest.WskRest = new WskRest
+  override val whiskConfig = new 
WhiskConfig(Map(WhiskConfig.actionSequenceMaxLimit -> null))
+  assert(whiskConfig.isValid)
 }
diff --git a/tests/src/test/scala/system/basic/WskRuleTests.scala 
b/tests/src/test/scala/system/basic/WskRuleTests.scala
index a454008789..5d576c4233 100644
--- a/tests/src/test/scala/system/basic/WskRuleTests.scala
+++ b/tests/src/test/scala/system/basic/WskRuleTests.scala
@@ -41,6 +41,7 @@ abstract class WskRuleTests extends TestHelpers with 
WskTestHelpers {
   val secondAction = TestUtils.getTestActionFilename("hello.js")
   val testString = "this is a test"
   val testResult = JsObject("count" -> testString.split(" ").length.toJson)
+  val cli = false
 
   /**
    * Sets up trigger -> rule -> action triplets. Deduplicates triggers and 
rules
@@ -101,22 +102,13 @@ abstract class WskRuleTests extends TestHelpers with 
WskTestHelpers {
     statusPermutations.foreach {
       case (trigger, status) =>
         if (status == active) wsk.rule.enable(ruleName) else 
wsk.rule.disable(ruleName)
-
         // Needs to be retried since the enable/disable causes a cache 
invalidation which needs to propagate first
-        retry(
-          {
-            wsk.rule
-              .create(ruleName, trigger, actionName, update = true)
-              .stdout
-              .parseJson
-              .asJsObject
-              .fields
-              .get("status") shouldBe status
-
-            
wsk.rule.get(ruleName).stdout.parseJson.asJsObject.fields.get("status") 
shouldBe status
-          },
-          10,
-          Some(1.second))
+        retry({
+          val createStdout = wsk.rule.create(ruleName, trigger, actionName, 
update = true).stdout
+          val getStdout = wsk.rule.get(ruleName).stdout
+          getJSONFromResponse(createStdout, cli).fields.get("status") shouldBe 
status
+          getJSONFromResponse(getStdout, cli).fields.get("status") shouldBe 
status
+        }, 10, Some(1.second))
     }
   }
 
diff --git a/tests/src/test/scala/system/basic/WskSequenceTests.scala 
b/tests/src/test/scala/system/basic/WskSequenceTests.scala
index ca9ad0eb9b..beb0ff367f 100644
--- a/tests/src/test/scala/system/basic/WskSequenceTests.scala
+++ b/tests/src/test/scala/system/basic/WskSequenceTests.scala
@@ -56,8 +56,7 @@ abstract class WskSequenceTests extends TestHelpers with 
ScalatestRouteTest with
   val allowedActionDuration = 120 seconds
   val shortDuration = 10 seconds
 
-  val whiskConfig = new WhiskConfig(Map(WhiskConfig.actionSequenceMaxLimit -> 
null))
-  assert(whiskConfig.isValid)
+  val whiskConfig: WhiskConfig
 
   behavior of "Wsk Sequence"
 


 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to