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 2019/04/22 13:30:23 UTC

[incubator-openwhisk] branch master updated: Shutdown actorSystem when tests are finished (#4452)

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 603b0a6  Shutdown actorSystem when tests are finished (#4452)
603b0a6 is described below

commit 603b0a6d0dfb4d1b2549e334c8fe9c752e442827
Author: jiangpch <ji...@navercorp.com>
AuthorDate: Mon Apr 22 21:30:12 2019 +0800

    Shutdown actorSystem when tests are finished (#4452)
---
 .../containerpool/logging/ElasticSearchLogStoreTests.scala |  8 +++++++-
 .../logging/ElasticSearchRestClientTests.scala             | 12 +++++++-----
 .../containerpool/logging/LogDriverLogStoreTests.scala     | 14 +++++++++++---
 .../core/containerpool/logging/SplunkLogStoreTests.scala   |  8 +++++++-
 .../mesos/test/MesosContainerFactoryTest.scala             | 13 +++++++++----
 .../ArtifactWithFileStorageActivationStoreTests.scala      |  9 ++++++++-
 .../org/apache/openwhisk/http/PoolingRestClientTests.scala | 12 +++++++-----
 7 files changed, 56 insertions(+), 20 deletions(-)

diff --git a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchLogStoreTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchLogStoreTests.scala
index 07e9660..a3af8fd 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchLogStoreTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchLogStoreTests.scala
@@ -31,7 +31,7 @@ import common.StreamLogging
 import org.junit.runner.RunWith
 import org.scalatest.concurrent.ScalaFutures
 import org.scalatest.junit.JUnitRunner
-import org.scalatest.{FlatSpecLike, Matchers}
+import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
 import pureconfig.error.ConfigReaderException
 import spray.json._
 import org.apache.openwhisk.core.entity._
@@ -47,6 +47,7 @@ class ElasticSearchLogStoreTests
     extends TestKit(ActorSystem("ElasticSearchLogStore"))
     with FlatSpecLike
     with Matchers
+    with BeforeAndAfterAll
     with ScalaFutures
     with StreamLogging {
 
@@ -105,6 +106,11 @@ class ElasticSearchLogStoreTests
     logs = expectedLogs,
     annotations = Parameters("limits", ActionLimits(TimeLimit(1.second), MemoryLimit(128.MB), LogLimit(1.MB)).toJson))
 
+  override def afterAll(): Unit = {
+    TestKit.shutdownActorSystem(system)
+    super.afterAll()
+  }
+
   private def testFlow(httpResponse: HttpResponse = HttpResponse(), httpRequest: HttpRequest = HttpRequest())
     : Flow[(HttpRequest, Promise[HttpResponse]), (Try[HttpResponse], Promise[HttpResponse]), NotUsed] =
     Flow[(HttpRequest, Promise[HttpResponse])]
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchRestClientTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchRestClientTests.scala
index a813503..49ae2a4 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchRestClientTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/ElasticSearchRestClientTests.scala
@@ -18,12 +18,10 @@
 package org.apache.openwhisk.core.containerpool.logging
 
 import spray.json._
-
 import org.junit.runner.RunWith
-import org.scalatest.{FlatSpecLike, Matchers}
+import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
 import org.scalatest.concurrent.ScalaFutures
 import org.scalatest.junit.JUnitRunner
-
 import akka.NotUsed
 import akka.actor.ActorSystem
 import akka.http.scaladsl.model._
@@ -32,9 +30,7 @@ import akka.stream.scaladsl.Flow
 import akka.stream.ActorMaterializer
 import akka.testkit.TestKit
 import akka.http.scaladsl.model.HttpMethods.POST
-
 import common.StreamLogging
-
 import org.apache.openwhisk.core.containerpool.logging.ElasticSearchJsonProtocol._
 
 import scala.concurrent.duration._
@@ -46,6 +42,7 @@ class ElasticSearchRestClientTests
     extends TestKit(ActorSystem("ElasticSearchRestClient"))
     with FlatSpecLike
     with Matchers
+    with BeforeAndAfterAll
     with ScalaFutures
     with StreamLogging {
 
@@ -62,6 +59,11 @@ class ElasticSearchRestClientTests
     headers = List(Accept(MediaTypes.`application/json`)),
     entity = HttpEntity(ContentTypes.`application/json`, EsQuery(EsQueryAll()).toJson.toString))
 
+  override def afterAll(): Unit = {
+    TestKit.shutdownActorSystem(system)
+    super.afterAll()
+  }
+
   private def testFlow(httpResponse: HttpResponse = HttpResponse(), httpRequest: HttpRequest = HttpRequest())
     : Flow[(HttpRequest, Promise[HttpResponse]), (Try[HttpResponse], Promise[HttpResponse]), NotUsed] =
     Flow[(HttpRequest, Promise[HttpResponse])]
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/LogDriverLogStoreTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/LogDriverLogStoreTests.scala
index 7e689c7..0f92bf9 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/LogDriverLogStoreTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/LogDriverLogStoreTests.scala
@@ -20,13 +20,16 @@ package org.apache.openwhisk.core.containerpool.logging
 import akka.actor.ActorSystem
 import akka.testkit.TestKit
 import org.junit.runner.RunWith
-import org.scalatest.FlatSpecLike
-import org.scalatest.Matchers
+import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
 import org.scalatest.junit.JUnitRunner
 import org.apache.openwhisk.core.containerpool.ContainerArgsConfig
 
 @RunWith(classOf[JUnitRunner])
-class LogDriverLogStoreTests extends TestKit(ActorSystem("LogDriverLogStore")) with FlatSpecLike with Matchers {
+class LogDriverLogStoreTests
+    extends TestKit(ActorSystem("LogDriverLogStore"))
+    with FlatSpecLike
+    with Matchers
+    with BeforeAndAfterAll {
 
   val testConfig = ContainerArgsConfig(
     network = "network",
@@ -34,6 +37,11 @@ class LogDriverLogStoreTests extends TestKit(ActorSystem("LogDriverLogStore")) w
       Map("log-driver" -> Set("fluentd"), "log-opt" -> Set("fluentd-address=localhost:24225", "tag=OW_CONTAINER")))
   behavior of "LogDriver LogStore"
 
+  override def afterAll(): Unit = {
+    TestKit.shutdownActorSystem(system)
+    super.afterAll()
+  }
+
   it should "set the container parameters from the config" in {
     val logDriverLogStore = new LogDriverLogStore(system)
     logDriverLogStore.containerParameters shouldBe Map.empty
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/SplunkLogStoreTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/SplunkLogStoreTests.scala
index e7a1567..d505a36 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/SplunkLogStoreTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/logging/SplunkLogStoreTests.scala
@@ -33,7 +33,7 @@ import common.StreamLogging
 import org.junit.runner.RunWith
 import org.scalatest.concurrent.ScalaFutures
 import org.scalatest.junit.JUnitRunner
-import org.scalatest.{FlatSpecLike, Matchers}
+import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
 import pureconfig.error.ConfigReaderException
 import spray.json._
 import org.apache.openwhisk.core.entity._
@@ -49,11 +49,17 @@ class SplunkLogStoreTests
     extends TestKit(ActorSystem("SplunkLogStore"))
     with FlatSpecLike
     with Matchers
+    with BeforeAndAfterAll
     with ScalaFutures
     with StreamLogging {
 
   def await[T](awaitable: Future[T], timeout: FiniteDuration = 10.seconds) = Await.result(awaitable, timeout)
 
+  override def afterAll(): Unit = {
+    TestKit.shutdownActorSystem(system)
+    super.afterAll()
+  }
+
   val testConfig = SplunkLogStoreConfig(
     "splunk-host",
     8080,
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/mesos/test/MesosContainerFactoryTest.scala b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/mesos/test/MesosContainerFactoryTest.scala
index c4f68b4..04577e3 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/mesos/test/MesosContainerFactoryTest.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/mesos/test/MesosContainerFactoryTest.scala
@@ -39,10 +39,9 @@ import org.apache.mesos.v1.Protos.TaskID
 import org.apache.mesos.v1.Protos.TaskState
 import org.apache.mesos.v1.Protos.TaskStatus
 import org.junit.runner.RunWith
-import org.scalatest.BeforeAndAfterEach
-import org.scalatest.FlatSpecLike
-import org.scalatest.Matchers
+import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, FlatSpecLike, Matchers}
 import org.scalatest.junit.JUnitRunner
+
 import scala.collection.immutable.Map
 import scala.concurrent.Await
 import scala.concurrent.Future
@@ -65,7 +64,8 @@ class MesosContainerFactoryTest
     with FlatSpecLike
     with Matchers
     with StreamLogging
-    with BeforeAndAfterEach {
+    with BeforeAndAfterEach
+    with BeforeAndAfterAll {
 
   /** Awaits the given future, throws the exception enclosed in Failure. */
   def await[A](f: Future[A], timeout: FiniteDuration = 500.milliseconds) = Await.result[A](f, timeout)
@@ -97,6 +97,11 @@ class MesosContainerFactoryTest
     stream.reset()
   }
 
+  override def afterAll(): Unit = {
+    TestKit.shutdownActorSystem(system)
+    super.afterAll()
+  }
+
   val timeouts = MesosTimeoutConfig(1.seconds, 1.seconds, 1.seconds, 1.seconds, 1.seconds)
 
   val mesosConfig =
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/database/ArtifactWithFileStorageActivationStoreTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/database/ArtifactWithFileStorageActivationStoreTests.scala
index 205634c..f703627 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/database/ArtifactWithFileStorageActivationStoreTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/database/ArtifactWithFileStorageActivationStoreTests.scala
@@ -28,12 +28,13 @@ import common.StreamLogging
 import org.junit.runner.RunWith
 import org.scalatest.concurrent.ScalaFutures
 import org.scalatest.junit.JUnitRunner
-import org.scalatest.{FlatSpecLike, Matchers}
+import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
 import spray.json.DefaultJsonProtocol._
 import spray.json._
 import org.apache.openwhisk.common.TransactionId
 import org.apache.openwhisk.core.entity._
 import org.apache.openwhisk.core.entity.size.SizeInt
+
 import scala.concurrent.{Await, Future}
 import scala.concurrent.duration._
 import scala.io.Source
@@ -43,6 +44,7 @@ class ArtifactWithFileStorageActivationStoreTests()
     extends TestKit(ActorSystem("ArtifactWithFileStorageActivationStoreTests"))
     with FlatSpecLike
     with Matchers
+    with BeforeAndAfterAll
     with ScalaFutures
     with StreamLogging {
 
@@ -56,6 +58,11 @@ class ArtifactWithFileStorageActivationStoreTests()
     Identity(subject, Namespace(EntityName("testSpace"), uuid), BasicAuthenticationAuthKey(uuid, Secret()), Set())
   private val context = UserContext(user, HttpRequest())
 
+  override def afterAll(): Unit = {
+    TestKit.shutdownActorSystem(system)
+    super.afterAll()
+  }
+
   private def await[T](awaitable: Future[T], timeout: FiniteDuration = 10.seconds) = Await.result(awaitable, timeout)
 
   def responsePermutations = {
diff --git a/tests/src/test/scala/org/apache/openwhisk/http/PoolingRestClientTests.scala b/tests/src/test/scala/org/apache/openwhisk/http/PoolingRestClientTests.scala
index 26dba87..be71858 100644
--- a/tests/src/test/scala/org/apache/openwhisk/http/PoolingRestClientTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/http/PoolingRestClientTests.scala
@@ -18,10 +18,9 @@
 package org.apache.openwhisk.http
 
 import org.junit.runner.RunWith
-import org.scalatest.{FlatSpecLike, Matchers}
+import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
 import org.scalatest.concurrent.ScalaFutures
 import org.scalatest.junit.JUnitRunner
-
 import akka.NotUsed
 import akka.actor.ActorSystem
 import akka.stream.scaladsl.Flow
@@ -32,16 +31,13 @@ import akka.http.scaladsl.model.HttpMethods.{GET, POST}
 import akka.http.scaladsl.model.StatusCodes.{InternalServerError, NotFound}
 import akka.http.scaladsl.model.headers.RawHeader
 import akka.http.scaladsl.unmarshalling.Unmarshaller.UnsupportedContentTypeException
-
 import common.StreamLogging
-
 import spray.json.JsObject
 import spray.json.DefaultJsonProtocol._
 
 import scala.concurrent.duration._
 import scala.concurrent.{Await, ExecutionContext, Future, Promise, TimeoutException}
 import scala.util.{Success, Try}
-
 import org.apache.openwhisk.http.PoolingRestClient._
 
 @RunWith(classOf[JUnitRunner])
@@ -49,11 +45,17 @@ class PoolingRestClientTests
     extends TestKit(ActorSystem("PoolingRestClientTests"))
     with FlatSpecLike
     with Matchers
+    with BeforeAndAfterAll
     with ScalaFutures
     with StreamLogging {
   implicit val ec: ExecutionContext = system.dispatcher
   implicit val materializer: ActorMaterializer = ActorMaterializer()
 
+  override def afterAll(): Unit = {
+    TestKit.shutdownActorSystem(system)
+    super.afterAll()
+  }
+
   def testFlow(httpResponse: HttpResponse = HttpResponse(), httpRequest: HttpRequest = HttpRequest())
     : Flow[(HttpRequest, Promise[HttpResponse]), (Try[HttpResponse], Promise[HttpResponse]), NotUsed] =
     Flow[(HttpRequest, Promise[HttpResponse])]