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:01 UTC

[GitHub] csantanapr closed pull request #116: add rule to all tests that rely upon activation records

csantanapr closed pull request #116: add rule to all tests that rely upon activation records
URL: https://github.com/apache/incubator-openwhisk-package-alarms/pull/116
 
 
   

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/AlarmsHealthFeedTests.scala b/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala
index da901e8..0e72e69 100644
--- a/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala
+++ b/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala
@@ -18,11 +18,11 @@ package system.health
 
 import java.time.{Clock, Instant}
 
-import common.{TestHelpers, Wsk, WskProps, WskTestHelpers}
+import common._
 import org.junit.runner.RunWith
-import org.scalatest.{FlatSpec, Inside}
 import org.scalatest.junit.JUnitRunner
-import spray.json.DefaultJsonProtocol.{IntJsonFormat, LongJsonFormat, StringJsonFormat, BooleanJsonFormat}
+import org.scalatest.{FlatSpec, Inside}
+import spray.json.DefaultJsonProtocol.{BooleanJsonFormat, IntJsonFormat, LongJsonFormat, StringJsonFormat}
 import spray.json.{JsObject, JsString, pimpAny}
 
 /**
@@ -38,12 +38,17 @@ class AlarmsHealthFeedTests
     val wskprops = WskProps()
     val wsk = new Wsk
 
+
+    val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
+    val defaultActionName = "hello"
+
     behavior of "Alarms Health tests"
 
     it should "bind alarm package and fire periodic trigger using cron feed" in withAssetCleaner(wskprops) {
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
             val triggerName = s"dummyAlarmsTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
             val packageName = "dummyAlarmsPackage"
 
             // the package alarms should be there
@@ -66,6 +71,13 @@ class AlarmsHealthFeedTests
             }
             feedCreationResult.stdout should include("ok")
 
+            assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+                action.create(name, defaultAction)
+            }
+            assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = defaultActionName)
+            }
+
             println("waiting for triggers")
             val activations = wsk.activation.pollFor(N = 5, Some(triggerName), retries = 30).length
             println(s"Found activation size (should be at least 5): $activations")
@@ -82,7 +94,7 @@ class AlarmsHealthFeedTests
             // recreate the trigger now without the feed
             wsk.trigger.create(triggerName)
 
-            // get activation list again, should be same as before sleeping
+            // get activation list again, should be same as before waiting
             println("confirming no new triggers")
             val activationsAfterWait = wsk.activation.pollFor(N = activationsAfterDelete + 1, Some(triggerName)).length
             println(s"Found activation size after wait: $activationsAfterWait")
@@ -94,6 +106,7 @@ class AlarmsHealthFeedTests
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
             val triggerName = s"dummyAlarmsTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
             val packageName = "dummyAlarmsPackage"
 
             // the package alarms should be there
@@ -118,8 +131,15 @@ class AlarmsHealthFeedTests
             }
             feedCreationResult.stdout should include("ok")
 
+            assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+                action.create(name, defaultAction)
+            }
+            assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = defaultActionName)
+            }
+
             println("waiting for trigger")
-            val activations = wsk.activation.pollFor(N = 1, Some(triggerName), retries = 30).length
+            val activations = wsk.activation.pollFor(N = 1, Some(triggerName), retries = 90).length
             println(s"Found activation size (should be 1): $activations")
             activations should be(1)
     }
@@ -191,6 +211,7 @@ class AlarmsHealthFeedTests
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
             val triggerName = s"dummyAlarmsTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
             val packageName = "dummyAlarmsPackage"
 
             // the package alarms should be there
@@ -217,13 +238,20 @@ class AlarmsHealthFeedTests
             }
             feedCreationResult.stdout should include("ok")
 
+            assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+                action.create(name, defaultAction)
+            }
+            assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = defaultActionName)
+            }
+
             println("waiting for triggers")
-            val activations = wsk.activation.pollFor(N = 20, Some(triggerName), retries = 45).length
+            val activations = wsk.activation.pollFor(N = 20, Some(triggerName), retries = 60).length
             println(s"Found activation size (should be at least 5): $activations")
             activations should be >= 5
 
 
-            // get activation list again, should be same as before sleeping
+            // get activation list again, should be same as before waiting
             println("confirming no new triggers")
             val activationsAfterWait = wsk.activation.pollFor(N = activations + 1, Some(triggerName)).length
             println(s"Found activation size after wait: $activationsAfterWait")
@@ -235,6 +263,7 @@ class AlarmsHealthFeedTests
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
             val triggerName = s"dummyAlarmsTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
             val packageName = "dummyAlarmsPackage"
 
             // the package alarms should be there
@@ -261,8 +290,15 @@ class AlarmsHealthFeedTests
             }
             feedCreationResult.stdout should include("ok")
 
+            assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+                action.create(name, defaultAction)
+            }
+            assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = defaultActionName)
+            }
+
             println("waiting for start date")
-            val activations = wsk.activation.pollFor(N = 1, Some(triggerName), retries = 45).length
+            val activations = wsk.activation.pollFor(N = 1, Some(triggerName), retries = 90).length
             println(s"Found activation size (should be 1): $activations")
             activations should be(1)
 
diff --git a/tests/src/test/scala/system/packages/AlarmsFeedTests.scala b/tests/src/test/scala/system/packages/AlarmsFeedTests.scala
index 876b070..aa2e29d 100644
--- a/tests/src/test/scala/system/packages/AlarmsFeedTests.scala
+++ b/tests/src/test/scala/system/packages/AlarmsFeedTests.scala
@@ -19,10 +19,7 @@ package system.packages
 import org.junit.runner.RunWith
 import org.scalatest.FlatSpec
 import org.scalatest.junit.JUnitRunner
-import common.TestHelpers
-import common.Wsk
-import common.WskProps
-import common.WskTestHelpers
+import common._
 import spray.json.DefaultJsonProtocol.IntJsonFormat
 import spray.json.DefaultJsonProtocol.{LongJsonFormat, StringJsonFormat}
 import spray.json.pimpAny
@@ -39,38 +36,49 @@ class AlarmsFeedTests
     val wskprops = WskProps()
     val wsk = new Wsk
 
+    val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
+    val defaultActionName = "hello"
+
     behavior of "Alarms trigger service"
 
     it should "should disable after reaching max triggers" in withAssetCleaner(wskprops) {
         (wp, assetHelper) =>
-        implicit val wskprops = wp // shadow global props and make implicit
-        val triggerName = s"dummyAlarmsTrigger-${System.currentTimeMillis}"
-        val packageName = "dummyAlarmsPackage"
-
-        // the package alarms should be there
-        val packageGetResult = wsk.pkg.get("/whisk.system/alarms")
-        println("fetched package alarms")
-        packageGetResult.stdout should include("ok")
-
-        // create package binding
-        assetHelper.withCleaner(wsk.pkg, packageName) {
-            (pkg, name) => pkg.bind("/whisk.system/alarms", name)
-        }
-
-        // create whisk stuff
-        val feedCreationResult = assetHelper.withCleaner(wsk.trigger, triggerName) {
-            (trigger, name) =>
-            trigger.create(name, feed = Some(s"$packageName/alarm"), parameters = Map(
+            implicit val wskprops = wp // shadow global props and make implicit
+            val triggerName = s"dummyAlarmsTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
+            val packageName = "dummyAlarmsPackage"
+
+            // the package alarms should be there
+            val packageGetResult = wsk.pkg.get("/whisk.system/alarms")
+            println("fetched package alarms")
+            packageGetResult.stdout should include("ok")
+
+            // create package binding
+            assetHelper.withCleaner(wsk.pkg, packageName) {
+                (pkg, name) => pkg.bind("/whisk.system/alarms", name)
+            }
+
+            // create whisk stuff
+            val feedCreationResult = assetHelper.withCleaner(wsk.trigger, triggerName) {
+                (trigger, name) =>
+                trigger.create(name, feed = Some(s"$packageName/alarm"), parameters = Map(
                     "trigger_payload" -> "alarmTest".toJson,
                     "cron" -> "* * * * * *".toJson,
                     "maxTriggers" -> 3.toJson))
-        }
-        feedCreationResult.stdout should include("ok")
+            }
+            feedCreationResult.stdout should include("ok")
+
+            assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+                action.create(name, defaultAction)
+            }
+            assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = defaultActionName)
+            }
 
-        // get activation list of the trigger
-        val activations = wsk.activation.pollFor(N = 4, Some(triggerName)).length
-        println(s"Found activation size: $activations")
-        activations should be(3)
+            // get activation list of the trigger
+            val activations = wsk.activation.pollFor(N = 4, Some(triggerName)).length
+            println(s"Found activation size: $activations")
+            activations should be(3)
     }
 
     it should "return error message when alarm action does not include cron parameter" in withAssetCleaner(wskprops) {
diff --git a/tests/src/test/scala/system/redundancy/AlarmsRedundancyTests.scala b/tests/src/test/scala/system/redundancy/AlarmsRedundancyTests.scala
index 34d207f..aa08880 100644
--- a/tests/src/test/scala/system/redundancy/AlarmsRedundancyTests.scala
+++ b/tests/src/test/scala/system/redundancy/AlarmsRedundancyTests.scala
@@ -18,7 +18,7 @@ package system.redundancy
 
 import com.jayway.restassured.RestAssured
 import com.jayway.restassured.config.SSLConfig
-import common.{WhiskProperties, Wsk, WskProps, WskTestHelpers}
+import common._
 import org.junit.runner.RunWith
 import org.scalatest.junit.JUnitRunner
 import org.scalatest.{BeforeAndAfterAll, FlatSpec, Matchers}
@@ -52,37 +52,48 @@ class AlarmsRedundancyTests
 
     var endpointPrefix = s"https://$user:$password@$edgeHost/alarmstrigger/worker0/"
 
+    val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
+    val defaultActionName = "hello"
+
     behavior of "Alarms redundancy tests"
 
     it should "fire alarms trigger before the swap" in withAssetCleaner(wskprops) {
         (wp, assetHelper) =>
-        implicit val wskprops = wp // shadow global props and make implicit
-        val triggerName = s"dummyAlarmsTrigger-${System.currentTimeMillis}"
-        val packageName = "dummyAlarmsPackage"
-
-        // the package alarms should be there
-        val packageGetResult = wsk.pkg.get("/whisk.system/alarms")
-        println("fetched package alarms")
-        packageGetResult.stdout should include("ok")
-
-        // create package binding
-        assetHelper.withCleaner(wsk.pkg, packageName) {
-            (pkg, name) => pkg.bind("/whisk.system/alarms", name)
-        }
-
-        // create whisk stuff
-        val feedCreationResult = assetHelper.withCleaner(wsk.trigger, triggerName) {
-            (trigger, name) =>
-            trigger.create(name, feed = Some(s"$packageName/alarm"), parameters = Map(
+            implicit val wskprops = wp // shadow global props and make implicit
+            val triggerName = s"dummyAlarmsTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
+            val packageName = "dummyAlarmsPackage"
+
+            // the package alarms should be there
+            val packageGetResult = wsk.pkg.get("/whisk.system/alarms")
+            println("fetched package alarms")
+            packageGetResult.stdout should include("ok")
+
+            // create package binding
+            assetHelper.withCleaner(wsk.pkg, packageName) {
+                (pkg, name) => pkg.bind("/whisk.system/alarms", name)
+            }
+
+            // create whisk stuff
+            val feedCreationResult = assetHelper.withCleaner(wsk.trigger, triggerName) {
+                (trigger, name) =>
+                trigger.create(name, feed = Some(s"$packageName/alarm"), parameters = Map(
                     "trigger_payload" -> "alarmTest".toJson,
                     "cron" -> "* * * * * *".toJson))
-        }
-        feedCreationResult.stdout should include("ok")
+            }
+            feedCreationResult.stdout should include("ok")
+
+            assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+                action.create(name, defaultAction)
+            }
+            assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = defaultActionName)
+            }
 
-        println("waiting for triggers")
-        val activations = wsk.activation.pollFor(N = 3, Some(triggerName)).length
-        println(s"Found activation size (should be at least 3): $activations")
-        activations should be >= 3
+            println("waiting for triggers")
+            val activations = wsk.activation.pollFor(N = 3, Some(triggerName)).length
+            println(s"Found activation size (should be at least 3): $activations")
+            activations should be >= 3
     }
 
 
@@ -111,7 +122,8 @@ class AlarmsRedundancyTests
     it should "fire alarms trigger again after the swap" in withAssetCleaner(wskprops) {
         (wp, assetHelper) =>
             implicit val wskprops = wp // shadow global props and make implicit
-        val triggerName = s"dummyAlarmsTrigger-${System.currentTimeMillis}"
+            val triggerName = s"dummyAlarmsTrigger-${System.currentTimeMillis}"
+            val ruleName = s"dummyAlarmsRule-${System.currentTimeMillis}"
             val packageName = "dummyAlarmsPackage"
 
             // the package alarms should be there
@@ -133,6 +145,13 @@ class AlarmsRedundancyTests
             }
             feedCreationResult.stdout should include("ok")
 
+            assetHelper.withCleaner(wsk.action, defaultActionName) { (action, name) =>
+                action.create(name, defaultAction)
+            }
+            assetHelper.withCleaner(wsk.rule, ruleName) { (rule, name) =>
+                rule.create(name, trigger = triggerName, action = defaultActionName)
+            }
+
             println("waiting for triggers")
             val activations = wsk.activation.pollFor(N = 3, Some(triggerName)).length
             println(s"Found activation size (should be at least 3): $activations")


 

----------------------------------------------------------------
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