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 2017/11/17 07:34:59 UTC

[incubator-openwhisk] branch master updated: Enable v2 views. (#2762)

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 e7830fd  Enable v2 views. (#2762)
e7830fd is described below

commit e7830fdb2aed831914c3ca892819b70b4ef14c6e
Author: rodric rabbah <ro...@gmail.com>
AuthorDate: Fri Nov 17 02:34:57 2017 -0500

    Enable v2 views. (#2762)
    
    * Enable v2 views.
    
    * Adjust console test in REST client eventhough this test makes no sense to me here.
---
 ansible/group_vars/all                             |  6 +++---
 ansible/logs.yml                                   |  2 +-
 .../scala/whisk/core/entity/WhiskActivation.scala  |  4 ++--
 .../main/scala/whisk/core/entity/WhiskStore.scala  |  7 ++++---
 .../scala/whisk/core/controller/Activations.scala  |  2 +-
 tests/src/test/scala/common/rest/WskRest.scala     | 23 +++++++++++-----------
 .../test/scala/system/basic/WskConsoleTests.scala  | 13 ++++++------
 .../src/test/scala/system/basic/WskRuleTests.scala |  4 ++--
 .../core/controller/test/ActivationsApiTests.scala | 23 ++++++++++------------
 9 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/ansible/group_vars/all b/ansible/group_vars/all
index d25b84e..b3644b4 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 43dc52d..3dc1b1e 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 4073093..596a5ec 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 b114450..3bd6367 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 0403d1c..06e7efe 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 0ae28f9..d5feb33 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 064de72..9df9bcb 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 e110c28..2baac6d 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 5341836..e4a02ff 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)
       }
     }
   }

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