You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by do...@apache.org on 2015/11/18 07:18:19 UTC

incubator-reef git commit: [REEF-915] Create tests for FailedEvaluatorHandler

Repository: incubator-reef
Updated Branches:
  refs/heads/master afdedaf8b -> 2c3d35955


[REEF-915] Create tests for FailedEvaluatorHandler

JIRA:
  [REEF-915](https://issues.apache.org/jira/browse/REEF-915)

Pull request:
  This closes #650


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

Branch: refs/heads/master
Commit: 2c3d35955b2f921848d133e8b647f37458c5aa12
Parents: afdedaf
Author: Andrew Chung <af...@gmail.com>
Authored: Tue Nov 17 17:28:41 2015 -0800
Committer: Dongjoon Hyun <do...@apache.org>
Committed: Wed Nov 18 15:16:09 2015 +0900

----------------------------------------------------------------------
 .../Functional/Bridge/TestBridgeClient.cs       |   2 +-
 .../Bridge/TestFailedEvaluatorEventHandler.cs   | 126 +++++++++++++++++++
 .../Bridge/TestSimpleEventHandlers.cs           |   2 +-
 .../Functional/Driver/TestDriver.cs             |   2 +-
 .../Functional/Group/BroadcastReduceTest.cs     |   2 +-
 .../Group/PipelinedBroadcastReduceTest.cs       |   2 +-
 .../Functional/Group/ScatterReduceTest.cs       |   2 +-
 .../Functional/ML/KMeans/TestKMeans.cs          |   2 +-
 .../Functional/Messaging/TestTaskMessage.cs     |   2 +-
 .../Functional/ReefFunctionalTest.cs            |  12 +-
 .../Org.Apache.REEF.Tests.csproj                |   1 +
 11 files changed, 141 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestBridgeClient.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestBridgeClient.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestBridgeClient.cs
index a9be497..2a63697 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestBridgeClient.cs
+++ b/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestBridgeClient.cs
@@ -74,7 +74,7 @@ namespace Org.Apache.REEF.Tests.Functional.Bridge
 
             await ((JobSubmissionResult)driverHttpEndpoint).TryUntilNoConnection(uri);
 
-            ValidateSuccessForLocalRuntime(2, testRuntimeFolder);
+            ValidateSuccessForLocalRuntime(2, testFolder: testRuntimeFolder);
 
             CleanUp(testRuntimeFolder);
         }

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestFailedEvaluatorEventHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestFailedEvaluatorEventHandler.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestFailedEvaluatorEventHandler.cs
new file mode 100644
index 0000000..23e2217
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestFailedEvaluatorEventHandler.cs
@@ -0,0 +1,126 @@
+/**
+ * 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.
+ */
+
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Org.Apache.REEF.Common.Tasks;
+using Org.Apache.REEF.Driver;
+using Org.Apache.REEF.Driver.Bridge;
+using Org.Apache.REEF.Driver.Evaluator;
+using Org.Apache.REEF.Tang.Annotations;
+using Org.Apache.REEF.Tang.Implementations.Tang;
+using Org.Apache.REEF.Tang.Interface;
+using Org.Apache.REEF.Tang.Util;
+
+namespace Org.Apache.REEF.Tests.Functional.Bridge
+{
+    [TestClass]
+    public sealed class TestFailedEvaluatorEventHandler : ReefFunctionalTest
+    {
+        [TestInitialize]
+        public void TestSetup()
+        {
+            Init();
+        }
+
+        [TestMethod, Priority(1), TestCategory("FunctionalGated")]
+        [Description("Test invocation of FailedEvaluatorHandler")]
+        [DeploymentItem(@".")]
+        [Timeout(180 * 1000)]
+        public void TestFailedEvaluatorEventHandlerOnLocalRuntime()
+        {
+            string testFolder = DefaultRuntimeFolder + Guid.NewGuid().ToString("N").Substring(0, 4);
+            CleanUp(testFolder);
+            TestRun(DriverConfigurations(), typeof(FailedEvaluatorDriver), 1, "failedEvaluatorTest", "local", testFolder);
+            ValidateSuccessForLocalRuntime(0, numberOfEvaluatorsToFail: 1, testFolder: testFolder);
+            CleanUp(testFolder);
+        }
+
+        public IConfiguration DriverConfigurations()
+        {
+            var driverConfig = DriverConfiguration.ConfigurationModule
+                .Set(DriverConfiguration.OnDriverStarted, GenericType<FailedEvaluatorDriver>.Class)
+                .Set(DriverConfiguration.OnEvaluatorAllocated, GenericType<FailedEvaluatorDriver>.Class)
+                .Set(DriverConfiguration.OnEvaluatorCompleted, GenericType<FailedEvaluatorDriver>.Class)
+                .Build();
+
+            return TangFactory.GetTang().NewConfigurationBuilder(driverConfig)
+                .BindSetEntry<DriverBridgeConfigurationOptions.SetOfAssemblies, string>(typeof(FailEvaluatorTask).Assembly.GetName().Name)
+                .Build();
+        }
+
+        private sealed class FailedEvaluatorDriver : IObserver<IDriverStarted>, IObserver<IAllocatedEvaluator>, IObserver<ICompletedEvaluator>
+        {
+            private readonly IEvaluatorRequestor _requestor;
+
+            [Inject]
+            private FailedEvaluatorDriver(IEvaluatorRequestor requestor)
+            {
+                _requestor = requestor;
+            }
+
+            public void OnNext(IDriverStarted value)
+            {
+                _requestor.Submit(_requestor.NewBuilder().Build());
+            }
+
+            public void OnNext(IAllocatedEvaluator value)
+            {
+                value.SubmitTask(TaskConfiguration.ConfigurationModule
+                    .Set(TaskConfiguration.Identifier, "1234567")
+                    .Set(TaskConfiguration.Task, GenericType<FailEvaluatorTask>.Class)
+                    .Build());
+            }
+
+            public void OnNext(ICompletedEvaluator value)
+            {
+                throw new Exception("Did not expecte completed evaluator.");
+            }
+
+            public void OnError(Exception error)
+            {
+                throw new NotImplementedException();
+            }
+
+            public void OnCompleted()
+            {
+                throw new NotImplementedException();
+            }
+        }
+
+        private sealed class FailEvaluatorTask : ITask
+        {
+            [Inject]
+            private FailEvaluatorTask()
+            {
+            }
+
+            public void Dispose()
+            {
+                throw new NotImplementedException();
+            }
+
+            public byte[] Call(byte[] memento)
+            {
+                Environment.Exit(1);
+                return null;
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestSimpleEventHandlers.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestSimpleEventHandlers.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestSimpleEventHandlers.cs
index 380e72f..0f8944f 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestSimpleEventHandlers.cs
+++ b/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestSimpleEventHandlers.cs
@@ -51,7 +51,7 @@ namespace Org.Apache.REEF.Tests.Functional.Bridge
             string testFolder = DefaultRuntimeFolder + Guid.NewGuid().ToString("N").Substring(0, 4);
             CleanUp(testFolder);
             TestRun(DriverConfigurations(), typeof(HelloSimpleEventHandlers), 2, "simpleHandler", "local", testFolder);
-            ValidateSuccessForLocalRuntime(1, testFolder);
+            ValidateSuccessForLocalRuntime(1, testFolder: testFolder);
             ValidateEvaluatorSetting(testFolder);
             CleanUp(testFolder);
         }

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Functional/Driver/TestDriver.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/Driver/TestDriver.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/Driver/TestDriver.cs
index 02e5b3d..8af9d6f 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Functional/Driver/TestDriver.cs
+++ b/lang/cs/Org.Apache.REEF.Tests/Functional/Driver/TestDriver.cs
@@ -55,7 +55,7 @@ namespace Org.Apache.REEF.Tests.Functional.Driver
             string testFolder = DefaultRuntimeFolder + TestNumber++;
             CleanUp(testFolder);
             TestRun(DriverConfigurations(), typeof(DriverTestStartHandler), 0, "DriverTestStartHandler", "local", testFolder);
-            ValidateSuccessForLocalRuntime(0, testFolder);
+            ValidateSuccessForLocalRuntime(0, testFolder: testFolder);
         }
 
         public IConfiguration DriverConfigurations()

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Functional/Group/BroadcastReduceTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/Group/BroadcastReduceTest.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/Group/BroadcastReduceTest.cs
index 7119ffb..94a8b18 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Functional/Group/BroadcastReduceTest.cs
+++ b/lang/cs/Org.Apache.REEF.Tests/Functional/Group/BroadcastReduceTest.cs
@@ -55,7 +55,7 @@ namespace Org.Apache.REEF.Tests.Functional.Group
             string testFolder = DefaultRuntimeFolder + TestNumber++;
             CleanUp(testFolder);
             TestBroadcastAndReduce(false, numTasks, testFolder);
-            ValidateSuccessForLocalRuntime(numTasks, testFolder);
+            ValidateSuccessForLocalRuntime(numTasks, testFolder: testFolder);
         }
 
         [Ignore]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Functional/Group/PipelinedBroadcastReduceTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/Group/PipelinedBroadcastReduceTest.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/Group/PipelinedBroadcastReduceTest.cs
index 0be72e3..9eef5f7 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Functional/Group/PipelinedBroadcastReduceTest.cs
+++ b/lang/cs/Org.Apache.REEF.Tests/Functional/Group/PipelinedBroadcastReduceTest.cs
@@ -55,7 +55,7 @@ namespace Org.Apache.REEF.Tests.Functional.Group
             string testFolder = DefaultRuntimeFolder + TestNumber++;
             CleanUp(testFolder);
             TestBroadcastAndReduce(false, numTasks, testFolder);
-            ValidateSuccessForLocalRuntime(numTasks, testFolder);
+            ValidateSuccessForLocalRuntime(numTasks, testFolder: testFolder);
         }
 
         [Ignore]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Functional/Group/ScatterReduceTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/Group/ScatterReduceTest.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/Group/ScatterReduceTest.cs
