markusthoemmes commented on a change in pull request #2531: Share bookkeeping
data across controllers
URL:
https://github.com/apache/incubator-openwhisk/pull/2531#discussion_r138258279
##########
File path:
tests/src/test/scala/whisk/core/loadBalancer/test/LoadBalancerDataTests.scala
##########
@@ -17,29 +17,49 @@
package whisk.core.loadBalancer.test
+import akka.actor.{ActorSystem}
+import com.typesafe.config.{ConfigFactory, ConfigValueFactory}
import org.scalatest.{FlatSpec, Matchers}
import whisk.core.entity.{ActivationId, UUID, WhiskActivation}
import whisk.core.loadBalancer.{ActivationEntry, LoadBalancerData}
-import scala.concurrent.{Promise}
+import scala.concurrent.{Await, Promise}
import whisk.core.entity.InstanceId
+import scala.concurrent.duration._
+
class LoadBalancerDataTests extends FlatSpec with Matchers {
val activationIdPromise = Promise[Either[ActivationId, WhiskActivation]]()
val firstEntry: ActivationEntry = ActivationEntry(ActivationId(), UUID(),
InstanceId(0), activationIdPromise)
val secondEntry: ActivationEntry = ActivationEntry(ActivationId(), UUID(),
InstanceId(1), activationIdPromise)
+ val port = 2552
+ val config = ConfigFactory
+ .parseString("akka.cluster { seed-nodes =
[\"akka.tcp://[email protected]" +
+ s".1:$port" + "\"] }")
+ .withValue("akka.remote.netty.tcp.hostname",
ConfigValueFactory.fromAnyRef("127.0.0.1"))
+ .withValue("akka.remote.netty.tcp.port",
ConfigValueFactory.fromAnyRef(port))
+ .withValue("akka.cluster.auto-down-unreachable-after",
ConfigValueFactory.fromAnyRef("10s"))
+ .withValue("akka.actor.provider", ConfigValueFactory.fromAnyRef("cluster"))
+ .withValue("akka.remote.log-remote-lifecycle-events",
ConfigValueFactory.fromAnyRef("off"))
+ .withFallback(ConfigFactory.load())
+
+ implicit val actorSystem = ActorSystem("controller-actor-system", config)
+
behavior of "LoadBalancerData"
it should "return the number of activations for a namespace" in {
-
val loadBalancerData = new LoadBalancerData()
loadBalancerData.putActivation(firstEntry.id, firstEntry)
- loadBalancerData.activationCountOn(firstEntry.namespaceId) shouldBe 1
- loadBalancerData.activationCountOn(firstEntry.invokerName) shouldBe 1
+ Await.result(loadBalancerData.activationCountOn(firstEntry.namespaceId),
1.second) shouldBe 1
+ Await.result(loadBalancerData.activationCountPerInvoker, 1.second)
shouldBe Map(
Review comment:
A local await helper like we use in many tests might make sense here, to
stop repeating the `1.second` timeout:
```scala
def await[A](f: Future[A], timeout: FiniteDuration = 1.second) =
Await.result(f, timeout)
```
----------------------------------------------------------------
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