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 f324618 Move CLI node tests to CLI repo and sync Node.js default tests (#3503) f324618 is described below commit f32461841ef9d27d5667f5920cc95192fc3f1914 Author: David Cariello <drcar...@us.ibm.com> AuthorDate: Wed Apr 4 13:12:22 2018 -0500 Move CLI node tests to CLI repo and sync Node.js default tests (#3503) * move CLI node tests to CLI repo and sync node default tests * remove duplicate tests * move appropriate rest tests from base to rest extention * merge duplicate tests and implement cli flag to handle different cases * use wsk test json helper in action test as well * override whisk config in rest requence tests * move whiskConfig assert to extension --- .../test/scala/system/basic/WskActionTests.scala | 3 +- .../system/basic/WskBasicNodeDefaultTests.scala | 32 ++++++++++++++++++++++ .../scala/system/basic/WskCliBasicNode6Tests.scala | 28 ------------------- .../scala/system/basic/WskCliBasicNode8Tests.scala | 28 ------------------- .../system/basic/WskCliBasicNodeDefaultTests.scala | 28 ------------------- .../scala/system/basic/WskRestSequenceTests.scala | 3 ++ .../src/test/scala/system/basic/WskRuleTests.scala | 22 +++++---------- .../test/scala/system/basic/WskSequenceTests.scala | 3 +- 8 files changed, 45 insertions(+), 102 deletions(-) diff --git a/tests/src/test/scala/system/basic/WskActionTests.scala b/tests/src/test/scala/system/basic/WskActionTests.scala index 7836b03..274cf99 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 e0e7316..2f5d8d3 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 9bcec86..0000000 --- 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 a6beb9f..0000000 --- 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 80f25ca..0000000 --- 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 bef4823..916b575 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 a454008..5d576c4 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 ca9ad0e..beb0ff3 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" -- To stop receiving notification emails like this one, please contact dube...@apache.org.