cbickel closed pull request #2762: Enable v2 views
URL: https://github.com/apache/incubator-openwhisk/pull/2762
 
 
   

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/ansible/group_vars/all b/ansible/group_vars/all
index c6ad149c4c..4bb74edfcb 100644
--- a/ansible/group_vars/all
+++ b/ansible/group_vars/all
@@ -200,10 +200,10 @@ db:
   - whisk.system
   whisk:
     actions: "{{ db_prefix }}whisks"
-    actions_ddoc: "whisks"
+    actions_ddoc: "whisks.v2"
     activations: "{{ db_prefix }}activations"
-    activations_ddoc: "whisks"
-    activations_filter_ddoc: "whisks"
+    activations_ddoc: "whisks.v2"
+    activations_filter_ddoc: "whisks-filters.v2"
     auth: "{{ db_prefix }}subjects"
 
 apigateway:
diff --git a/ansible/logs.yml b/ansible/logs.yml
index 43dc52decc..3dc1b1e68c 100644
--- a/ansible/logs.yml
+++ b/ansible/logs.yml
@@ -10,7 +10,7 @@
     - name: create "logs" folder
       file: path="{{ openwhisk_home }}/logs" state=directory
     - name: dump entity views
-      local_action: shell "{{ openwhisk_home }}/bin/wskadmin" db get whisks 
--docs --view whisks/{{ item }} | tail -n +2 > "{{ openwhisk_home }}/logs/db-{{ 
item }}.log"
+      local_action: shell "{{ openwhisk_home }}/bin/wskadmin" db get whisks 
--docs --view whisks.v2/{{ item }} | tail -n +2 > "{{ openwhisk_home 
}}/logs/db-{{ item }}.log"
       with_items:
         - actions
         - triggers
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 4073093781..596a5ecbc0 100644
--- a/common/scala/src/main/scala/whisk/core/entity/WhiskActivation.scala
+++ b/common/scala/src/main/scala/whisk/core/entity/WhiskActivation.scala
@@ -145,8 +145,8 @@ object WhiskActivation
   // which are readily available here; rather than introduce significant 
refactoring,
   // defer this fix until WhiskConfig is refactored itself, which is planned 
to introduce
   // type safe properties
-  private val mainDdoc = 
WhiskConfig.readFromEnv(dbActivationsDesignDoc).getOrElse("whisks")
-  private val filtersDdoc = 
WhiskConfig.readFromEnv(dbActivationsFilterDesignDoc).getOrElse("whisks")
+  private val mainDdoc = 
WhiskConfig.readFromEnv(dbActivationsDesignDoc).getOrElse("whisks.v2")
+  private val filtersDdoc = 
WhiskConfig.readFromEnv(dbActivationsFilterDesignDoc).getOrElse("whisks-filters.v2")
 
   /** The main view for activations, keyed by namespace, sorted by date. */
   override lazy val view = WhiskEntityQueries.view(mainDdoc, collectionName)
diff --git a/common/scala/src/main/scala/whisk/core/entity/WhiskStore.scala 
b/common/scala/src/main/scala/whisk/core/entity/WhiskStore.scala
index b114450b2d..3bd6367bc3 100644
--- a/common/scala/src/main/scala/whisk/core/entity/WhiskStore.scala
+++ b/common/scala/src/main/scala/whisk/core/entity/WhiskStore.scala
@@ -40,7 +40,7 @@ import whisk.core.WhiskConfig.dbProvider
 import whisk.core.WhiskConfig.dbUsername
 import whisk.core.WhiskConfig.dbWhisk
 import whisk.core.WhiskConfig.dbWhiskDesignDoc
-import whisk.core.WhiskConfig.dbActivationsDesignDoc
+import whisk.core.WhiskConfig.{dbActivationsDesignDoc, 
dbActivationsFilterDesignDoc}
 import whisk.core.database.ArtifactStore
 import whisk.core.database.ArtifactStoreProvider
 import whisk.core.database.DocumentRevisionProvider
