You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by du...@apache.org on 2018/01/03 13:24:04 UTC
[incubator-openwhisk] branch master updated: Enforce WhiskAction
equality mod DocRevision. (#3121)
This is an automated email from the ASF dual-hosted git repository.
dubeejw 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 6de2694 Enforce WhiskAction equality mod DocRevision. (#3121)
6de2694 is described below
commit 6de269440b8ccc20bb1e21de0f81e8a727921d56
Author: rodric rabbah <ro...@gmail.com>
AuthorDate: Wed Jan 3 08:24:00 2018 -0500
Enforce WhiskAction equality mod DocRevision. (#3121)
---
.../main/scala/whisk/core/connector/Message.scala | 9 ---------
.../main/scala/whisk/core/entity/WhiskAction.scala | 5 +++++
.../containerpool/test/ContainerPoolTests.scala | 15 ++++++++++++++
.../scala/whisk/core/entity/test/SchemaTests.scala | 23 ++++++++++++++++++++--
4 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/common/scala/src/main/scala/whisk/core/connector/Message.scala b/common/scala/src/main/scala/whisk/core/connector/Message.scala
index c7cff9f..d79ba26 100644
--- a/common/scala/src/main/scala/whisk/core/connector/Message.scala
+++ b/common/scala/src/main/scala/whisk/core/connector/Message.scala
@@ -58,15 +58,6 @@ case class ActivationMessage(override val transid: TransactionId,
cause: Option[ActivationId] = None)
extends Message {
- def meta =
- JsObject("meta" -> {
- cause map { c =>
- JsObject(c.toJsObject.fields ++ activationId.toJsObject.fields)
- } getOrElse {
- activationId.toJsObject
- }
- })
-
override def serialize = ActivationMessage.serdes.write(this).compactPrint
override def toString = {
diff --git a/common/scala/src/main/scala/whisk/core/entity/WhiskAction.scala b/common/scala/src/main/scala/whisk/core/entity/WhiskAction.scala
index afd85cc..4aaddbd 100644
--- a/common/scala/src/main/scala/whisk/core/entity/WhiskAction.scala
+++ b/common/scala/src/main/scala/whisk/core/entity/WhiskAction.scala
@@ -216,6 +216,11 @@ case class WhiskActionMetaData(namespace: EntityPath,
*
* exec is typed to CodeExec to guarantee executability by an Invoker.
*
+ * Note: Two actions are equal regardless of their DocRevision if there is one.
+ * The invoker uses action equality when matching actions to warm containers.
+ * That means creating an action, invoking it, then deleting/recreating/reinvoking
+ * it will reuse the previous container. The delete/recreate restores the SemVer to 0.0.1.
+ *
* @param namespace the namespace for the action
* @param name the name of the action
* @param exec the action executable details
diff --git a/tests/src/test/scala/whisk/core/containerpool/test/ContainerPoolTests.scala b/tests/src/test/scala/whisk/core/containerpool/test/ContainerPoolTests.scala
index a607f5b..dcfe5e4 100644
--- a/tests/src/test/scala/whisk/core/containerpool/test/ContainerPoolTests.scala
+++ b/tests/src/test/scala/whisk/core/containerpool/test/ContainerPoolTests.scala
@@ -90,6 +90,7 @@ class ContainerPoolTests
val runMessage = createRunMessage(action, invocationNamespace)
val runMessageDifferentAction = createRunMessage(differentAction, invocationNamespace)
+ val runMessageDifferentVersion = createRunMessage(action.copy().revision(DocRevision("v2")), invocationNamespace)
val runMessageDifferentNamespace = createRunMessage(action, differentInvocationNamespace)
val runMessageDifferentEverything = createRunMessage(differentAction, differentInvocationNamespace)
@@ -133,6 +134,20 @@ class ContainerPoolTests
containers(1).expectNoMsg(100.milliseconds)
}
+ it should "reuse a warm container when action is the same even if revision changes" in within(timeout) {
+ val (containers, factory) = testContainers(2)
+ val feed = TestProbe()
+ val pool = system.actorOf(ContainerPool.props(factory, 2, 2, feed.ref))
+
+ pool ! runMessage
+ containers(0).expectMsg(runMessage)
+ containers(0).send(pool, NeedWork(warmedData()))
+
+ pool ! runMessageDifferentVersion
+ containers(0).expectMsg(runMessageDifferentVersion)
+ containers(1).expectNoMsg(100.milliseconds)
+ }
+
it should "create a container if it cannot find a matching container" in within(timeout) {
val (containers, factory) = testContainers(2)
val feed = TestProbe()
diff --git a/tests/src/test/scala/whisk/core/entity/test/SchemaTests.scala b/tests/src/test/scala/whisk/core/entity/test/SchemaTests.scala
index dd3fa04..504db38 100644
--- a/tests/src/test/scala/whisk/core/entity/test/SchemaTests.scala
+++ b/tests/src/test/scala/whisk/core/entity/test/SchemaTests.scala
@@ -26,17 +26,16 @@ import scala.language.postfixOps
import scala.language.reflectiveCalls
import scala.util.Failure
import scala.util.Try
-
import org.junit.runner.RunWith
import org.scalatest.BeforeAndAfter
import org.scalatest.FlatSpec
import org.scalatest.Matchers
import org.scalatest.junit.JUnitRunner
-
import spray.json._
import spray.json.DefaultJsonProtocol._
import whisk.core.controller.test.WhiskAuthHelpers
import whisk.core.entitlement.Privilege
+import whisk.core.entity.ExecManifest.{ImageName, RuntimeManifest}
import whisk.core.entity._
import whisk.core.entity.size.SizeInt
import whisk.http.Messages
@@ -469,6 +468,26 @@ class SchemaTests extends FlatSpec with BeforeAndAfter with ExecHelpers with Mat
}
}
+ it should "compare as equal two actions even if their revision does not match" in {
+ val exec = CodeExecAsString(RuntimeManifest("actionKind", ImageName("testImage")), "testCode", None)
+ val actionA = WhiskAction(EntityPath("actionSpace"), EntityName("actionName"), exec)
+ val actionB = actionA.copy()
+ val actionC = actionA.copy()
+ actionC.revision(DocRevision("2"))
+ actionA shouldBe actionB
+ actionA shouldBe actionC
+ }
+
+ it should "compare as equal two executable actions even if their revision does not match" in {
+ val exec = CodeExecAsString(RuntimeManifest("actionKind", ImageName("testImage")), "testCode", None)
+ val actionA = ExecutableWhiskAction(EntityPath("actionSpace"), EntityName("actionName"), exec)
+ val actionB = actionA.copy()
+ val actionC = actionA.copy()
+ actionC.revision(DocRevision("2"))
+ actionA shouldBe actionB
+ actionA shouldBe actionC
+ }
+
it should "reject malformed JSON" in {
val b64 = Base64.getEncoder()
val contents = b64.encodeToString("tarball".getBytes)
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].