You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iota.apache.org by to...@apache.org on 2016/07/18 20:43:29 UTC
[06/12] incubator-iota git commit: FeyCore.scala tests
FeyCore.scala tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-iota/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-iota/commit/0ced6757
Tree: http://git-wip-us.apache.org/repos/asf/incubator-iota/tree/0ced6757
Diff: http://git-wip-us.apache.org/repos/asf/incubator-iota/diff/0ced6757
Branch: refs/heads/master
Commit: 0ced67579ba2bc4df507bc785ac3b60289d54dcb
Parents: 2d51565
Author: Barbara Gomes <ba...@gmail.com>
Authored: Fri Jul 15 17:17:24 2016 -0700
Committer: Barbara Gomes <ba...@gmail.com>
Committed: Fri Jul 15 17:17:24 2016 -0700
----------------------------------------------------------------------
.../org/apache/iota/fey/BaseAkkaSpec.scala | 3 +-
.../scala/org/apache/iota/fey/FeyCoreSpec.scala | 28 +++++++++++----
.../org/apache/iota/fey/Utils_JSONTest.scala | 36 ++++++++++++++++++++
3 files changed, 60 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/0ced6757/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 b650e88..673538e 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
@@ -24,6 +24,7 @@ import java.nio.file.Paths
import akka.actor.{ActorIdentity, ActorRef, ActorSystem, Identify}
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._
@@ -38,7 +39,7 @@ class BaseAkkaSpec extends BaseSpec with BeforeAndAfterAll{
CONFIG.loadUserConfiguration(Paths.get(conf.toURI()).toFile().getAbsolutePath)
copyTestActorToTmp()
- implicit val system = ActorSystem()
+ implicit val system = ActorSystem("FEY-TEST", ConfigFactory.parseString("""akka.loggers = ["akka.testkit.TestEventListener"]"""))
system.eventStream.publish(TestEvent.Mute(EventFilter.debug()))
system.eventStream.publish(TestEvent.Mute(EventFilter.info()))
system.eventStream.publish(TestEvent.Mute(EventFilter.warning()))
http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/0ced6757/fey-core/src/test/scala/org/apache/iota/fey/FeyCoreSpec.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/test/scala/org/apache/iota/fey/FeyCoreSpec.scala b/fey-core/src/test/scala/org/apache/iota/fey/FeyCoreSpec.scala
index 411ce24..9fa3299 100644
--- a/fey-core/src/test/scala/org/apache/iota/fey/FeyCoreSpec.scala
+++ b/fey-core/src/test/scala/org/apache/iota/fey/FeyCoreSpec.scala
@@ -21,9 +21,9 @@ package org.apache.iota.fey
import java.io.File
import akka.actor.{ActorRef, PoisonPill, Props}
-import akka.testkit.{EventFilter, TestActorRef, TestProbe}
+import akka.testkit.{EventFilter, TestProbe}
-import scala.concurrent.duration.{DurationInt, FiniteDuration}
+import scala.concurrent.duration.DurationInt
class FeyCoreSpec extends BaseAkkaSpec {
@@ -59,9 +59,9 @@ class FeyCoreSpec extends BaseAkkaSpec {
var ensemble2Test1ref:ActorRef = _
var orchestrationref:ActorRef = _
+ val orchestration_name = "TEST-ACTOR"
"Sending FeyCore.ORCHESTRATION_RECEIVED with CREATE command to FeyCore" should {
- val orchestration_name = "TEST-ACTOR"
feyCoreRef ! FeyCore.ORCHESTRATION_RECEIVED(getJSValueFromString(Utils_JSONTest.create_json_test), new File("/tmp/fey/test/json"))
s"result in creating an Orchestration child actor with the name '$orchestration_name'" in {
orchestrationref = TestProbe().expectActor(s"$feyPath/$orchestration_name")
@@ -84,7 +84,6 @@ class FeyCoreSpec extends BaseAkkaSpec {
}
"Sending FeyCore.ORCHESTRATION_RECEIVED with UPDATE command to FeyCore" should {
- val orchestration_name = "TEST-ACTOR"
s"result in creating a new Performer child actor with the name '$orchestration_name/MY-ENSEMBLE-0001/TEST-0002'" in {
feyCoreRef ! FeyCore.ORCHESTRATION_RECEIVED(getJSValueFromString(Utils_JSONTest.update_json_test), new File("/tmp/fey/test/json"))
ensemble1Test2ref = TestProbe().expectActor(s"$feyPath/$orchestration_name/MY-ENSEMBLE-0001/TEST-0002")
@@ -92,7 +91,6 @@ class FeyCoreSpec extends BaseAkkaSpec {
}
"Sending FeyCore.ORCHESTRATION_RECEIVED with UPDATE command and DELETE ensemble to FeyCore" should {
- val orchestration_name = "TEST-ACTOR"
s"result in termination of Ensemble with the name '$orchestration_name/MY-ENSEMBLE-0001'" in {
feyCoreRef ! FeyCore.ORCHESTRATION_RECEIVED(getJSValueFromString(Utils_JSONTest.update_delete_json_test), new File("/tmp/fey/test/json"))
TestProbe().verifyActorTermination(ensemble1ref)
@@ -105,8 +103,23 @@ class FeyCoreSpec extends BaseAkkaSpec {
}
}
+ "Sending FeyCore.ORCHESTRATION_RECEIVED with RECREATE command and same Timestamp to FeyCore" should {
+ s"result in logging a 'not recreated' message at Warn " in {
+ EventFilter.warning(pattern = s".*$orchestration_name not recreated.*", occurrences = 1) intercept {
+ feyCoreRef ! FeyCore.ORCHESTRATION_RECEIVED(getJSValueFromString(Utils_JSONTest.recreate_timestamp_json_test), new File("/tmp/fey/test/json"))
+ }
+ }
+ }
+
+ "Sending FeyCore.JSON_TREE to FeyCore" should {
+ s"result in logging a 6 path messages at Info " in {
+ EventFilter.info(pattern = s"^akka://.*/user/.*", occurrences = 6) intercept {
+ feyCoreRef ! FeyCore.JSON_TREE
+ }
+ }
+ }
+
"Sending FeyCore.ORCHESTRATION_RECEIVED with DELETE command to FeyCore" should {
- val orchestration_name = "TEST-ACTOR"
s"result in termination of Orchestration with the name '$orchestration_name'" in {
feyCoreRef ! FeyCore.ORCHESTRATION_RECEIVED(getJSValueFromString(Utils_JSONTest.delete_json_test), new File("/tmp/fey/test/json"))
TestProbe().verifyActorTermination(orchestrationref)
@@ -120,6 +133,9 @@ class FeyCoreSpec extends BaseAkkaSpec {
s"result in termination of Performer with the name '$orchestration_name/MY-ENSEMBLE-0002/TEST-0001'" in {
TestProbe().notExpectActor(ensemble2Test1ref.path.toString)
}
+ s"result in removing key '$orchestration_name' at FEY_CACHE.activeOrchestrations" in {
+ FEY_CACHE.activeOrchestrations should not contain key(orchestration_name)
+ }
}
"Stopping FeyCore" should {
http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/0ced6757/fey-core/src/test/scala/org/apache/iota/fey/Utils_JSONTest.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/test/scala/org/apache/iota/fey/Utils_JSONTest.scala b/fey-core/src/test/scala/org/apache/iota/fey/Utils_JSONTest.scala
index 3c873dc..e65aafc 100644
--- a/fey-core/src/test/scala/org/apache/iota/fey/Utils_JSONTest.scala
+++ b/fey-core/src/test/scala/org/apache/iota/fey/Utils_JSONTest.scala
@@ -147,5 +147,41 @@ object Utils_JSONTest {
"ensembles" : []
}"""
+ val recreate_timestamp_json_test =
+ """{
+ "guid" : "TEST-ACTOR",
+ "command" : "RECREATE",
+ "timestamp": "213263914979",
+ "name" : "ORCHESTRATION FOR TEST",
+ "ensembles" : [
+ {
+ "guid":"MY-ENSEMBLE-0001",
+ "command": "DELETE",
+ "performers":[
+ {
+ "guid": "TEST-0001",
+ "schedule": 0,
+ "backoff": 0,
+ "source": {
+ "name": "fey-test-actor.jar",
+ "classPath": "org.apache.iota.fey.TestActor",
+ "parameters": {}
+ }
+ },
+ {
+ "guid": "TEST-0002",
+ "schedule": 0,
+ "backoff": 0,
+ "source": {
+ "name": "fey-test-actor.jar",
+ "classPath": "org.apache.iota.fey.TestActor",
+ "parameters": {}
+ }
+ }
+ ],
+ "connections":[]
+ }
+ ]
+ }"""
}