Esempio n. 1
0
 public void HeartBeat_SameNodeExceptionTest()
 {
     TaskNode node1 = new TaskNode("node1");
     TaskNode node2 = new TaskNode("node1");
     try
     {
         Thread.Sleep(15000);
         Assert.AreEqual(false, node2.IsAlive);
         node2.Shutdown();
     }
     finally
     {
         node2.Shutdown();
         node1.Shutdown();
     }
 }
Esempio n. 2
0
 public void InitializeTest()
 {
     TaskNode node = new TaskNode();
     try
     {
         using (ZooKeeper zk = TaskNode.GetShortSessionZk())
         {
             Assert.IsNotNull(zk.Exists(GloabalConfig.AppDataRoot, false));
             Assert.IsNotNull(zk.Exists(GloabalConfig.CommandsRoot, false));
             Assert.IsNotNull(zk.Exists(GloabalConfig.Scheduler, false));
             Assert.IsNotNull(zk.Exists(GloabalConfig.LockRoot, false));
             Assert.IsNotNull(zk.Exists(GloabalConfig.AppDataRoot, false));
         }
     }
     finally
     {
         node.Shutdown();
     }
 }
Esempio n. 3
0
 public void AcceptCommandTest()
 {
     TaskNode node1 = new TaskNode("node1");
     Chanel.SendCommand("node1", new CommandInfo { JobName = "job1", JobType = JobType.Exe, Path = "WildDogs.exe" });
     Chanel.SendCommand("node2", new CommandInfo { JobName = "job1", JobType = JobType.Exe, Path = "WildDogs.exe" });
     Chanel.SendCommand("node1", new CommandInfo { JobName = "job1", JobType = JobType.Exe, Path = "WildDogs.exe" });
     Chanel.SendCommand("node4", new CommandInfo { JobName = "job1", JobType = JobType.Exe, Path = "WildDogs.exe" });
     try
     {
         Thread.Sleep(3000);
         Assert.AreEqual(2, AppRuntime.Running.Count);
         using (ZooKeeper zk = TaskNode.GetShortSessionZk())
         {
             Assert.AreEqual(2, zk.GetChildren(GloabalConfig.CommandsRoot, false).Count());
         }
     }
     finally
     {
         node1.Shutdown();
     }
 }
Esempio n. 4
0
        public void MasterVoteTest()
        {
            TaskNode node1 = new TaskNode();
            TaskNode node2 = new TaskNode();
            TaskNode node3 = new TaskNode();
            TaskNode node4 = new TaskNode(); try
            {
                List<TaskNode> nodeList = new List<TaskNode>()
            {
                node2,
                node3,
                node4,
            };
                Thread.Sleep(3000);
                Assert.AreEqual(Role.Master.ToString(), node1.NodeRole);
                node1.Shutdown();

                Thread.Sleep(50000);
                Assert.IsTrue(nodeList.Exists(u => u.NodeRole == Role.Master.ToString()));
            }
            finally
            {
                node1.Shutdown();
                node2.Shutdown();
                node4.Shutdown();
                node3.Shutdown();
            }
        }
Esempio n. 5
0
        public void SubmitJobTest()
        {
            TaskNode node1 = new TaskNode();
            try
            {
                Chanel.SubmitJob("job1", "HelloWold.zip", "[* * * *]", new CommandInfo { JobType = JobType.Exe, Path = "WildDogs.exe" });

                using (ZooKeeper zk = TaskNode.GetShortSessionZk())
                {
                    var childrens = zk.GetChildren("/wilddogs/appdata/job1", false).ToList();
                    Assert.IsNotNull(childrens.Any(u => u.Contains("zip000000000")));
                }
            }
            finally
            {
                node1.Shutdown();
            }
        }
Esempio n. 6
0
        public void SendCommandTest()
        {
            TaskNode node1 = new TaskNode();
            try
            {
                Chanel.SendCommand("node1", new CommandInfo { JobType = JobType.Exe, Path = @"C:\Users\Lewis\Documents\GitHub\WildDogs\Java2DotNet.WildDogs\bin\Release\WildDogs.exe" });

                using (ZooKeeper zk = TaskNode.GetShortSessionZk())
                {
                    var childrens = zk.GetChildren("/wilddogs/commands", false).ToList();
                    Assert.IsNotNull(childrens.Any(u => u.Contains("node1")));
                }
            }
            finally
            {
                node1.Shutdown();
            }
        }
Esempio n. 7
0
 static void Main(string[] args)
 {
     TaskNode node = new TaskNode();
     Console.Read();
 }