iota-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tonyfaust...@apache.org
Subject [08/12] incubator-iota git commit: [IOTA-36] Adding test to fey core
Date Tue, 31 Jan 2017 22:29:11 GMT
[IOTA-36] Adding test to fey core


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

Branch: refs/heads/master
Commit: a2e6fac1b64657d7edbb83cfac65853a95933759
Parents: 580e301
Author: Barbara Gomes <barbaramaltagomes@gmail.com>
Authored: Mon Jan 30 17:27:45 2017 -0800
Committer: Barbara Gomes <barbaramaltagomes@gmail.com>
Committed: Mon Jan 30 17:27:45 2017 -0800

----------------------------------------------------------------------
 .../scala/org/apache/iota/fey/FeyCore.scala     |  1 +
 .../scala/org/apache/iota/fey/FeyCoreSpec.scala | 64 ++++++++++++++++++++
 .../org/apache/iota/fey/Utils_JSONTest.scala    | 57 +++++++++++++++++
 3 files changed, 122 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a2e6fac1/fey-core/src/main/scala/org/apache/iota/fey/FeyCore.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/main/scala/org/apache/iota/fey/FeyCore.scala b/fey-core/src/main/scala/org/apache/iota/fey/FeyCore.scala
index 99dc7c4..5dc6f7d 100644
--- a/fey-core/src/main/scala/org/apache/iota/fey/FeyCore.scala
+++ b/fey-core/src/main/scala/org/apache/iota/fey/FeyCore.scala
@@ -102,6 +102,7 @@ protected class FeyCore extends Actor with ActorLogging{
     FEY_CACHE.activeOrchestrations.remove(actorRef.path.name)
     ORCHESTRATION_CACHE.orchestration_metadata.remove(actorRef.path.name)
     ORCHESTRATION_CACHE.orchestration_globals.remove(actorRef.path.name)
+    GlobalPerformer.activeGlobalPerformers.remove(actorRef.path.name)
     if(!FEY_CACHE.orchestrationsAwaitingTermination.isEmpty) {
       checkForOrchestrationWaitingForTermination(actorRef.path.name)
     }

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a2e6fac1/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 5ae55c2..927b87a 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
@@ -225,6 +225,70 @@ class FeyCoreSpec extends BaseAkkaSpec  {
     }
   }
 
