You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ma...@apache.org on 2017/08/17 13:40:59 UTC

[incubator-openwhisk] branch master updated: Add retry to rate-throttle tests. (#2616)

This is an automated email from the ASF dual-hosted git repository.

markusthoemmes 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 20f400e  Add retry to rate-throttle tests. (#2616)
20f400e is described below

commit 20f400ea4155135533547b4dc5c294c758968720
Author: Christian Bickel <gi...@cbickel.de>
AuthorDate: Thu Aug 17 15:40:57 2017 +0200

    Add retry to rate-throttle tests. (#2616)
---
 tests/src/test/scala/limits/ThrottleTests.scala | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/tests/src/test/scala/limits/ThrottleTests.scala b/tests/src/test/scala/limits/ThrottleTests.scala
index 88d3e13..0049f8b 100644
--- a/tests/src/test/scala/limits/ThrottleTests.scala
+++ b/tests/src/test/scala/limits/ThrottleTests.scala
@@ -45,6 +45,7 @@ import whisk.http.Messages._
 import whisk.utils.ExecutionContextFactory
 import org.scalatest.BeforeAndAfterAll
 import common.RunWskAdminCmd
+import whisk.utils.retry
 
 @RunWith(classOf[JUnitRunner])
 class ThrottleTests
@@ -349,12 +350,24 @@ class NamespaceSpecificThrottleTests
             }
 
             // One invoke should be allowed, the second one throttled
-            wsk.action.invoke(actionName)
-            wsk.action.invoke(actionName, expectedExitCode = TestUtils.THROTTLED).stderr should include(tooManyRequests)
+            // Due to the current implementation of the rate throttling, it could be possible, that the counter gets deleted, because the minute switches
+            retry({
+                val results = (1 to 2).map { _ =>
+                    wsk.action.invoke(actionName, expectedExitCode = TestUtils.DONTCARE_EXIT)
+                }
+                results.map(_.exitCode) should contain(TestUtils.THROTTLED)
+                results.map(_.stderr).mkString should include(tooManyRequests)
+            }, 2, Some(1.second))
 
             // One fire should be allowed, the second one throttled
-            wsk.trigger.fire(triggerName)
-            wsk.trigger.fire(triggerName, expectedExitCode = TestUtils.THROTTLED).stderr should include(tooManyRequests)
+            // Due to the current implementation of the rate throttling, it could be possible, that the counter gets deleted, because the minute switches
+            retry({
+                val results = (1 to 2).map { _ =>
+                    wsk.trigger.fire(triggerName, expectedExitCode = TestUtils.DONTCARE_EXIT)
+                }
+                results.map(_.exitCode) should contain(TestUtils.THROTTLED)
+                results.map(_.stderr).mkString should include(tooManyRequests)
+            }, 2, Some(1.second))
     }
 
     it should "respect overridden concurrent throttle of 0" in withAssetCleaner(zeroConcProps) {

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