Repository: incubator-reef Updated Branches: refs/heads/master d07797442 -> 7824be835
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7824be83/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 c8dd6e3..77f3154 100644 --- a/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestBridgeClient.cs +++ b/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestBridgeClient.cs @@ -19,7 +19,7 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; -using Org.Apache.REEF.Examples.HelloCLRBridge; +using Org.Apache.REEF.Examples.AllHandlers; using Org.Apache.REEF.Utilities.Logging; namespace Org.Apache.REEF.Tests.Functional.Bridge @@ -63,7 +63,7 @@ namespace Org.Apache.REEF.Tests.Functional.Bridge { string testRuntimeFolder = DefaultRuntimeFolder + TestNumber++; string[] a = new[] { runOnYarn ? "yarn" : "local", testRuntimeFolder }; - ClrBridgeClient.Run(a); + AllHandlers.Run(a); ValidateSuccessForLocalRuntime(2, testRuntimeFolder); CleanUp(testRuntimeFolder); } http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7824be83/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestHelloBridgeHandlers.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestHelloBridgeHandlers.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestHelloBridgeHandlers.cs deleted file mode 100644 index 3e7c035..0000000 --- a/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestHelloBridgeHandlers.cs +++ /dev/null @@ -1,100 +0,0 @@ -/** - * 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 System.Collections.Generic; -using System.IO; -using System.Linq; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Org.Apache.REEF.Driver.Bridge; -using Org.Apache.REEF.Driver.Defaults; -using Org.Apache.REEF.Examples.HelloCLRBridge.Handlers; -using Org.Apache.REEF.Examples.Tasks.HelloTask; -using Org.Apache.REEF.Tang.Interface; -using Org.Apache.REEF.Tang.Util; -using Org.Apache.REEF.Utilities.Logging; - -namespace Org.Apache.REEF.Tests.Functional.Bridge -{ - [TestClass] - public class TestHelloBridgeHandlers : ReefFunctionalTest - { - [TestInitialize()] - public void TestSetup() - { - CleanUp(); - Init(); - } - - [TestCleanup] - public void TestCleanup() - { - Console.WriteLine("Post test check and clean up"); - CleanUp(); - } - - [TestMethod, Priority(1), TestCategory("FunctionalGated")] - [Description("Test Hello Handler on local runtime")] - [DeploymentItem(@".")] - [Timeout(180 * 1000)] - public void RunHelloHandlerOnLocalRuntime() - { - IsOnLocalRuntiime = true; - TestRun(AssembliesToCopy(), DriverConfiguration()); - ValidateSuccessForLocalRuntime(2); - ValidateEvaluatorSetting(); - } - - public IConfiguration DriverConfiguration() - { - return DriverBridgeConfiguration.ConfigurationModule - .Set(DriverBridgeConfiguration.OnDriverStarted, GenericType<HelloStartHandler>.Class) - .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<HelloAllocatedEvaluatorHandler>.Class) - .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<AnotherHelloAllocatedEvaluatorHandler>.Class) - .Set(DriverBridgeConfiguration.OnContextActive, GenericType<HelloActiveContextHandler>.Class) - .Set(DriverBridgeConfiguration.OnTaskMessage, GenericType<HelloTaskMessageHandler>.Class) - .Set(DriverBridgeConfiguration.OnEvaluatorFailed, GenericType<HelloFailedEvaluatorHandler>.Class) - .Set(DriverBridgeConfiguration.OnTaskFailed, GenericType<HelloFailedTaskHandler>.Class) - .Set(DriverBridgeConfiguration.OnTaskRunning, GenericType<HelloRunningTaskHandler>.Class) - .Set(DriverBridgeConfiguration.OnEvaluatorRequested, GenericType<HelloEvaluatorRequestorHandler>.Class) - .Set(DriverBridgeConfiguration.OnHttpEvent, GenericType<HelloHttpHandler>.Class) - .Set(DriverBridgeConfiguration.OnEvaluatorCompleted, GenericType<HelloCompletedEvaluatorHandler>.Class) - .Set(DriverBridgeConfiguration.CustomTraceListeners, GenericType<DefaultCustomTraceListener>.Class) - .Set(DriverBridgeConfiguration.CustomTraceLevel, Level.Info.ToString()) - .Set(DriverBridgeConfiguration.CommandLineArguments, "submitContextAndTask") - .Build(); - } - - public HashSet<string> AssembliesToCopy() - { - HashSet<string> appDlls = new HashSet<string>(); - appDlls.Add(typeof(HelloStartHandler).Assembly.GetName().Name); - appDlls.Add(typeof(HelloTask).Assembly.GetName().Name); - return appDlls; - } - - private void ValidateEvaluatorSetting() - { - const string successIndication = "Evaluator is assigned with 512 MB of memory and 2 cores."; - string[] lines = File.ReadAllLines(GetLogFile(_stdout)); - string[] successIndicators = lines.Where(s => s.Contains(successIndication)).ToArray(); - Assert.IsTrue(successIndicators.Count() >= 1); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7824be83/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 71091e7..eac060f 100644 --- a/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestSimpleEventHandlers.cs +++ b/lang/cs/Org.Apache.REEF.Tests/Functional/Bridge/TestSimpleEventHandlers.cs @@ -18,16 +18,15 @@ */ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; -using Org.Apache.REEF.Common.Evaluator; using Org.Apache.REEF.Driver.Bridge; using Org.Apache.REEF.Driver.Defaults; -using Org.Apache.REEF.Examples.HelloCLRBridge.Handlers; +using Org.Apache.REEF.Examples.AllHandlers; using Org.Apache.REEF.Examples.Tasks.HelloTask; using Org.Apache.REEF.Network.Naming; +using Org.Apache.REEF.Tang.Implementations.Tang; using Org.Apache.REEF.Tang.Interface; using Org.Apache.REEF.Tang.Util; using Org.Apache.REEF.Utilities.Logging; @@ -40,69 +39,54 @@ namespace Org.Apache.REEF.Tests.Functional.Bridge [TestInitialize()] public void TestSetup() { - CleanUp(); Init(); } - [TestCleanup] - public void TestCleanup() - { - Console.WriteLine("Post test check and clean up"); - CleanUp(); - } - - //[TestMethod, Priority(1), TestCategory("FunctionalGated")] + [TestMethod, Priority(1), TestCategory("FunctionalGated")] [Description("Test Hello Handler on local runtime")] [DeploymentItem(@".")] [Timeout(180 * 1000)] public void RunSimpleEventHandlerOnLocalRuntime() { - IsOnLocalRuntiime = true; - TestRun(AssembliesToCopy(), DriverConfiguration()); - ValidateSuccessForLocalRuntime(2); - ValidateEvaluatorSetting(); + string testFolder = DefaultRuntimeFolder + TestNumber++; + TestRun(DriverConfiguration(), typeof(HelloSimpleEventHandlers), "simpleHandler", "local", testFolder); + ValidateSuccessForLocalRuntime(1, testFolder); + ValidateEvaluatorSetting(testFolder); + CleanUp(testFolder); } public IConfiguration DriverConfiguration() { - return DriverBridgeConfiguration.ConfigurationModule - .Set(DriverBridgeConfiguration.OnDriverStarted, GenericType<HelloSimpleEventHandlers>.Class) - .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<HelloSimpleEventHandlers>.Class) - .Set(DriverBridgeConfiguration.OnEvaluatorAllocated, GenericType<AnotherHelloAllocatedEvaluatorHandler>.Class) - .Set(DriverBridgeConfiguration.OnContextActive, GenericType<HelloSimpleEventHandlers>.Class) - .Set(DriverBridgeConfiguration.OnTaskMessage, GenericType<HelloTaskMessageHandler>.Class) - .Set(DriverBridgeConfiguration.OnEvaluatorFailed, GenericType<HelloSimpleEventHandlers>.Class) - .Set(DriverBridgeConfiguration.OnTaskCompleted, GenericType<HelloSimpleEventHandlers>.Class) - .Set(DriverBridgeConfiguration.OnTaskFailed, GenericType<HelloSimpleEventHandlers>.Class) - .Set(DriverBridgeConfiguration.OnTaskRunning, GenericType<HelloSimpleEventHandlers>.Class) - .Set(DriverBridgeConfiguration.OnEvaluatorRequested, GenericType<HelloSimpleEventHandlers>.Class) - .Set(DriverBridgeConfiguration.OnHttpEvent, GenericType<HelloSimpleEventHandlers>.Class) - .Set(DriverBridgeConfiguration.OnEvaluatorCompleted, GenericType<HelloSimpleEventHandlers>.Class) - .Set(DriverBridgeConfiguration.CustomTraceListeners, GenericType<DefaultCustomTraceListener>.Class) - .Set(DriverBridgeConfiguration.CustomTraceLevel, Level.Info.ToString()) - .Set(DriverBridgeConfiguration.CommandLineArguments, "submitContextAndTask") - .Set(DriverBridgeConfiguration.OnDriverRestarted, GenericType<HelloRestartHandler>.Class) - .Set(DriverBridgeConfiguration.OnDriverReconnect, GenericType<DefaultLocalHttpDriverConnection>.Class) - .Set(DriverBridgeConfiguration.OnDirverRestartContextActive, GenericType<HelloDriverRestartActiveContextHandler>.Class) - .Set(DriverBridgeConfiguration.OnDriverRestartTaskRunning, GenericType<HelloDriverRestartRunningTaskHandler>.Class) + var helloDriverConfiguration = REEF.Driver.DriverConfiguration.ConfigurationModule + .Set(REEF.Driver.DriverConfiguration.OnDriverStarted, GenericType<HelloSimpleEventHandlers>.Class) + .Set(REEF.Driver.DriverConfiguration.OnEvaluatorAllocated, GenericType<HelloSimpleEventHandlers>.Class) + .Set(REEF.Driver.DriverConfiguration.OnContextActive, GenericType<HelloSimpleEventHandlers>.Class) + .Set(REEF.Driver.DriverConfiguration.OnTaskMessage, GenericType<HelloTaskMessageHandler>.Class) + .Set(REEF.Driver.DriverConfiguration.OnEvaluatorFailed, GenericType<HelloSimpleEventHandlers>.Class) + .Set(REEF.Driver.DriverConfiguration.OnTaskCompleted, GenericType<HelloSimpleEventHandlers>.Class) + .Set(REEF.Driver.DriverConfiguration.OnTaskFailed, GenericType<HelloSimpleEventHandlers>.Class) + .Set(REEF.Driver.DriverConfiguration.OnTaskRunning, GenericType<HelloSimpleEventHandlers>.Class) + .Set(REEF.Driver.DriverConfiguration.OnHttpEvent, GenericType<HelloSimpleEventHandlers>.Class) + .Set(REEF.Driver.DriverConfiguration.OnEvaluatorCompleted, GenericType<HelloSimpleEventHandlers>.Class) + .Set(REEF.Driver.DriverConfiguration.CustomTraceListeners, GenericType<DefaultCustomTraceListener>.Class) + .Set(REEF.Driver.DriverConfiguration.CustomTraceLevel, Level.Info.ToString()) + .Set(REEF.Driver.DriverConfiguration.CommandLineArguments, "submitContextAndTask") .Build(); - } - public HashSet<string> AssembliesToCopy() - { - HashSet<string> appDlls = new HashSet<string>(); - appDlls.Add(typeof(HelloSimpleEventHandlers).Assembly.GetName().Name); - appDlls.Add(typeof(HelloTask).Assembly.GetName().Name); - appDlls.Add(typeof(INameServer).Assembly.GetName().Name); - return appDlls; + return TangFactory.GetTang().NewConfigurationBuilder(helloDriverConfiguration) + .BindSetEntry<DriverBridgeConfigurationOptions.SetOfAssemblies, string>(typeof(HelloTask).Assembly.GetName().Name) + .BindSetEntry<DriverBridgeConfigurationOptions.SetOfAssemblies, string>(typeof(NameClient).Assembly.GetName().Name) + .BindNamedParameter<IsRetain, bool>(GenericType<IsRetain>.Class, "false") + .BindNamedParameter<NumberOfEvaluators, Int32>(GenericType<NumberOfEvaluators>.Class, "1") + .Build(); } - private void ValidateEvaluatorSetting() + private void ValidateEvaluatorSetting(string testFolder) { - const string successIndication = "Evaluator is assigned with 512 MB of memory and 2 cores."; - string[] lines = File.ReadAllLines(GetLogFile(_stdout)); + const string successIndication = "Evaluator is assigned with 3072 MB of memory and 1 cores."; + string[] lines = File.ReadAllLines(GetLogFile(_stdout, testFolder)); string[] successIndicators = lines.Where(s => s.Contains(successIndication)).ToArray(); - Assert.IsTrue(successIndicators.Count() >= 1); + Assert.IsTrue(successIndicators.Any()); } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7824be83/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 adf9909..a517540 100644 --- a/lang/cs/Org.Apache.REEF.Tests/Functional/ReefFunctionalTest.cs +++ b/lang/cs/Org.Apache.REEF.Tests/Functional/ReefFunctionalTest.cs @@ -28,8 +28,13 @@ using System.Timers; using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.WindowsAzure.Storage; using Microsoft.WindowsAzure.Storage.Blob; +using Org.Apache.REEF.Client.API; +using Org.Apache.REEF.Client.Local; +using Org.Apache.REEF.Client.YARN; using Org.Apache.REEF.Driver; using Org.Apache.REEF.Driver.Bridge; +using Org.Apache.REEF.Examples.AllHandlers; +using Org.Apache.REEF.Tang.Implementations.Tang; using Org.Apache.REEF.Tang.Interface; using Org.Apache.REEF.Utilities; using Org.Apache.REEF.Utilities.Diagnostics; @@ -48,6 +53,9 @@ namespace Org.Apache.REEF.Tests.Functional protected static int TestNumber = 1; protected const string DefaultRuntimeFolder = "REEF_LOCAL_RUNTIME"; + private const string Local = "local"; + private const string YARN = "yarn"; + private readonly static Logger Logger = Logger.GetLogger(typeof(ReefFunctionalTest)); private const string StorageAccountKeyEnvironmentVariable = "REEFTestStorageAccountKey"; private const string StorageAccountNameEnvironmentVariable = "REEFTestStorageAccountName"; @@ -241,5 +249,36 @@ namespace Org.Apache.REEF.Tests.Functional } return result; } + + protected void TestRun(IConfiguration driverCondig, Type globalAssemblyType, string jobIdentifier = "myDriver", string runOnYarn = "local", string runtimeFolder = DefaultRuntimeFolder) + { + IInjector injector = TangFactory.GetTang().NewInjector(GetRuntimeConfiguration(runOnYarn, runtimeFolder)); + var reefClient = injector.GetInstance<IREEFClient>(); + var jobSubmissionBuilderFactory = injector.GetInstance<JobSubmissionBuilderFactory>(); + var jobSubmission = jobSubmissionBuilderFactory.GetJobSubmissionBuilder() + .AddDriverConfiguration(driverCondig) + .AddGlobalAssemblyForType(globalAssemblyType) + .SetJobIdentifier(jobIdentifier) + .Build(); + + reefClient.Submit(jobSubmission); + } + + private IConfiguration GetRuntimeConfiguration(string runOnYarn, string runtimeFolder) + { + switch (runOnYarn) + { + case Local: + var dir = Path.Combine(".", runtimeFolder); + return LocalRuntimeClientConfiguration.ConfigurationModule + .Set(LocalRuntimeClientConfiguration.NumberOfEvaluators, "2") + .Set(LocalRuntimeClientConfiguration.RuntimeFolder, dir) + .Build(); + case YARN: + return YARNClientConfiguration.ConfigurationModule.Build(); + default: + throw new Exception("Unknown runtime: " + runOnYarn); + } + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7824be83/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 ba69f97..1dc5182 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,8 +49,8 @@ under the License. <ItemGroup> <Compile Include="Evaluator\EvaluatorConfigurationsTests.cs" /> <Compile Include="Evaluator\EvaluatorTests.cs" /> + <Compile Include="Functional\Bridge\HelloSimpleEventHandlers.cs" /> <Compile Include="Functional\Bridge\TestBridgeClient.cs" /> - <Compile Include="Functional\Bridge\TestHelloBridgeHandlers.cs" /> <Compile Include="Functional\Bridge\TestSimpleEventHandlers.cs" /> <Compile Include="Functional\Driver\DriverTestStartHandler.cs" /> <Compile Include="Functional\Driver\TestDriver.cs" /> @@ -120,9 +120,9 @@ under the License. <Project>{b1b43b60-ddd0-4805-a9b4-ba84a0ccb7c7}</Project> <Name>Org.Apache.REEF.Network.Examples</Name> </ProjectReference> - <ProjectReference Include="$(SolutionDir)\Org.Apache.REEF.Examples.HelloCLRBridge\Org.Apache.REEF.Examples.HelloCLRBridge.csproj"> + <ProjectReference Include="$(SolutionDir)\Org.Apache.REEF.Examples.AllHandlers\Org.Apache.REEF.Examples.AllHandlers.csproj"> <Project>{159f7d70-8acc-4d97-9f6d-2fc4ca0d8682}</Project> - <Name>Org.Apache.REEF.Examples.HelloCLRBridge</Name> + <Name>Org.Apache.REEF.Examples.AllHandlers</Name> </ProjectReference> </ItemGroup> <ItemGroup> http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/7824be83/lang/cs/Org.Apache.REEF.sln ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.sln b/lang/cs/Org.Apache.REEF.sln index 63afdb0..21cb979 100644 Binary files a/lang/cs/Org.Apache.REEF.sln and b/lang/cs/Org.Apache.REEF.sln differ
