Adding Setup
- Majority of tests on Fey will be integrated. They must be executed sequentially.
- Setup should happen only once, right before all suites run
diff --git a/fey-core/src/test/scala/org/apache/iota/fey/BaseAkkaSpec.scala b/fey-core/src/test/scala/org/apache/iota/fey/BaseAkkaSpec.scala
index 34a264b..fbf80f9 100644
--- a/fey-core/src/test/scala/org/apache/iota/fey/BaseAkkaSpec.scala
+++ b/fey-core/src/test/scala/org/apache/iota/fey/BaseAkkaSpec.scala
@@ -18,14 +18,11 @@
package org.apache.iota.fey
-import java.io.File
import java.nio.file.Paths
import akka.actor.{ActorIdentity, ActorRef, ActorSystem, Identify, Props}
import akka.testkit.{EventFilter, TestActorRef, TestEvent, TestProbe}
-import akka.util.Timeout
import com.typesafe.config.ConfigFactory
-import org.apache.commons.io.FileUtils
import org.scalatest.BeforeAndAfterAll
import play.api.libs.json._
@@ -34,10 +31,9 @@
class BaseAkkaSpec extends BaseSpec with BeforeAndAfterAll{
- createFeyTmpDirectoriesForTest()
- val conf = getClass.getResource("/test-fey-configuration.conf")
- CONFIG.loadUserConfiguration(Paths.get(conf.toURI()).toFile().getAbsolutePath)
- copyTestActorToTmp()
+ //Load default configuration for Fey when running tests
+ CONFIG.loadUserConfiguration(Paths.get(TestSetup.configTest.toURI()).toFile().getAbsolutePath)
+ TestSetup.setup()
val systemName = "FEY-TEST"
implicit val system = ActorSystem(systemName, ConfigFactory.parseString("""akka.loggers = ["akka.testkit.TestEventListener"]"""))
@@ -50,26 +46,10 @@
val globalIdentifierRef = system.actorOf(Props[IdentifyFeyActors],globalIdentifierName)
override protected def afterAll(): Unit = {
+ Monitor.events.removeAllNodes()
Await.ready(system.terminate(), 20.seconds)
}
- private def copyTestActorToTmp(): Unit = {
- val jarTest = getClass.getResource("/fey-test-actor.jar")
- val dest = new File(s"${CONFIG.JAR_REPOSITORY}/fey-test-actor.jar")
- FileUtils.copyURLToFile(jarTest, dest)
- }
-
- private def createFeyTmpDirectoriesForTest(): Unit = {
- var file = new File(s"/tmp/fey/test/checkpoint")
- file.mkdirs()
- file = new File(s"/tmp/fey/test/json")
- file.mkdirs()
- file = new File(s"/tmp/fey/test/jars")
- file.mkdirs()
- file = new File(s"/tmp/fey/test/jars/dynamic")
- file.mkdirs()
- }
-
implicit class TestProbeOps(probe: TestProbe) {
def expectActor(path: String, max: FiniteDuration = 3.seconds): ActorRef = {
diff --git a/fey-core/src/test/scala/org/apache/iota/fey/TestSetup.scala b/fey-core/src/test/scala/org/apache/iota/fey/TestSetup.scala
new file mode 100644
index 0000000..7f25490
--- /dev/null
+++ b/fey-core/src/test/scala/org/apache/iota/fey/TestSetup.scala
@@ -0,0 +1,59 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.iota.fey
+
+import java.io.File
+import java.nio.file.Paths
+
+import org.apache.commons.io.FileUtils
+
+object TestSetup {
+
+ private var runSetup = true
+
+ val configTest = getClass.getResource("/test-fey-configuration.conf")
+
+ def setup(): Unit = {
+ if(runSetup){
+ println("SETTING UP ...")
+ createFeyTmpDirectoriesForTest()
+ copyTestActorToTmp()
+ runSetup = false
+ }
+ }
+
+ private def copyTestActorToTmp(): Unit = {
+ val jarTest = getClass.getResource("/fey-test-actor.jar")
+ val dest = new File(s"${CONFIG.JAR_REPOSITORY}/fey-test-actor.jar")
+ FileUtils.copyURLToFile(jarTest, dest)
+ }
+
+ private def createFeyTmpDirectoriesForTest(): Unit = {
+ var file = new File(s"/tmp/fey/test/checkpoint")
+ file.mkdirs()
+ file = new File(s"/tmp/fey/test/json")
+ file.mkdirs()
+ file = new File(s"/tmp/fey/test/jars")
+ file.mkdirs()
+ file = new File(s"/tmp/fey/test/jars/dynamic")
+ file.mkdirs()
+ }
+
+
+}
diff --git a/project/BuildSettings.scala b/project/BuildSettings.scala
index 0416900..17bb264 100644
--- a/project/BuildSettings.scala
+++ b/project/BuildSettings.scala
@@ -60,7 +60,10 @@
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
- }
+ },
+ //All tests on Fey are integrated tests.
+ //All tests need to be execute sequentially
+ parallelExecution in Test := false
)
lazy val StreambuildSettings = Defaults.coreDefaultSettings ++ Seq(