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:33 UTC
[10/12] incubator-iota git commit: TODOs: - Test ensembles val in
orchRef.underlyingActor - OrchestrationSpec - Test STOP_EMPTY_ORCHESTRATION -
FeyCoreSpec
TODOs:
- Test ensembles val in orchRef.underlyingActor - OrchestrationSpec
- Test STOP_EMPTY_ORCHESTRATION - FeyCoreSpec
Project: http://git-wip-us.apache.org/repos/asf/incubator-iota/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-iota/commit/ad056da3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-iota/tree/ad056da3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-iota/diff/ad056da3
Branch: refs/heads/master
Commit: ad056da3d38217284400730ff7e89fc513f21322
Parents: 47a69e8
Author: Barbara Gomes <ba...@gmail.com>
Authored: Mon Jul 18 10:22:20 2016 -0700
Committer: Barbara Gomes <ba...@gmail.com>
Committed: Mon Jul 18 10:22:20 2016 -0700
----------------------------------------------------------------------
.../org/apache/iota/fey/Orchestration.scala | 4 +-
.../scala/org/apache/iota/fey/FeyCoreSpec.scala | 18 ++++++++-
.../org/apache/iota/fey/OrchestrationSpec.scala | 40 +++++++++++++++++---
3 files changed, 54 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/ad056da3/fey-core/src/main/scala/org/apache/iota/fey/Orchestration.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/main/scala/org/apache/iota/fey/Orchestration.scala b/fey-core/src/main/scala/org/apache/iota/fey/Orchestration.scala
index cb1bcae..dc2e64d 100644
--- a/fey-core/src/main/scala/org/apache/iota/fey/Orchestration.scala
+++ b/fey-core/src/main/scala/org/apache/iota/fey/Orchestration.scala
@@ -35,8 +35,8 @@ protected class Orchestration(val name: String,
/**
* List of map of Ensembles = [EnsembleID, Ensemble]
*/
- private val ensembles:HashMap[String, ActorRef] = HashMap.empty[String, ActorRef]
- private val awaitingTermination:HashMap[String, JsObject] = HashMap.empty[String, JsObject]
+ val ensembles:HashMap[String, ActorRef] = HashMap.empty[String, ActorRef]
+ val awaitingTermination:HashMap[String, JsObject] = HashMap.empty[String, JsObject]
val monitoring_actor = FEY_MONITOR.actorRef
override def receive: Receive = {
http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/ad056da3/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 d5162c1..b5a2ca9 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
@@ -138,6 +138,23 @@ class FeyCoreSpec extends BaseAkkaSpec {
}
}
+ "Sending FeyCore.STOP_EMPTY_ORCHESTRATION to FeyCore" should {
+ s"result in termination of 'TEST-ORCH-2'" in {
+ feyCoreRef ! FeyCore.ORCHESTRATION_RECEIVED(getJSValueFromString(Utils_JSONTest.orchestration_test_json), new File("/tmp/fey/test/json"))
+ val ref = TestProbe().expectActor(s"$feyPath/TEST-ORCH-2")
+ FEY_CACHE.activeOrchestrations should have size(1)
+ FEY_CACHE.activeOrchestrations should contain key("TEST-ORCH-2")
+ feyCoreRef ! FeyCore.STOP_EMPTY_ORCHESTRATION("TEST-ORCH-2")
+ TestProbe().verifyActorTermination(ref)
+ }
+ s"result in sending Terminate message to Monitor actor" in{
+ monitor.expectMsgClass(1.seconds, classOf[Monitor.TERMINATE])
+ }
+ s"result in empty FEY_CACHE.activeOrchestrations" in {
+ FEY_CACHE.activeOrchestrations shouldBe empty
+ }
+ }
+
"Stopping FeyCore" should {
"result in sending STOP message to Monitor actor" in {
feyCoreRef ! PoisonPill
@@ -145,7 +162,6 @@ class FeyCoreSpec extends BaseAkkaSpec {
}
}
- //TODO: Test STOP_EMPTY_ORCHESTRATION
//TODO: Test restart
//TODO: Test checkpoint
}
http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/ad056da3/fey-core/src/test/scala/org/apache/iota/fey/OrchestrationSpec.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/test/scala/org/apache/iota/fey/OrchestrationSpec.scala b/fey-core/src/test/scala/org/apache/iota/fey/OrchestrationSpec.scala
index 4301772..8719f36 100644
--- a/fey-core/src/test/scala/org/apache/iota/fey/OrchestrationSpec.scala
+++ b/fey-core/src/test/scala/org/apache/iota/fey/OrchestrationSpec.scala
@@ -32,6 +32,7 @@ class OrchestrationSpec extends BaseAkkaSpec{
val orchRef = TestActorRef[Orchestration]( Props(new Orchestration("TESTING",orchName,"123124324324"){
override val monitoring_actor = monitor.ref
}), parent.ref, orchName)
+ val orchState = orchRef.underlyingActor
val orchestrationJson = getJSValueFromString(Utils_JSONTest.create_json_test)
val ensembles = (orchestrationJson \ JSON_PATH.ENSEMBLES).as[List[JsObject]]
@@ -50,6 +51,9 @@ class OrchestrationSpec extends BaseAkkaSpec{
IdentifyFeyActors.actorsPath should have size(1)
IdentifyFeyActors.actorsPath should contain(s"${parent.ref.path}/$orchName")
}
+ "result in empty Orchestration.ensembles state variable" in{
+ orchState.ensembles shouldBe empty
+ }
}
"Sending Orchestration.CREATE_ENSEMBLES to Orchestration" should {
@@ -64,6 +68,13 @@ class OrchestrationSpec extends BaseAkkaSpec{
TestProbe().expectActor(s"${orchRef.path}/${(ensemble2 \ JSON_PATH.GUID).as[String]}/TEST-0001")
TestProbe().expectActor(s"${orchRef.path}/${(ensemble1 \ JSON_PATH.GUID).as[String]}/TEST-0001")
}
+ s"result in two entries in Orchestration.ensembles matching the craeted ensembles" in {
+ orchState.ensembles should have size(2)
+ orchState.ensembles should contain key((ensemble1 \ JSON_PATH.GUID).as[String])
+ orchState.ensembles should contain key((ensemble2 \ JSON_PATH.GUID).as[String])
+ orchState.ensembles.get((ensemble1 \ JSON_PATH.GUID).as[String]).get should equal(ensemble1ref)
+ orchState.ensembles.get((ensemble2 \ JSON_PATH.GUID).as[String]).get should equal(ensemble2ref)
+ }
s"result in two entries in ORCHESTRATION_CACHE.orchestration_metadata for $orchName" in {
ORCHESTRATION_CACHE.orchestration_metadata should contain key(orchName)
ORCHESTRATION_CACHE.orchestration_metadata.get(orchName).get should have size(2)
@@ -98,15 +109,23 @@ class OrchestrationSpec extends BaseAkkaSpec{
orchRef ! Orchestration.CREATE_ENSEMBLES(ensembles)
}
}
+ s"not change state variable Orchestration.ensembles" in {
+ orchState.ensembles should have size(2)
+ orchState.ensembles should contain key((ensemble1 \ JSON_PATH.GUID).as[String])
+ orchState.ensembles should contain key((ensemble2 \ JSON_PATH.GUID).as[String])
+ orchState.ensembles.get((ensemble1 \ JSON_PATH.GUID).as[String]).get should equal(ensemble1ref)
+ orchState.ensembles.get((ensemble2 \ JSON_PATH.GUID).as[String]).get should equal(ensemble2ref)
+ }
}
val orch2Name = "TEST-ORCH-2"
- var orch2ref: ActorRef = _
- var orch2ens: ActorRef = _
+ var orch2ref: TestActorRef[Orchestration] = _
+ var orch2ensRef: ActorRef = _
val orchestration2Json = getJSValueFromString(Utils_JSONTest.orchestration_test_json)
val orch2ensembles = (orchestration2Json \ JSON_PATH.ENSEMBLES).as[List[JsObject]]
val orch2ensemble1 = orch2ensembles(0)
val monitor2 = TestProbe()
+ var orch2state:Orchestration = null
"Creating a second Orchestration" should {
s"result in sending START message to Monitor actor" in {
@@ -114,6 +133,10 @@ class OrchestrationSpec extends BaseAkkaSpec{
override val monitoring_actor = monitor2.ref
}), parent.ref, orch2Name)
monitor2.expectMsgClass(1.seconds, classOf[Monitor.START])
+ orch2state = orch2ref.underlyingActor
+ }
+ "result in empty Orchestration.ensembles state variable" in{
+ orch2state.ensembles shouldBe empty
}
"result in six paths added to IdentifyFeyActors.actorsPath" in{
globalIdentifierRef ! IdentifyFeyActors.IDENTIFY_TREE(parent.ref.path.toString)
@@ -131,11 +154,16 @@ class OrchestrationSpec extends BaseAkkaSpec{
"Sending Orchestration.CREATE_ENSEMBLES to the second Orchestration" should {
s"result in creation of Ensemble '${(orch2ensemble1 \ JSON_PATH.GUID).as[String]}'" in {
orch2ref ! Orchestration.CREATE_ENSEMBLES(orch2ensembles)
- orch2ens = TestProbe().expectActor(s"${orch2ref.path}/${(orch2ensemble1 \ JSON_PATH.GUID).as[String]}")
+ orch2ensRef = TestProbe().expectActor(s"${orch2ref.path}/${(orch2ensemble1 \ JSON_PATH.GUID).as[String]}")
}
s"result in creation of one Performers" in {
TestProbe().expectActor(s"${orch2ref.path}/${(orch2ensemble1 \ JSON_PATH.GUID).as[String]}/TEST-0001")
}
+ s"result in one entry in Orchestration.ensembles matching the craeted ensemble" in {
+ orch2state.ensembles should have size(1)
+ orch2state.ensembles should contain key((orch2ensemble1 \ JSON_PATH.GUID).as[String])
+ orch2state.ensembles.get((orch2ensemble1 \ JSON_PATH.GUID).as[String]).get should equal(orch2ensRef)
+ }
s"result in one entries in ORCHESTRATION_CACHE.orchestration_metadata for $orch2Name" in {
ORCHESTRATION_CACHE.orchestration_metadata should contain key(orch2Name)
ORCHESTRATION_CACHE.orchestration_metadata.get(orch2Name).get should have size(1)
@@ -164,7 +192,7 @@ class OrchestrationSpec extends BaseAkkaSpec{
"Sending Orchestration.DELETE_ENSEMBLES to the second Orchestration" should {
"result in termination of ensembles and the Orchestration itself" in {
orch2ref ! Orchestration.DELETE_ENSEMBLES(orch2ensembles)
- TestProbe().verifyActorTermination(orch2ens)
+ TestProbe().verifyActorTermination(orch2ensRef)
}
s"result in sending TERMINATED message to Monitor actor" in {
monitor2.expectMsgAllClassOf(classOf[Monitor.TERMINATE])
@@ -183,6 +211,9 @@ class OrchestrationSpec extends BaseAkkaSpec{
IdentifyFeyActors.actorsPath should contain(s"${parent.ref.path}/$orchName/MY-ENSEMBLE-0002/TEST-0001")
IdentifyFeyActors.actorsPath should contain(s"${parent.ref.path}/$orch2Name")
}
+ "result in empty state variable Orchestration.ensembles" in {
+ orch2state.ensembles shouldBe empty
+ }
}
"Stopping second Orchestration" should {
@@ -234,6 +265,5 @@ class OrchestrationSpec extends BaseAkkaSpec{
}
//TODO: Test restart
- //TODO: Test ensembles val in orchRef.underlyingActor
}