+
+  val global_orch_name = "GLOBAL-PERFORMER"
+  var globalRef:ActorRef= null
+
+  "Sending FeyCore.ORCHESTRATION_RECEIVED with CREATE AND GLOBAL performer command to FeyCore"
should {
+    s"result in creating an Orchestration child actor with the name '$global_orch_name'"
in {
+      feyCoreRef ! FeyCore.ORCHESTRATION_RECEIVED(getJSValueFromString(Utils_JSONTest.global_perf_test),
None)
+      orchestrationref = TestProbe().expectActor(s"$feyPath/$global_orch_name")
+    }
+    s"result in creating an Ensemble child actor with the name '$global_orch_name/ENS-GLOBAL'"
in {
+      ensemble1ref = TestProbe().expectActor(s"$feyPath/$global_orch_name/ENS-GLOBAL")
+    }
+    s"result in creating a global Performer child actor with the name '$global_orch_name/GLOBAL_MANAGER/GLOBAL-TEST'"
in {
+      globalRef = TestProbe().expectActor(s"$feyPath/$global_orch_name/GLOBAL_MANAGER/GLOBAL-TEST")
+    }
+    s"result in creating a Performer child actor with the name '$global_orch_name/ENS-GLOBAL/PERFORMER-SCHEDULER'"
in {
+      ensemble2Test1ref = TestProbe().expectActor(s"$feyPath/$global_orch_name/ENS-GLOBAL/PERFORMER-SCHEDULER")
+    }
+    s"result in new entry to FEY_CACHE.activeOrchestrations with key '$global_orch_name'"
in {
+      FEY_CACHE.activeOrchestrations should contain key(global_orch_name)
+    }
+    s"result in one global actor created for orchestration" in {
+      GlobalPerformer.activeGlobalPerformers should have size(1)
+      GlobalPerformer.activeGlobalPerformers should contain key(global_orch_name)
+    }
+    s"result in globa metadata add to table" in {
+      ORCHESTRATION_CACHE.orchestration_globals should have size(1)
+      ORCHESTRATION_CACHE.orchestration_globals should contain key(global_orch_name)
+    }
+    s"result in right running actors" in {
+      globalIdentifierRef ! IdentifyFeyActors.IDENTIFY_TREE(feyCoreRef.path.toString)
+      Thread.sleep(500)
+      IdentifyFeyActors.actorsPath should contain(s"$feyPath/$global_orch_name")
+      IdentifyFeyActors.actorsPath should contain(s"$feyPath/$global_orch_name/GLOBAL_MANAGER")
+      IdentifyFeyActors.actorsPath should contain(s"$feyPath/$global_orch_name/GLOBAL_MANAGER/GLOBAL-TEST")
+      IdentifyFeyActors.actorsPath should contain(s"$feyPath/$global_orch_name/ENS-GLOBAL/PERFORMER-SCHEDULER")
+    }
+  }
+
+  "Stopping Global actor" should {
+    "result in sending logging error" in {
+      EventFilter.error(pattern = s".*DEAD Global Performer.*", occurrences = 1) intercept
{
+        globalRef ! PoisonPill
+      }
+    }
+    "result in orchestration restarted" in {
+      TestProbe().expectActor(s"$feyPath/$global_orch_name/GLOBAL_MANAGER/GLOBAL-TEST")
+      TestProbe().expectActor(s"$feyPath/$global_orch_name/ENS-GLOBAL/PERFORMER-SCHEDULER")
+      TestProbe().expectActor(s"$feyPath/$global_orch_name/ENS-GLOBAL")
+    }
+  }
+
+  "Stopping orchestration with global performer" should {
+    "result in sending TERMINATE message to Monitor actor" in {
+      orchestrationref ! PoisonPill
+      monitor.expectMsgClass(1.seconds, classOf[Monitor.TERMINATE])
+    }
+    "result in no global actors for orchestration" in {
+      GlobalPerformer.activeGlobalPerformers should have size(0)
+      ORCHESTRATION_CACHE.orchestration_globals should have size(0)
+      ORCHESTRATION_CACHE.orchestration_metadata should not contain key(global_orch_name)
+    }
+  }
+
   "Stopping FeyCore" should {
     "result in sending STOP message to Monitor actor" in {
       feyCoreRef ! PoisonPill

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a2e6fac1/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 106a406..a900df5 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
@@ -551,4 +551,61 @@ object Utils_JSONTest {
          }
        ]
      }"""
+
+
+  val global_perf_test =
+    """
+      {
+        "guid":"GLOBAL-PERFORMER",
+        "command":"RECREATE",
+        "timestamp":"12347896906",
+        "name":"recreate global",
+        "global-performers":[
+          {
+            "guid":"GLOBAL-TEST",
+            "schedule":0,
+            "backoff":1000,
+            "source":{
+              "name":"fey-test-actor.jar",
+              "classPath":"org.apache.iota.fey.TestActor",
+              "parameters":{
+                "param-1":"test",
+                "param-2":"test2"
+              }
+            }
+          }
+        ],
+        "ensembles":[
+          {
+            "guid":"ENS-GLOBAL",
+            "command":"NONE",
+            "performers":[
+              {
+                "guid":"PERFORMER-SCHEDULER",
+                "schedule":200,
+                "backoff":0,
+                "autoScale":{
+                  "lowerBound":4,
+                  "upperBound":6
+                },
+                "source":{
+                  "name":"fey-test-actor.jar",
+                  "classPath":"org.apache.iota.fey.TestActor",
+                  "parameters":{
+
+                  }
+                }
+              }
+            ],
+            "connections":[
+              {
+                "PERFORMER-SCHEDULER":[
+                  "GLOBAL-TEST"
+                ]
+              }
+            ]
+          }
+        ]
+      }
+    """
 }


Mime
View raw message