dubee closed pull request #3528: move select tests to Rest extension
URL: https://github.com/apache/incubator-openwhisk/pull/3528
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 274cf990ef..31ceb28177 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 2dbc866a1f..dbafbcd5bf 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 d081fdb661..8b073747db 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 5d576c4233..279e330e5f 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")
----------------------------------------------------------------
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