Repository: reef Updated Branches: refs/heads/master e23b4ae43 -> 436496569
[REEF-1241] Configurations in ConfigurationProviders was dropped from JobSubmissionBuilder Add Configurations in ConfigurationProviders to driver configuration Add test cases JIRA: [REEF-1241](https://issues.apache.org/jira/browse/REEF-1241) Pull Request: Closes #880 Project: http://git-wip-us.apache.org/repos/asf/reef/repo Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/43649656 Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/43649656 Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/43649656 Branch: refs/heads/master Commit: 43649656990b358183751715befb4b4d037bb4bc Parents: e23b4ae Author: Julia Wang <[email protected]> Authored: Tue Mar 8 10:06:03 2016 -0800 Committer: Andrew Chung <[email protected]> Committed: Tue Mar 8 11:08:03 2016 -0800 ---------------------------------------------------------------------- .../JobRequestBuilderTests.cs | 72 ++++++++++++++++++++ .../Org.Apache.REEF.Client.Tests.csproj | 5 ++ .../API/AppParametersBuilder.cs | 4 ++ 3 files changed, 81 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/reef/blob/43649656/lang/cs/Org.Apache.REEF.Client.Tests/JobRequestBuilderTests.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client.Tests/JobRequestBuilderTests.cs b/lang/cs/Org.Apache.REEF.Client.Tests/JobRequestBuilderTests.cs new file mode 100644 index 0000000..d47d0f4 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Client.Tests/JobRequestBuilderTests.cs @@ -0,0 +1,72 @@ +// 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.Linq; +using Org.Apache.REEF.Client.API; +using Org.Apache.REEF.Tang.Implementations.Configuration; +using Org.Apache.REEF.Tang.Implementations.Tang; +using Org.Apache.REEF.Tang.Interface; +using Org.Apache.REEF.Tang.Util; +using Org.Apache.REEF.Wake.Remote.Parameters; +using Xunit; + +namespace Org.Apache.REEF.Client.Tests +{ + public class JobRequestBuilderTests + { + /// <summary> + /// This is to test the configurations set from the provider are added to driver configuration through jobRequestBuilder + /// </summary> + [Fact] + public void TestTcpProvider() + { + IConfiguration tcpPortConfig = TcpPortConfigurationModule.ConfigurationModule + .Set(TcpPortConfigurationModule.PortRangeStart, "2000") + .Set(TcpPortConfigurationModule.PortRangeCount, "20") + .Build(); + + var injector = TangFactory.GetTang().NewInjector(tcpPortConfig); + var jobRequestBuilder = injector.GetInstance<JobRequestBuilder>(); + var jobRequest = jobRequestBuilder.Build(); + var driverConfig = jobRequest.AppParameters.DriverConfigurations; + + var injector2 = TangFactory.GetTang().NewInjector(Configurations.Merge(driverConfig.ToArray())); + var portStart = injector2.GetNamedInstance<TcpPortRangeStart, int>(GenericType<TcpPortRangeStart>.Class); + var portRange = injector2.GetNamedInstance<TcpPortRangeCount, int>(GenericType<TcpPortRangeCount>.Class); + Assert.Equal(portStart, 2000); + Assert.Equal(portRange, 20); + } + + /// <summary> + /// This is to test the defaul configuration is used without provider + /// </summary> + [Fact] + public void TestTcpDefaultWithoutProvider() + { + var injector = TangFactory.GetTang().NewInjector(); + var jobRequestBuilder = injector.GetInstance<JobRequestBuilder>(); + var jobRequest = jobRequestBuilder.Build(); + var driverConfig = jobRequest.AppParameters.DriverConfigurations; + + var injector2 = TangFactory.GetTang().NewInjector(Configurations.Merge(driverConfig.ToArray())); + var portStart = injector2.GetNamedInstance<TcpPortRangeStart, int>(GenericType<TcpPortRangeStart>.Class); + var portRange = injector2.GetNamedInstance<TcpPortRangeCount, int>(GenericType<TcpPortRangeCount>.Class); + Assert.Equal(portStart, 8900); + Assert.Equal(portRange, 1000); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/reef/blob/43649656/lang/cs/Org.Apache.REEF.Client.Tests/Org.Apache.REEF.Client.Tests.csproj ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client.Tests/Org.Apache.REEF.Client.Tests.csproj b/lang/cs/Org.Apache.REEF.Client.Tests/Org.Apache.REEF.Client.Tests.csproj index 5888681..1d9e18a 100644 --- a/lang/cs/Org.Apache.REEF.Client.Tests/Org.Apache.REEF.Client.Tests.csproj +++ b/lang/cs/Org.Apache.REEF.Client.Tests/Org.Apache.REEF.Client.Tests.csproj @@ -49,6 +49,7 @@ under the License. </ItemGroup> <ItemGroup> <Compile Include="HDInsightYarnClientTests.cs" /> + <Compile Include="JobRequestBuilderTests.cs" /> <Compile Include="JobResourceUploaderTests.cs" /> <Compile Include="LegacyJobResourceUploaderTests.cs" /> <Compile Include="MultipleRMUrlProviderTests.cs" /> @@ -81,6 +82,10 @@ under the License. <Project>{A6BAA2A7-F52F-4329-884E-1BCF711D6805}</Project> <Name>Org.Apache.REEF.Driver</Name> </ProjectReference> + <ProjectReference Include="..\Org.Apache.REEF.Wake\Org.Apache.REEF.Wake.csproj"> + <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project> + <Name>Org.Apache.REEF.Wake</Name> + </ProjectReference> </ItemGroup> <ItemGroup> <None Include="packages.config" /> http://git-wip-us.apache.org/repos/asf/reef/blob/43649656/lang/cs/Org.Apache.REEF.Client/API/AppParametersBuilder.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client/API/AppParametersBuilder.cs b/lang/cs/Org.Apache.REEF.Client/API/AppParametersBuilder.cs index 0b12c5e..c81f004 100644 --- a/lang/cs/Org.Apache.REEF.Client/API/AppParametersBuilder.cs +++ b/lang/cs/Org.Apache.REEF.Client/API/AppParametersBuilder.cs @@ -154,6 +154,10 @@ namespace Org.Apache.REEF.Client.API /// </summary> public AppParameters Build() { + foreach (var conf in _configurationProviders) + { + _driverConfigurations.Add(conf.GetConfiguration()); + } return new AppParameters(_driverConfigurations, _globalAssemblies, _globalFiles, _localAssemblies, _localFiles, _driverConfigurationFileContents); }
