You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cb...@apache.org on 2018/04/24 15:06:16 UTC

[incubator-openwhisk] branch master updated: Bump retries for view based tests. (#3571)

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

cbickel 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 61d64f8  Bump retries for view based tests. (#3571)
61d64f8 is described below

commit 61d64f8a147b89d481b1880f494d875b828aca05
Author: Markus Thömmes <ma...@me.com>
AuthorDate: Tue Apr 24 17:06:10 2018 +0200

    Bump retries for view based tests. (#3571)
    
    The view based retry logic is a bit deep and overloaded. To bump the retries and make all those tests more stable this bumps the general retry count for all those tests.
    
    Also tightens the blacklist test by retrying the view based lookup as well.
---
 tests/src/test/scala/whisk/core/database/test/DbUtils.scala         | 6 +++++-
 .../scala/whisk/core/invoker/test/NamespaceBlacklistTests.scala     | 5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/src/test/scala/whisk/core/database/test/DbUtils.scala b/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
index 277e131..7cf9074 100644
--- a/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
+++ b/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
@@ -57,7 +57,8 @@ trait DbUtils extends TransactionCounter {
    * Attempt the operation up to 'count' times. The future from the
    * step is not aborted --- TODO fix this.
    */
-  def retry[T](step: () => Future[T], timeout: Duration, count: Int = 5): Try[T] = {
+  def retry[T](step: () => Future[T], timeout: Duration, count: Int = 100): Try[T] = {
+    val graceBeforeRetry = 50.milliseconds
     val future = step()
     if (count > 0) try {
       val result = Await.result(future, timeout)
@@ -65,12 +66,15 @@ trait DbUtils extends TransactionCounter {
     } catch {
       case n: NoDocumentException =>
         println("no document exception, retrying")
+        Thread.sleep(graceBeforeRetry.toMillis)
         retry(step, timeout, count - 1)
       case RetryOp() =>
         println("condition not met, retrying")
+        Thread.sleep(graceBeforeRetry.toMillis)
         retry(step, timeout, count - 1)
       case t: TimeoutException =>
         println("timed out, retrying")
+        Thread.sleep(graceBeforeRetry.toMillis)
         retry(step, timeout, count - 1)
       case t: Throwable =>
         println(s"unexpected failure $t")
diff --git a/tests/src/test/scala/whisk/core/invoker/test/NamespaceBlacklistTests.scala b/tests/src/test/scala/whisk/core/invoker/test/NamespaceBlacklistTests.scala
index 914e307..e3bfd85 100644
--- a/tests/src/test/scala/whisk/core/invoker/test/NamespaceBlacklistTests.scala
+++ b/tests/src/test/scala/whisk/core/invoker/test/NamespaceBlacklistTests.scala
@@ -32,6 +32,7 @@ import whisk.core.ConfigKeys
 import whisk.core.database.test.{DbUtils, ExtendedCouchDbRestClient}
 import whisk.core.entity._
 import whisk.core.invoker.NamespaceBlacklist
+import whisk.utils.{retry => testRetry}
 
 import scala.concurrent.duration._
 
@@ -128,7 +129,9 @@ class NamespaceBlacklistTests
   it should "mark a namespace as blocked if limit is 0 in database or if one of its subjects is blocked" in {
     val blacklist = new NamespaceBlacklist(authStore)
 
-    blacklist.refreshBlacklist().futureValue should have size blockedNamespacesCount
+    testRetry({
+      blacklist.refreshBlacklist().futureValue should have size blockedNamespacesCount
+    }, 60, Some(1.second))
 
     identities.map(blacklist.isBlacklisted) shouldBe Seq(true, true, false)
     authToIdentities(subject).toSeq.map(blacklist.isBlacklisted) shouldBe Seq(true, true)

-- 
To stop receiving notification emails like this one, please contact
cbickel@apache.org.