iota-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tonyfaust...@apache.org
Subject [05/10] incubator-iota git commit: Adding Setup
Date Thu, 21 Jul 2016 23:37:56 GMT
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


Project: http://git-wip-us.apache.org/repos/asf/incubator-iota/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-iota/commit/90ffcf3b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-iota/tree/90ffcf3b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-iota/diff/90ffcf3b

Branch: refs/heads/master
Commit: 90ffcf3b4163c8f02ad36c8662d43e47a8f36469
Parents: d3db152
Author: Barbara Gomes <barbaramaltagomes@gmail.com>
Authored: Wed Jul 20 13:01:18 2016 -0700
Committer: Barbara Gomes <barbaramaltagomes@gmail.com>
Committed: Wed Jul 20 13:01:18 2016 -0700

----------------------------------------------------------------------
 .../org/apache/iota/fey/BaseAkkaSpec.scala      | 28 ++--------
 .../scala/org/apache/iota/fey/TestSetup.scala   | 59 ++++++++++++++++++++
 project/BuildSettings.scala                     |  5 +-
 3 files changed, 67 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/90ffcf3b/fey-core/src/test/scala/org/apache/iota/fey/BaseAkkaSpec.scala
----------------------------------------------------------------------
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 @@ import scala.concurrent.Await
 
 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 @@ class BaseAkkaSpec extends BaseSpec with BeforeAndAfterAll{
   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 = {

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/90ffcf3b/fey-core/src/test/scala/org/apache/iota/fey/TestSetup.scala
----------------------------------------------------------------------
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()
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/90ffcf3b/project/BuildSettings.scala
----------------------------------------------------------------------
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 @@ object BuildSettings {
       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(


Mime
View raw message