index 0404cfb..9201330 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Functional/Group/ScatterReduceTest.cs
+++ b/lang/cs/Org.Apache.REEF.Tests/Functional/Group/ScatterReduceTest.cs
@@ -55,7 +55,7 @@ namespace Org.Apache.REEF.Tests.Functional.Group
             string testFolder = DefaultRuntimeFolder + TestNumber++;
             CleanUp(testFolder);
             TestScatterAndReduce(false, numTasks, testFolder);
-            ValidateSuccessForLocalRuntime(numTasks, testFolder);
+            ValidateSuccessForLocalRuntime(numTasks, testFolder: testFolder);
         }
 
         [Ignore]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Functional/ML/KMeans/TestKMeans.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/ML/KMeans/TestKMeans.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/ML/KMeans/TestKMeans.cs
index 9c3d043..9045e6a 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Functional/ML/KMeans/TestKMeans.cs
+++ b/lang/cs/Org.Apache.REEF.Tests/Functional/ML/KMeans/TestKMeans.cs
@@ -130,7 +130,7 @@ namespace Org.Apache.REEF.Tests.Functional.ML.KMeans
             string testFolder = DefaultRuntimeFolder + TestNumber++;
             CleanUp(testFolder);
             TestRun(DriverConfiguration(), typeof(KMeansDriverHandlers), Partitions + 1, "KMeansDriverHandlers", "local", testFolder);