@@ -139,7 +139,8 @@ object WhiskActivationStore {
       dbHost -> null,
       dbPort -> null,
       dbActivations -> null,
-      dbActivationsDesignDoc -> null)
+      dbActivationsDesignDoc -> null,
+      dbActivationsFilterDesignDoc -> null)
 
   def datastore(config: WhiskConfig)(implicit system: ActorSystem, logging: 
Logging, materializer: ActorMaterializer) =
     SpiLoader.get[ArtifactStoreProvider].makeStore[WhiskActivation](config, 
_.dbActivations, true)
@@ -198,7 +199,7 @@ object WhiskEntityQueries {
   // which are readily available here; rather than introduce significant 
refactoring,
   // defer this fix until WhiskConfig is refactored itself, which is planned 
to introduce
   // type safe properties
-  val designDoc = WhiskConfig.readFromEnv(dbWhiskDesignDoc).getOrElse("whisks")
+  val designDoc = 
WhiskConfig.readFromEnv(dbWhiskDesignDoc).getOrElse("whisks.v2")
 
   /** The view name for the collection, within the design document. */
   def view(ddoc: String = designDoc, collection: String) = new View(ddoc, 
collection)
diff --git 
a/core/controller/src/main/scala/whisk/core/controller/Activations.scala 
b/core/controller/src/main/scala/whisk/core/controller/Activations.scala
index 0403d1c03f..06e7efe669 100644
--- a/core/controller/src/main/scala/whisk/core/controller/Activations.scala
+++ b/core/controller/src/main/scala/whisk/core/controller/Activations.scala
@@ -157,7 +157,7 @@ trait WhiskActivationsApi extends Directives with 
AuthenticatedRouteProvider wit
             WhiskActivation.listActivationsMatchingName(
               activationStore,
               namespace,
-              action.last.toPath,
+              action,
               skip,
               cappedLimit,
               docs,
diff --git a/tests/src/test/scala/common/rest/WskRest.scala 
b/tests/src/test/scala/common/rest/WskRest.scala
index 0ae28f93a5..d5feb3333e 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRest.scala
@@ -619,11 +619,18 @@ class WskRestActivation extends RunWskRestCmd with 
HasActivationRest with WaitFo
    */
   override def console(duration: Duration, since: Option[Duration] = None, 
expectedExitCode: Int = SUCCESS_EXIT)(
     implicit wp: WskProps): RestResult = {
-    var sinceTime = System.currentTimeMillis()
-    sinceTime = since map { s =>
-      sinceTime - s.toMillis
-    } getOrElse sinceTime
-    waitForActivationConsole(duration, Instant.ofEpochMilli(sinceTime))
+    require(duration > 1.second, "duration must be at least 1 second")
+    val sinceTime = {
+      val now = System.currentTimeMillis()
+      since map { s =>
+        now - s.toMillis
+      } getOrElse now
+    }
+
+    retry({
+      val result = listActivation(since = 
Some(Instant.ofEpochMilli(sinceTime)))(wp)
+      if (result.stdout != "[]") result else throw new Throwable()
+    }, (duration / 1.second).toInt, Some(1.second))
   }
 
   /**
@@ -776,12 +783,6 @@ class WskRestActivation extends RunWskRestCmd with 
HasActivationRest with WaitFo
 
   }
 
-  def waitForActivationConsole(totalWait: Duration = 30 seconds, sinceTime: 
Instant)(
-    implicit wp: WskProps): RestResult = {
-    Thread.sleep(totalWait.toMillis)
-    listActivation(since = Some(sinceTime))(wp)
-  }
-
   override def logs(activationId: Option[String] = None,
                     expectedExitCode: Int = OK.intValue,
                     last: Option[Boolean] = None)(implicit wp: WskProps): 
RestResult = {
diff --git a/tests/src/test/scala/system/basic/WskConsoleTests.scala 
b/tests/src/test/scala/system/basic/WskConsoleTests.scala
index 064de72b14..9df9bcb4c0 100644
--- a/tests/src/test/scala/system/basic/WskConsoleTests.scala
+++ b/tests/src/test/scala/system/basic/WskConsoleTests.scala
@@ -74,9 +74,10 @@ abstract class WskConsoleTests extends TestHelpers with 
WskTestHelpers {
       // Time recorded by invoker, some contingency to make query more robust
       val queryTime = activation.start.minusMillis(500)
       // since: poll for activations since specified point in time (absolute)
-      val activations = wsk.activation.pollFor(N = 1, Some(actionName), since 
= Some(queryTime), retries = 80).length
+      val activations =
+        wsk.activation.pollFor(N = 1, Some(s"$packageName/$actionName"), since 
= Some(queryTime), retries = 80).length
       withClue(
-        s"expected activations of action '${actionName}' since 
${queryTime.toString} / initial activation ${activation.activationId}:") {
+        s"expected activations of action '$fullActionName' since $queryTime, 
initial activation ${activation.activationId}:") {
         activations should be(1)
       }
 
@@ -84,8 +85,7 @@ abstract class WskConsoleTests extends TestHelpers with 
WskTestHelpers {
       val pollTime = 10 seconds
       // since: poll for activations since specified number of seconds ago 
(relative)
       val console = wsk.activation.console(pollTime, since = Some(duration))
-      withClue(
-        s"Poll for ${pollTime.toSeconds} seconds since ${duration.toSeconds} 
seconds did not return expected result:") {
+      withClue(s"Polled since ${duration.toSeconds} seconds, did not find 
expected result:") {
         console.stdout should include(payload)
       }
     }
@@ -108,15 +108,14 @@ abstract class WskConsoleTests extends TestHelpers with 
WskTestHelpers {
       // since: poll for activations since specified point in time (absolute)
       val activations = wsk.activation.pollFor(N = 4, Some(name), since = 
Some(queryTime), retries = 80).length
       withClue(
-        s"expected activations of action '${name}' since ${queryTime.toString} 
/ initial activation ${activation.activationId}:") {
+        s"expected activations of action '$name' since $queryTime, initial 
activation ${activation.activationId}:") {
         activations should be(count + 1)
       }
       val duration = 
Duration(Instant.now.minusMillis(start.toEpochMilli).toEpochMilli, MILLISECONDS)
       val pollTime = 10 seconds
       // since: poll for activations since specified number of seconds ago 
(relative)
       val console = wsk.activation.console(pollTime, since = Some(duration))
-      withClue(
-        s"Poll for ${pollTime.toSeconds} seconds since ${duration.toSeconds} 
seconds did not return expected result:") {
+      withClue(s"Polled for ${duration.toSeconds} seconds, did not find 
expected result:") {
         console.stdout should include("Happy New Year")
       }
     }
diff --git a/tests/src/test/scala/system/basic/WskRuleTests.scala 
b/tests/src/test/scala/system/basic/WskRuleTests.scala
index e110c284a7..2baac6d850 100644
--- a/tests/src/test/scala/system/basic/WskRuleTests.scala
+++ b/tests/src/test/scala/system/basic/WskRuleTests.scala
@@ -147,7 +147,7 @@ abstract class WskRuleTests extends TestHelpers with 
WskTestHelpers {
 
       withActivationsFromEntity(
         wsk.activation,
-        actionName,
+        pkgActionName,
         since = 
Some(triggerActivation.start.minusMillis(activationTimeSkewFactorMs))) {
         _.head.response.result shouldBe Some(testResult)
       }
@@ -187,7 +187,7 @@ abstract class WskRuleTests extends TestHelpers with 
WskTestHelpers {
 
       withActivationsFromEntity(
         wsk.activation,
-        actionName,
+        pkgActionName,
         since = 
Some(triggerActivation.start.minusMillis(activationTimeSkewFactorMs))) {
         _.head.response.result shouldBe Some(testResult)
       }
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 53418366f6..e4a02ff770 100644
--- a/tests/src/test/scala/whisk/core/controller/test/ActivationsApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/ActivationsApiTests.scala
@@ -325,25 +325,22 @@ class ActivationsApiTests extends ControllerTestCommon 
with WhiskActivationsApi
       Get(s"$collectionPath?name=xyz") ~> Route.seal(routes(creds)) ~> check {
         status should be(OK)
         val response = responseAs[List[JsObject]]
-        val allActivations = activations ++ activationsInPackage
-        allActivations.length should be(response.length)
-        allActivations forall { a =>
+        activations.length should be(response.length)
+        activations forall { a =>
           response contains a.summaryAsJson
         } should be(true)
       }
     }
 
     // this is not yet ready, the v2 views must be activated
-    if (false) {
-      whisk.utils.retry {
-        Get(s"$collectionPath?name=pkg/xyz") ~> Route.seal(routes(creds)) ~> 
check {
-          status should be(OK)
-          val response = responseAs[List[JsObject]]
-          activationsInPackage.length should be(response.length)
-          activationsInPackage forall { a =>
-            response contains a.summaryAsJson
-          } should be(true)
-        }
+    whisk.utils.retry {
+      Get(s"$collectionPath?name=pkg/xyz") ~> Route.seal(routes(creds)) ~> 
check {
+        status should be(OK)
+        val response = responseAs[List[JsObject]]
+        activationsInPackage.length should be(response.length)
+        activationsInPackage forall { a =>
+          response contains a.summaryAsJson
+        } should be(true)
       }
     }
   }


 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to