openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csantan...@apache.org
Subject [incubator-openwhisk-package-alarms] branch master updated: update logging level when maxTriggers reached (#91)
Date Thu, 07 Sep 2017 17:52:56 GMT
This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-alarms.git


The following commit(s) were added to refs/heads/master by this push:
     new 15b7345  update logging level when maxTriggers reached (#91)
15b7345 is described below

commit 15b7345fe1e7200f482cca3f6dcd9e3d7c64c625
Author: Jason Peterson <jasonpet@us.ibm.com>
AuthorDate: Thu Sep 7 13:52:54 2017 -0400

    update logging level when maxTriggers reached (#91)
---
 provider/lib/utils.js                              |   2 +-
 .../system/health/AlarmsHealthFeedTests.scala      | 188 +++++++++++----------
 2 files changed, 98 insertions(+), 92 deletions(-)

diff --git a/provider/lib/utils.js b/provider/lib/utils.js
index 0949ddc..83f57d0 100644
--- a/provider/lib/utils.js
+++ b/provider/lib/utils.js
@@ -85,7 +85,7 @@ module.exports = function(
             logger.info(method, 'Trigger', triggerId, 'was successfully fired');
             if (dataTrigger.triggersLeft === 0) {
                 utils.disableTrigger(triggerIdentifier, undefined, 'Automatically disabled
after reaching max triggers');
-                logger.error(method, 'no more triggers left, disabled', triggerIdentifier);
+                logger.warn(method, 'no more triggers left, disabled', triggerIdentifier);
             }
         })
         .catch(err => {
diff --git a/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala b/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala
index 1ea7ab8..7072289 100644
--- a/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala
+++ b/tests/src/test/scala/system/health/AlarmsHealthFeedTests.scala
@@ -16,6 +16,8 @@
  */
 package system.health
 
+import java.time.{Clock, Instant}
+
 import common.{TestHelpers, Wsk, WskProps, WskTestHelpers}
 import org.junit.runner.RunWith
 import org.scalatest.FlatSpec
@@ -39,104 +41,108 @@ class AlarmsHealthFeedTests
 
     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 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")
-
-        println("waiting for triggers")
-        val activations = wsk.activation.pollFor(N = 5, Some(triggerName), retries = 20).length
-        println(s"Found activation size (should be at least 5): $activations")
-        activations should be >= 5
-
-        // delete the whisk trigger, which must also delete the feed
-        wsk.trigger.delete(triggerName)
-        Thread.sleep(5000)
-        // get activation list after delete of the trigger
-        val activationsAfterDelete = wsk.activation.ids(wsk.activation.list(filter = Some(triggerName))).length
-        println(s"Found activation size after delete: $activationsAfterDelete")
-
-        // recreate the trigger now without the feed
-        wsk.trigger.create(triggerName)
-
-        // get activation list again, should be same as before sleeping
-        println("confirming no new triggers")
-        val activationsAfterWait = wsk.activation.pollFor(N = activationsAfterDelete + 1,
Some(triggerName)).length
-        println(s"Found activation size after wait: $activationsAfterWait")
-        println("Activation list after wait should equal with activation list after delete")
-        activationsAfterWait should be(activationsAfterDelete)
+            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)
+            }
+
+            println(s"Creating trigger: $triggerName")
+            // 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")
+
+            println("waiting for triggers")
+            val activations = wsk.activation.pollFor(N = 5, Some(triggerName)).length
+            println(s"Found activation size (should be at least 5): $activations")
+            activations should be >= 5
+
+            // delete the whisk trigger, which must also delete the feed
+            wsk.trigger.delete(triggerName)
+
+            // get activation list after delete of the trigger
+            val activationsAfterDelete = wsk.activation.pollFor(N = 20, Some(triggerName),
retries = 20).length
+            val now = Instant.now(Clock.systemUTC())
+            println(s"Found activation size after delete ($now): $activationsAfterDelete")
+
+            // recreate the trigger now without the feed
+            wsk.trigger.create(triggerName)
+
+            // get activation list again, should be same as before sleeping
+            println("confirming no new triggers")
+            val activationsAfterWait = wsk.activation.pollFor(N = activationsAfterDelete
+ 1, Some(triggerName)).length
+            println(s"Found activation size after wait: $activationsAfterWait")
+            println("Activation list after wait should equal with activation list after delete")
+            activationsAfterWait should be(activationsAfterDelete)
     }
 
     it should "should not fail when specifying triggers above 1 Million" 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(
-                    "trigger_payload" -> "alarmTest".toJson,
-                    "cron" -> "* * * * * *".toJson,
-                    "maxTriggers" -> 100000000.toJson))
-        }
-        feedCreationResult.stdout should include("ok")
+            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
+            println(s"Creating trigger: $triggerName")
+            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" -> 100000000.toJson))
+            }
+            feedCreationResult.stdout should include("ok")
     }
 
     it should "should not deny trigger creation when choosing maxTriggers set to infinity
(-1)" 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, confirmDelete
= true) {
-            (trigger, name) =>
-            trigger.create(name, feed = Some(s"$packageName/alarm"), parameters = Map(
-                    "trigger_payload" -> "alarmTest".toJson,
-                    "cron" -> "* * * * * *".toJson,
-                    "maxTriggers" -> -1.toJson),
-            expectedExitCode = 0)
-        }
-        feedCreationResult.stderr should not include("error")
+            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
+            println(s"Creating trigger: $triggerName")
+            val feedCreationResult = assetHelper.withCleaner(wsk.trigger, triggerName, confirmDelete
= true) {
+                (trigger, name) =>
+                    trigger.create(name, feed = Some(s"$packageName/alarm"), parameters =
Map(
+                        "trigger_payload" -> "alarmTest".toJson,
+                        "cron" -> "* * * * * *".toJson,
+                        "maxTriggers" -> -1.toJson),
+                expectedExitCode = 0)
+            }
+            feedCreationResult.stderr should not include("error")
     }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].

Mime
View raw message