-            ValidateSuccessForLocalRuntime(Partitions + 1, testFolder);
+            ValidateSuccessForLocalRuntime(Partitions + 1, testFolder: testFolder);
         }
 
         [TestMethod, Priority(1), TestCategory("FunctionalGated")]

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Functional/Messaging/TestTaskMessage.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/Messaging/TestTaskMessage.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/Messaging/TestTaskMessage.cs
index 009c1eb..154fb8e 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Functional/Messaging/TestTaskMessage.cs
+++ b/lang/cs/Org.Apache.REEF.Tests/Functional/Messaging/TestTaskMessage.cs
@@ -59,7 +59,7 @@ namespace Org.Apache.REEF.Tests.Functional.Messaging
             string testFolder = DefaultRuntimeFolder + TestNumber++;
             CleanUp(testFolder);
             TestRun(DriverConfigurations(), typeof(MessageDriver), 1, "simpleHandler", "local", testFolder);
-            ValidateSuccessForLocalRuntime(1, testFolder);
+            ValidateSuccessForLocalRuntime(1, testFolder: testFolder);
             CleanUp(testFolder);
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Functional/ReefFunctionalTest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/ReefFunctionalTest.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/ReefFunctionalTest.cs
index ec15dca..50f8799 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Functional/ReefFunctionalTest.cs
+++ b/lang/cs/Org.Apache.REEF.Tests/Functional/ReefFunctionalTest.cs
@@ -135,11 +135,11 @@ namespace Org.Apache.REEF.Tests.Functional
             }   
         }
 
