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 2018/03/02 22:14:18 UTC

[GitHub] markusthoemmes closed pull request #3364: Add retries to some entity "update" tests

markusthoemmes closed pull request #3364: Add retries to some entity "update" tests
URL: https://github.com/apache/incubator-openwhisk/pull/3364
 
 
   

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/basic/WskBasicTests.scala b/tests/src/test/scala/system/basic/WskBasicTests.scala
index 1fd93fd79b..9d9b0d6aef 100644
--- a/tests/src/test/scala/system/basic/WskBasicTests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicTests.scala
@@ -53,6 +53,11 @@ class WskBasicTests extends TestHelpers with WskTestHelpers {
    */
   def withTimestamp(text: String) = s"${text}-${System.currentTimeMillis}"
 
+  /**
+   * Retry operations that need to settle the controller cache
+   */
+  def cacheRetry[T](fn: => T) = whisk.utils.retry(fn, 5, Some(1.second))
+
   behavior of "Wsk REST"
 
   it should "reject creating duplicate entity" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
@@ -88,9 +93,14 @@ class WskBasicTests extends TestHelpers with WskTestHelpers {
       pkg.create(name, parameters = params, shared = Some(true))
       pkg.create(name, update = true)
     }
-    val pack = wsk.pkg.get(name)
+
+    // Add retry to ensure cache with "0.0.1" is replaced
+    val pack = cacheRetry({
+      val p = wsk.pkg.get(name)
+      p.getField("version") shouldBe "0.0.2"
+      p
+    })
     pack.getFieldJsValue("publish") shouldBe JsBoolean(true)
-    pack.getField("version") shouldBe "0.0.2"
     pack.getFieldJsValue("parameters") shouldBe JsArray(JsObject("key" -> JsString("a"), "value" -> JsString("A")))
     val packageList = wsk.pkg.list()
     val packages = packageList.getBodyListJsObject()
@@ -220,10 +230,14 @@ class WskBasicTests extends TestHelpers with WskTestHelpers {
       action.create(name, None, parameters = Map("b" -> "B".toJson), update = true)
     }
 
-    val action = wsk.action.get(name)
+    // Add retry to ensure cache with "0.0.1" is replaced
+    val action = cacheRetry({
+      val a = wsk.action.get(name)
+      a.getField("version") shouldBe "0.0.2"
+      a
+    })
     action.getFieldJsValue("parameters") shouldBe JsArray(JsObject("key" -> JsString("b"), "value" -> JsString("B")))
     action.getFieldJsValue("publish") shouldBe JsBoolean(false)
-    action.getField("version") shouldBe "0.0.2"
     val actionList = wsk.action.list()
     val actions = actionList.getBodyListJsObject()
     actions.exists(action => RestResult.getField(action, "name") == name) shouldBe true
@@ -509,10 +523,14 @@ class WskBasicTests extends TestHelpers with WskTestHelpers {
       rule.create(name, trigger = triggerName, action = actionName)
     }
 
-    val trigger = wsk.trigger.get(triggerName)
+    // Add retry to ensure cache with "0.0.1" is replaced
+    val trigger = cacheRetry({
+      val t = wsk.trigger.get(triggerName)
+      t.getField("version") shouldBe "0.0.2"
+      t
+    })
     trigger.getFieldJsValue("parameters") shouldBe JsArray(JsObject("key" -> JsString("a"), "value" -> JsString("A")))
     trigger.getFieldJsValue("publish") shouldBe JsBoolean(false)
-    trigger.getField("version") shouldBe "0.0.2"
 
     val expectedRules = JsObject(
       ns + "/" + ruleName -> JsObject(
@@ -836,8 +854,12 @@ class WskBasicTests extends TestHelpers with WskTestHelpers {
     // finally, we perform the update, and expect success this time
     wsk.rule.create(ruleName, trigger = triggerName, action = actionName, update = true)
 
-    val rule = wsk.rule.get(ruleName)
-    rule.getField("version") shouldBe "0.0.2"
+    // Add retry to ensure cache with "0.0.1" is replaced
+    val rule = cacheRetry({
+      val r = wsk.rule.get(ruleName)
+      r.getField("version") shouldBe "0.0.2"
+      r
+    })
     rule.getField("name") shouldBe ruleName
     RestResult.getField(rule.getFieldJsObject("trigger"), "name") shouldBe triggerName
     RestResult.getField(rule.getFieldJsObject("action"), "name") shouldBe actionName


 

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