You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2017/12/12 19:53:42 UTC

[GitHub] csantanapr closed pull request #230: Add rule and action to trigger tests which rely upon activation records

csantanapr closed pull request #230: Add rule and action to trigger tests which rely upon activation records
URL: https://github.com/apache/incubator-openwhisk-package-kafka/pull/230
 
 
   

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/health/BasicHealthTest.scala b/tests/src/test/scala/system/health/BasicHealthTest.scala
index c2fa641..cd66269 100644
--- a/tests/src/test/scala/system/health/BasicHealthTest.scala
+++ b/tests/src/test/scala/system/health/BasicHealthTest.scala
@@ -29,6 +29,7 @@ import org.scalatest.{BeforeAndAfterAll, FlatSpec, Inside, Matchers}
 import org.scalatest.junit.JUnitRunner
 import common.JsHelpers
 import common.TestHelpers
+import common.TestUtils
 import common.TestUtils.DONTCARE_EXIT
 import common.TestUtils.NOT_FOUND
 import common.TestUtils.SUCCESS_EXIT
@@ -143,6 +144,16 @@ class BasicHealthTest
         println(s"Trigger already exists, reusing it: $triggerName")
       }
 
+      val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
+      val defaultActionName = "hello"
+
+      assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+        action.create(name, defaultAction)
+      }
+      assetHelper.withCleaner(wsk.rule, "rule") { (rule, name) =>
+        rule.create(name, trigger = triggerName, action = defaultActionName)
+      }
+
       retry({
         val start = Instant.now(Clock.systemUTC())
         // key to use for the produced message
diff --git a/tests/src/test/scala/system/packages/MessageHubFeedTests.scala b/tests/src/test/scala/system/packages/MessageHubFeedTests.scala
index be1d083..241ad6b 100644
--- a/tests/src/test/scala/system/packages/MessageHubFeedTests.scala
+++ b/tests/src/test/scala/system/packages/MessageHubFeedTests.scala
@@ -30,6 +30,7 @@ import org.scalatest.junit.JUnitRunner
 import spray.json.DefaultJsonProtocol._
 import spray.json._
 import common.JsHelpers
+import common.TestUtils
 import common.TestHelpers
 import common.Wsk
 import common.WskActorSystem
@@ -67,6 +68,9 @@ class MessageHubFeedTests
   val wsk = new Wsk()
   val actionName = s"${messagingPackage}/${messageHubFeed}"
 
+  val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
+  val defaultActionName = "hello"
+
   behavior of "Message Hub feed action"
 
   it should "reject invocation when topic argument is missing" in {
@@ -133,6 +137,13 @@ class MessageHubFeedTests
         "isBinaryKey" -> true.toJson,
         "isBinaryValue" -> true.toJson))
 
+      assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+        action.create(name, defaultAction)
+      }
+      assetHelper.withCleaner(wsk.rule, "rule") { (rule, name) =>
+        rule.create(name, trigger = triggerName, action = defaultActionName)
+      }
+
       // It takes a moment for the consumer to fully initialize.
       println("Giving the consumer a moment to get ready")
       Thread.sleep(consumerInitTime)
@@ -197,6 +208,13 @@ class MessageHubFeedTests
         "isBinaryKey" -> false.toJson,
         "isBinaryValue" -> false.toJson))
 
+      assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+        action.create(name, defaultAction)
+      }
+      assetHelper.withCleaner(wsk.rule, "rule") { (rule, name) =>
+        rule.create(name, trigger = triggerName, action = defaultActionName)
+      }
+
       // It takes a moment for the consumer to fully initialize.
       println("Giving the consumer a moment to get ready")
       Thread.sleep(consumerInitTime)
@@ -247,6 +265,13 @@ class MessageHubFeedTests
         "isBinaryKey" -> false.toJson,
         "isBinaryValue" -> false.toJson))
 
+      assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+        action.create(name, defaultAction)
+      }
+      assetHelper.withCleaner(wsk.rule, "rule") { (rule, name) =>
+        rule.create(name, trigger = triggerName, action = defaultActionName)
+      }
+
       // It takes a moment for the consumer to fully initialize.
       println("Giving the consumer a moment to get ready")
       Thread.sleep(consumerInitTime)
@@ -293,6 +318,17 @@ class MessageHubFeedTests
         "isBinaryKey" -> false.toJson,
         "isBinaryValue" -> false.toJson
       ))
+
+      val run = wsk.action.invoke(actionName, parameters = Map(
+        "triggerName" -> triggerName.toJson,
+        "lifecycleEvent" -> "UPDATE".toJson,
+        "authKey" -> wp.authKey.toJson
+      ))
+
+      withActivation(wsk.activation, run) {
+        activation =>
+          activation.response.success shouldBe false
+      }
   }
 
   it should "reject trigger update when both isJSONData and isBinaryValue are enabled" in withAssetCleaner(wskprops) {
@@ -349,6 +385,13 @@ class MessageHubFeedTests
         "topic" -> topic.toJson
       ))
 
+      assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+        action.create(name, defaultAction)
+      }
+      assetHelper.withCleaner(wsk.rule, "rule") { (rule, name) =>
+        rule.create(name, trigger = triggerName, action = defaultActionName)
+      }
+
       println("Giving the consumer a moment to get ready")
       Thread.sleep(consumerInitTime)
 
diff --git a/tests/src/test/scala/system/packages/MessageHubProduceTests.scala b/tests/src/test/scala/system/packages/MessageHubProduceTests.scala
index fb77547..c193648 100644
--- a/tests/src/test/scala/system/packages/MessageHubProduceTests.scala
+++ b/tests/src/test/scala/system/packages/MessageHubProduceTests.scala
@@ -30,6 +30,7 @@ import org.scalatest.junit.JUnitRunner
 
 import common.JsHelpers
 import common.TestHelpers
+import common.TestUtils
 import common.Wsk
 import common.WskActorSystem
 import common.WskProps
@@ -64,6 +65,9 @@ class MessageHubProduceTests
 
     val kafkaUtils = new KafkaUtils
 
+    val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
+    val defaultActionName = "hello"
+
     // these parameter values are 100% valid and should work as-is
     val validParameters = Map(
         "user" -> kafkaUtils.getAsJson("user"),
@@ -169,6 +173,13 @@ class MessageHubProduceTests
                     activation.response.success shouldBe true
             }
 
+            assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+                action.create(name, defaultAction)
+            }
+            assetHelper.withCleaner(wsk.rule, "rule") { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = defaultActionName)
+            }
+
             // It takes a moment for the consumer to fully initialize.
             println("Giving the consumer a moment to get ready")
             Thread.sleep(consumerInitTime)
@@ -229,6 +240,13 @@ class MessageHubProduceTests
                     activation.response.success shouldBe true
             }
 
+            assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+                action.create(name, defaultAction)
+            }
+            assetHelper.withCleaner(wsk.rule, "rule") { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = defaultActionName)
+            }
+
             // It takes a moment for the consumer to fully initialize.
             println("Giving the consumer a moment to get ready")
             Thread.sleep(consumerInitTime)


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services