-        protected void ValidateSuccessForLocalRuntime(int numberOfEvaluatorsToClose, string testFolder = DefaultRuntimeFolder)
+        protected void ValidateSuccessForLocalRuntime(int numberOfEvaluatorsToClose, int numberOfTasksToFail = 0, int numberOfEvaluatorsToFail = 0, string testFolder = DefaultRuntimeFolder)
         {
             const string successIndication = "EXIT: ActiveContextClr2Java::Close";
-            const string failedTaskIndication = "Java_com_microsoft_reef_javabridge_NativeInterop_clrSystemFailedTaskHandlerOnNext";
-            const string failedEvaluatorIndication = "Java_com_microsoft_reef_javabridge_NativeInterop_clrSystemFailedEvaluatorHandlerOnNext";
+            const string failedTaskIndication = "Java_org_apache_reef_javabridge_NativeInterop_clrSystemFailedTaskHandlerOnNext";
+            const string failedEvaluatorIndication = "Java_org_apache_reef_javabridge_NativeInterop_clrSystemFailedEvaluatorHandlerOnNext";
             string[] lines = null;
             for (int i = 0; i < 60; i++)
             {
@@ -160,9 +160,9 @@ namespace Org.Apache.REEF.Tests.Functional
                 string[] successIndicators = lines.Where(s => s.Contains(successIndication)).ToArray();
                 string[] failedTaskIndicators = lines.Where(s => s.Contains(failedTaskIndication)).ToArray();
                 string[] failedIndicators = lines.Where(s => s.Contains(failedEvaluatorIndication)).ToArray();
-                Assert.IsTrue(successIndicators.Count() == numberOfEvaluatorsToClose);
-                Assert.IsFalse(failedTaskIndicators.Any());
-                Assert.IsFalse(failedIndicators.Any());
+                Assert.AreEqual(numberOfEvaluatorsToClose, successIndicators.Length);
+                Assert.AreEqual(numberOfTasksToFail * 3, failedTaskIndicators.Length);
+                Assert.AreEqual(numberOfEvaluatorsToFail * 3, failedIndicators.Length);
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2c3d3595/lang/cs/Org.Apache.REEF.Tests/Org.Apache.REEF.Tests.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Org.Apache.REEF.Tests.csproj b/lang/cs/Org.Apache.REEF.Tests/Org.Apache.REEF.Tests.csproj
index 04a56e0..398dac3 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Org.Apache.REEF.Tests.csproj
+++ b/lang/cs/Org.Apache.REEF.Tests/Org.Apache.REEF.Tests.csproj
@@ -49,6 +49,7 @@ under the License.
   <ItemGroup>
     <Compile Include="Functional\Bridge\HelloSimpleEventHandlers.cs" />
     <Compile Include="Functional\Bridge\TestBridgeClient.cs" />
+    <Compile Include="Functional\Bridge\TestFailedEvaluatorEventHandler.cs" />
     <Compile Include="Functional\Bridge\TestSimpleEventHandlers.cs" />
     <Compile Include="Functional\Driver\DriverTestStartHandler.cs" />
     <Compile Include="Functional\Driver\TestDriver.cs" />