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/01/11 01:38:32 UTC

[GitHub] dubeejw closed pull request #3175: Fix heisenbug by using the correct view.

dubeejw closed pull request #3175: Fix heisenbug by using the correct view.
URL: https://github.com/apache/incubator-openwhisk/pull/3175
 
 
   

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/common/scala/src/main/scala/whisk/core/entity/WhiskActivation.scala b/common/scala/src/main/scala/whisk/core/entity/WhiskActivation.scala
index cde75070a4..0525f501a1 100644
--- a/common/scala/src/main/scala/whisk/core/entity/WhiskActivation.scala
+++ b/common/scala/src/main/scala/whisk/core/entity/WhiskActivation.scala
@@ -159,7 +159,7 @@ object WhiskActivation
    * A view for activations in a namespace additionally keyed by action name
    * (and package name if present) sorted by date.
    */
-  private val filtersView = WhiskEntityQueries.view(filtersDdoc, collectionName)
+  val filtersView = WhiskEntityQueries.view(filtersDdoc, collectionName)
 
   override implicit val serdes = jsonFormat13(WhiskActivation.apply)
 
diff --git a/tests/src/test/scala/whisk/core/controller/test/ActivationsApiTests.scala b/tests/src/test/scala/whisk/core/controller/test/ActivationsApiTests.scala
index c36a7c1de7..edda225577 100644
--- a/tests/src/test/scala/whisk/core/controller/test/ActivationsApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/ActivationsApiTests.scala
@@ -338,7 +338,12 @@ class ActivationsApiTests extends ControllerTestCommon with WhiskActivationsApi
     }.toList
     activationsInPackage foreach { put(activationStore, _) }
 
-    waitOnView(activationStore, namespace.root, 4, WhiskActivation.view)
+    waitOnView(activationStore, namespace.addPath(EntityName("xyz")), activations.length, WhiskActivation.filtersView)
+    waitOnView(
+      activationStore,
+      namespace.addPath(EntityName("pkg")).addPath(EntityName("xyz")),
+      activationsInPackage.length,
+      WhiskActivation.filtersView)
 
     whisk.utils.retry {
       Get(s"$collectionPath?name=xyz") ~> Route.seal(routes(creds)) ~> check {
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 6c87faf927..62c705b63d 100644
--- a/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
+++ b/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
@@ -86,11 +86,31 @@ trait DbUtils extends TransactionCounter {
   def waitOnView[Au](db: ArtifactStore[Au], namespace: EntityName, count: Int, view: View)(
     implicit context: ExecutionContext,
     transid: TransactionId,
-    timeout: Duration) = {
+    timeout: Duration): Unit = waitOnViewImpl(db, namespace.asString, count, view)
+
+  /**
+   * Wait on a view to update with documents added to namespace. This uses retry above,
+   * where the step performs a direct db query to retrieve the view and check the count
+   * matches the given value.
+   */
+  def waitOnView[Au](db: ArtifactStore[Au], path: EntityPath, count: Int, view: View)(
+    implicit context: ExecutionContext,
+    transid: TransactionId,
+    timeout: Duration): Unit = waitOnViewImpl(db, path.asString, count, view)
+
+  /**
+   * Wait on a view to update with documents added to namespace. This uses retry above,
+   * where the step performs a direct db query to retrieve the view and check the count
+   * matches the given value.
+   */
+  private def waitOnViewImpl[Au](db: ArtifactStore[Au], key: String, count: Int, view: View)(
+    implicit context: ExecutionContext,
+    transid: TransactionId,
+    timeout: Duration): Unit = {
     val success = retry(
       () => {
-        val startKey = List(namespace.asString)
-        val endKey = List(namespace.asString, WhiskEntityQueries.TOP)
+        val startKey = List(key)
+        val endKey = List(key, WhiskEntityQueries.TOP)
         db.query(view.name, startKey, endKey, 0, 0, false, true, false, StaleParameter.No) map { l =>
           if (l.length != count) {
             throw RetryOp()


 

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