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 b2b72bd  Don't use stubbed functions in InvokerSupervisionTests. 
(#3826)
b2b72bd is described below

commit b2b72bd4ba6946cb4de81b4b45002db18b9ae107
Author: Markus Thömmes <markusthoem...@me.com>
AuthorDate: Fri Jun 29 23:20:44 2018 +0200

    Don't use stubbed functions in InvokerSupervisionTests. (#3826)
    
    `stubFunctions` don't seem to play nicely with retry logic because the 
`verify` handler will be attached more than once. Switching to a manual stub 
should help here.
    
    Fixes #3809
---
 tests/src/test/scala/common/LoggedFunction.scala         | 13 +++++++------
 .../core/loadBalancer/test/InvokerSupervisionTests.scala | 16 +++++-----------
 2 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/tests/src/test/scala/common/LoggedFunction.scala 
b/tests/src/test/scala/common/LoggedFunction.scala
index e8b7261..9c338db 100644
--- a/tests/src/test/scala/common/LoggedFunction.scala
+++ b/tests/src/test/scala/common/LoggedFunction.scala
@@ -83,10 +83,11 @@ class LoggedFunction6[A1, A2, A3, A4, A5, A6, B](body: (A1, 
A2, A3, A4, A5, A6)
 }
 
 object LoggedFunction {
-  def apply[A1, B](body: (A1) => B) = new LoggedFunction1(body)
-  def apply[A1, A2, B](body: (A1, A2) => B) = new LoggedFunction2(body)
-  def apply[A1, A2, A3, B](body: (A1, A2, A3) => B) = new LoggedFunction3(body)
-  def apply[A1, A2, A3, A4, B](body: (A1, A2, A3, A4) => B) = new 
LoggedFunction4(body)
-  def apply[A1, A2, A3, A4, A5, B](body: (A1, A2, A3, A4, A5) => B) = new 
LoggedFunction5(body)
-  def apply[A1, A2, A3, A4, A5, A6, B](body: (A1, A2, A3, A4, A5, A6) => B) = 
new LoggedFunction6(body)
+  def apply[A1, B](body: (A1) => B) = new LoggedFunction1[A1, B](body)
+  def apply[A1, A2, B](body: (A1, A2) => B) = new LoggedFunction2[A1, A2, 
B](body)
+  def apply[A1, A2, A3, B](body: (A1, A2, A3) => B) = new LoggedFunction3[A1, 
A2, A3, B](body)
+  def apply[A1, A2, A3, A4, B](body: (A1, A2, A3, A4) => B) = new 
LoggedFunction4[A1, A2, A3, A4, B](body)
+  def apply[A1, A2, A3, A4, A5, B](body: (A1, A2, A3, A4, A5) => B) = new 
LoggedFunction5[A1, A2, A3, A4, A5, B](body)
+  def apply[A1, A2, A3, A4, A5, A6, B](body: (A1, A2, A3, A4, A5, A6) => B) =
+    new LoggedFunction6[A1, A2, A3, A4, A5, A6, B](body)
 }
diff --git 
a/tests/src/test/scala/whisk/core/loadBalancer/test/InvokerSupervisionTests.scala
 
b/tests/src/test/scala/whisk/core/loadBalancer/test/InvokerSupervisionTests.scala
index 2605058..8e11417 100644
--- 
a/tests/src/test/scala/whisk/core/loadBalancer/test/InvokerSupervisionTests.scala
+++ 
b/tests/src/test/scala/whisk/core/loadBalancer/test/InvokerSupervisionTests.scala
@@ -42,7 +42,7 @@ import akka.testkit.TestFSMRef
 import akka.testkit.TestKit
 import akka.testkit.TestProbe
 import akka.util.Timeout
-import common.StreamLogging
+import common.{LoggedFunction, StreamLogging}
 import whisk.common.TransactionId
 import whisk.core.WhiskConfig
 import whisk.core.connector.ActivationMessage
@@ -175,7 +175,9 @@ class InvokerSupervisionTests
     val invokerName = s"invoker${invokerInstance.toInt}"
     val childFactory = (f: ActorRefFactory, instance: InvokerInstanceId) => 
invoker.ref
 
-    val sendActivationToInvoker = stubFunction[ActivationMessage, 
InvokerInstanceId, Future[RecordMetadata]]
+    val sendActivationToInvoker = LoggedFunction { (a: ActivationMessage, b: 
InvokerInstanceId) =>
+      Future.successful(new RecordMetadata(new TopicPartition(invokerName, 0), 
0L, 0L, 0L, Long.box(0L), 0, 0))
+    }
 
     val supervisor = system.actorOf(InvokerPool.props(childFactory, 
sendActivationToInvoker, pC))
 
@@ -196,18 +198,10 @@ class InvokerSupervisionTests
       content = None)
     val msg = ActivationRequest(activationMessage, invokerInstance)
 
-    sendActivationToInvoker
-      .when(activationMessage, invokerInstance)
-      .returns(
-        Future.successful(new RecordMetadata(new TopicPartition(invokerName, 
0), 0L, 0L, 0L, Long.box(0L), 0, 0)))
-
     supervisor ! msg
 
     // Verify, that MessageProducer will receive a call to send the message
-    retry(
-      sendActivationToInvoker.verify(activationMessage, invokerInstance).once,
-      N = 3,
-      waitBeforeRetry = Some(500.milliseconds))
+    retry(sendActivationToInvoker.calls should have size 1, N = 3, 
waitBeforeRetry = Some(500.milliseconds))
   }
 
   behavior of "InvokerActor"

Reply via email to