You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by du...@apache.org on 2018/04/05 17:24:15 UTC

[incubator-openwhisk] branch master updated: Move select tests to Rest extension (#3528)

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 b7f37b6  Move select tests to Rest extension (#3528)
b7f37b6 is described below

commit b7f37b6d84b461b2af9bddaca7667c91350b3fd0
Author: David Cariello <dr...@us.ibm.com>
AuthorDate: Thu Apr 5 12:24:12 2018 -0500

    Move select tests to Rest extension (#3528)
---
 .../test/scala/system/basic/WskActionTests.scala   | 10 -------
 .../scala/system/basic/WskRestActionTests.scala    | 12 ++++++++
 .../test/scala/system/basic/WskRestRuleTests.scala | 35 ++++++++++++++++++++++
 .../src/test/scala/system/basic/WskRuleTests.scala | 31 -------------------
 4 files changed, 47 insertions(+), 41 deletions(-)

diff --git a/tests/src/test/scala/system/basic/WskActionTests.scala b/tests/src/test/scala/system/basic/WskActionTests.scala
index 274cf99..31ceb28 100644
--- a/tests/src/test/scala/system/basic/WskActionTests.scala
+++ b/tests/src/test/scala/system/basic/WskActionTests.scala
@@ -38,7 +38,6 @@ 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)
@@ -225,15 +224,6 @@ abstract class WskActionTests extends TestHelpers with WskTestHelpers with JsHel
     }
   }
 
-  it should "create an action with an empty file" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
-    val name = "empty"
-    assetHelper.withCleaner(wsk.action, name) { (action, _) =>
-      action.create(name, Some(TestUtils.getTestActionFilename("empty.js")))
-    }
-    val rr = wsk.action.get(name)
-    getJSONFromResponse(rr.stdout, cli).getFieldPath("exec", "code") shouldBe Some(JsString(""))
-  }
-
   it should "blocking invoke of nested blocking actions" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
     val name = "nestedBlockingAction"
     val child = "wc"
diff --git a/tests/src/test/scala/system/basic/WskRestActionTests.scala b/tests/src/test/scala/system/basic/WskRestActionTests.scala
index 2dbc866..dbafbcd 100644
--- a/tests/src/test/scala/system/basic/WskRestActionTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestActionTests.scala
@@ -21,8 +21,20 @@ import org.junit.runner.RunWith
 import org.scalatest.junit.JUnitRunner
 
 import common.rest.WskRest
+import common.TestUtils
+
+import spray.json._
 
 @RunWith(classOf[JUnitRunner])
 class WskRestActionTests extends WskActionTests {
   override val wsk: WskRest = new WskRest
+
+  it should "create an action with an empty file" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
+    val name = "empty"
+    assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+      action.create(name, Some(TestUtils.getTestActionFilename("empty.js")))
+    }
+    val rr = wsk.action.get(name)
+    getJSONFromResponse(rr.stdout, false).getFieldPath("exec", "code") shouldBe Some(JsString(""))
+  }
 }
diff --git a/tests/src/test/scala/system/basic/WskRestRuleTests.scala b/tests/src/test/scala/system/basic/WskRestRuleTests.scala
index d081fdb..8b07374 100644
--- a/tests/src/test/scala/system/basic/WskRestRuleTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestRuleTests.scala
@@ -24,6 +24,13 @@ import common.TestUtils.RunResult
 import common.rest.WskRest
 import common.rest.RestResult
 
+import whisk.utils.retry
+
+import scala.concurrent.duration._
+
+import spray.json._
+import spray.json.DefaultJsonProtocol._
+
 @RunWith(classOf[JUnitRunner])
 class WskRestRuleTests extends WskRuleTests {
   override val wsk: common.rest.WskRest = new WskRest
@@ -41,4 +48,32 @@ class WskRestRuleTests extends WskRuleTests {
     rules.exists(rule => RestResult.getField(rule, "name") == ruleName) shouldBe true
     ruleListResultRest.respData should not include ("Unknown")
   }
+
+  it should "preserve rule status when a rule is updated" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
+    val ruleName = withTimestamp("r1to1")
+    val triggerName = withTimestamp("t1to1")
+    val actionName = withTimestamp("a1 to 1")
+    val triggerName2 = withTimestamp("t2to1")
+    val active = Some("active".toJson)
+    val inactive = Some("inactive".toJson)
+    val statusPermutations =
+      Seq((triggerName, active), (triggerName, inactive), (triggerName2, active), (triggerName, inactive))
+
+    ruleSetup(Seq((ruleName, triggerName, (actionName, actionName, defaultAction))), assetHelper)
+    assetHelper.withCleaner(wsk.trigger, triggerName2) { (trigger, name) =>
+      trigger.create(name)
+    }
+
+    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({
+          val createStdout = wsk.rule.create(ruleName, trigger, actionName, update = true).stdout
+          val getStdout = wsk.rule.get(ruleName).stdout
+          getJSONFromResponse(createStdout, false).fields.get("status") shouldBe status
+          getJSONFromResponse(getStdout, false).fields.get("status") shouldBe status
+        }, 10, Some(1.second))
+    }
+  }
 }
diff --git a/tests/src/test/scala/system/basic/WskRuleTests.scala b/tests/src/test/scala/system/basic/WskRuleTests.scala
index 5d576c4..279e330 100644
--- a/tests/src/test/scala/system/basic/WskRuleTests.scala
+++ b/tests/src/test/scala/system/basic/WskRuleTests.scala
@@ -29,8 +29,6 @@ import common.RuleActivationResult
 import spray.json._
 import spray.json.DefaultJsonProtocol._
 import java.time.Instant
-import whisk.utils.retry
-import scala.concurrent.duration._
 
 @RunWith(classOf[JUnitRunner])
 abstract class WskRuleTests extends TestHelpers with WskTestHelpers {
@@ -41,7 +39,6 @@ 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
@@ -84,34 +81,6 @@ abstract class WskRuleTests extends TestHelpers with WskTestHelpers {
 
   behavior of "Whisk rules"
 
-  it should "preserve rule status when a rule is updated" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
-    val ruleName = withTimestamp("r1to1")
-    val triggerName = withTimestamp("t1to1")
-    val actionName = withTimestamp("a1 to 1")
-    val triggerName2 = withTimestamp("t2to1")
-    val active = Some("active".toJson)
-    val inactive = Some("inactive".toJson)
-    val statusPermutations =
-      Seq((triggerName, active), (triggerName, inactive), (triggerName2, active), (triggerName, inactive))
-
-    ruleSetup(Seq((ruleName, triggerName, (actionName, actionName, defaultAction))), assetHelper)
-    assetHelper.withCleaner(wsk.trigger, triggerName2) { (trigger, name) =>
-      trigger.create(name)
-    }
-
-    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({
-          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))
-    }
-  }
-
   it should "invoke the action attached on trigger fire, creating an activation for each entity including the cause" in withAssetCleaner(
     wskprops) { (wp, assetHelper) =>
     val ruleName = withTimestamp("r1to1")

-- 
To stop receiving notification emails like this one, please contact
dubeejw@apache.org.