Repository: reef Updated Branches: refs/heads/master 12decb734 -> 9e19eeaf4
[REEF-1033] Migrate Org.Apache.REEF.Client.Tests to xUnit This change: * creates attribute which checks whether Hadoop services are available on the machine and skips the test if they are not * migrates O.A.R.Client.Tests to xUnit JIRA: [REEF-1033](https://issues.apache.org/jira/browse/REEF-1033) Pull request: This closes #804 Project: http://git-wip-us.apache.org/repos/asf/reef/repo Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/9e19eeaf Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/9e19eeaf Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/9e19eeaf Branch: refs/heads/master Commit: 9e19eeaf484c9adfe8f3eea074f1f59b4e34fd96 Parents: 12decb7 Author: Mariia Mykhailova <[email protected]> Authored: Thu Jan 28 18:00:16 2016 -0800 Committer: Markus Weimer <[email protected]> Committed: Fri Jan 29 14:14:47 2016 -0800 ---------------------------------------------------------------------- .../JobResourceUploaderTests.cs | 17 ++- .../LegacyJobResourceUploaderTests.cs | 20 ++-- .../MultipleRMUrlProviderTests.cs | 22 ++-- .../WindowsHadoopEmulatorYarnClientTests.cs | 115 ++++++++++--------- .../WindowsYarnJobCommandProviderTests.cs | 23 ++-- .../YarnClientTests.cs | 27 +++-- .../YarnConfigurationUrlProviderTests.cs | 34 +++--- 7 files changed, 129 insertions(+), 129 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/reef/blob/9e19eeaf/lang/cs/Org.Apache.REEF.Client.Tests/JobResourceUploaderTests.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client.Tests/JobResourceUploaderTests.cs b/lang/cs/Org.Apache.REEF.Client.Tests/JobResourceUploaderTests.cs index 66202ef..e5a6113 100644 --- a/lang/cs/Org.Apache.REEF.Client.Tests/JobResourceUploaderTests.cs +++ b/lang/cs/Org.Apache.REEF.Client.Tests/JobResourceUploaderTests.cs @@ -16,7 +16,6 @@ // under the License. using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Org.Apache.REEF.Client.Common; using Org.Apache.REEF.Client.Yarn; @@ -24,10 +23,10 @@ using Org.Apache.REEF.Client.YARN.RestClient; using Org.Apache.REEF.IO.FileSystem; using Org.Apache.REEF.Tang.Implementations.Tang; using Org.Apache.REEF.Tang.Util; +using Xunit; namespace Org.Apache.REEF.Client.Tests { - [TestClass] public class JobResourceUploaderTests { private const string AnyDriverLocalFolderPath = @"Any\Local\Folder\Path\"; @@ -41,13 +40,13 @@ namespace Org.Apache.REEF.Client.Tests private const long AnyResourceSize = 53092; private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0); - [TestMethod] + [Fact] public void JobResourceUploaderCanInstantiateWithDefaultBindings() { TangFactory.GetTang().NewInjector().GetInstance<FileSystemJobResourceUploader>(); } - [TestMethod] + [Fact] public void UploadJobResourceCreatesResourceArchive() { var testContext = new TestContext(); @@ -59,7 +58,7 @@ namespace Org.Apache.REEF.Client.Tests testContext.ResourceArchiveFileGenerator.Received(1).CreateArchiveToUpload(AnyDriverLocalFolderPath); } - [TestMethod] + [Fact] public void UploadJobResourceReturnsJobResourceDetails() { var testContext = new TestContext(); @@ -67,12 +66,12 @@ namespace Org.Apache.REEF.Client.Tests var jobResource = jobResourceUploader.UploadJobResource(AnyDriverLocalFolderPath, AnyDriverResourceUploadPath); - Assert.AreEqual(AnyModificationTime, jobResource.LastModificationUnixTimestamp); - Assert.AreEqual(AnyResourceSize, jobResource.ResourceSize); - Assert.AreEqual(AnyUploadedResourceAbsoluteUri, jobResource.RemoteUploadPath); + Assert.Equal(AnyModificationTime, jobResource.LastModificationUnixTimestamp); + Assert.Equal(AnyResourceSize, jobResource.ResourceSize); + Assert.Equal(AnyUploadedResourceAbsoluteUri, jobResource.RemoteUploadPath); } - [TestMethod] + [Fact] public void UploadJobResourceMakesCorrectFileSystemCalls() { var testContext = new TestContext(); http://git-wip-us.apache.org/repos/asf/reef/blob/9e19eeaf/lang/cs/Org.Apache.REEF.Client.Tests/LegacyJobResourceUploaderTests.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client.Tests/LegacyJobResourceUploaderTests.cs b/lang/cs/Org.Apache.REEF.Client.Tests/LegacyJobResourceUploaderTests.cs index 09fac49..2f66638 100644 --- a/lang/cs/Org.Apache.REEF.Client.Tests/LegacyJobResourceUploaderTests.cs +++ b/lang/cs/Org.Apache.REEF.Client.Tests/LegacyJobResourceUploaderTests.cs @@ -17,16 +17,15 @@ using System; using System.IO; -using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Org.Apache.REEF.Client.Common; using Org.Apache.REEF.Client.Yarn; using Org.Apache.REEF.Tang.Implementations.Tang; using Org.Apache.REEF.Tang.Util; +using Xunit; namespace Org.Apache.REEF.Client.Tests { - [TestClass] public class LegacyJobResourceUploaderTests { private const string AnyDriverLocalFolderPath = @"Any\Local\Folder\Path"; @@ -35,7 +34,7 @@ namespace Org.Apache.REEF.Client.Tests private const long AnyModificationTime = 1446161745550; private const long AnyResourceSize = 53092; - [TestMethod] + [Fact] public void UploadJobResourceCreatesResourceArchive() { var testContext = new TestContext(); @@ -47,7 +46,7 @@ namespace Org.Apache.REEF.Client.Tests testContext.ResourceArchiveFileGenerator.Received(1).CreateArchiveToUpload(AnyDriverLocalFolderPath + @"\"); } - [TestMethod] + [Fact] public void UploadJobResourceJavaLauncherCalledWithCorrectArguments() { var testContext = new TestContext(); @@ -71,18 +70,17 @@ namespace Org.Apache.REEF.Client.Tests && Guid.TryParse(Path.GetFileName(outputFilePath), out notUsed))); } - [TestMethod] - [ExpectedException(typeof(FileNotFoundException))] + [Fact] public void UploadJobResourceNoFileCreatedByJavaCallThrowsException() { var testContext = new TestContext(); var jobResourceUploader = testContext.GetJobResourceUploader(fileExistsReturnValue: false); // throws filenotfound exception - jobResourceUploader.UploadJobResource(AnyDriverLocalFolderPath, AnyDriverResourceUploadPath); + Assert.Throws<FileNotFoundException>(() => jobResourceUploader.UploadJobResource(AnyDriverLocalFolderPath, AnyDriverResourceUploadPath)); } - [TestMethod] + [Fact] public void UploadJobResourceReturnsJobResourceDetails() { var testContext = new TestContext(); @@ -90,9 +88,9 @@ namespace Org.Apache.REEF.Client.Tests var jobResource = jobResourceUploader.UploadJobResource(AnyDriverLocalFolderPath, AnyDriverResourceUploadPath); - Assert.AreEqual(AnyModificationTime, jobResource.LastModificationUnixTimestamp); - Assert.AreEqual(AnyResourceSize, jobResource.ResourceSize); - Assert.AreEqual(AnyUploadedResourcePath, jobResource.RemoteUploadPath); + Assert.Equal(AnyModificationTime, jobResource.LastModificationUnixTimestamp); + Assert.Equal(AnyResourceSize, jobResource.ResourceSize); + Assert.Equal(AnyUploadedResourcePath, jobResource.RemoteUploadPath); } private class TestContext http://git-wip-us.apache.org/repos/asf/reef/blob/9e19eeaf/lang/cs/Org.Apache.REEF.Client.Tests/MultipleRMUrlProviderTests.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client.Tests/MultipleRMUrlProviderTests.cs b/lang/cs/Org.Apache.REEF.Client.Tests/MultipleRMUrlProviderTests.cs index 64c8747..364234d 100644 --- a/lang/cs/Org.Apache.REEF.Client.Tests/MultipleRMUrlProviderTests.cs +++ b/lang/cs/Org.Apache.REEF.Client.Tests/MultipleRMUrlProviderTests.cs @@ -18,16 +18,16 @@ using System; using System.Globalization; using System.IO; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Org.Apache.REEF.Client.Yarn.RestClient; using Org.Apache.REEF.Client.YARN.RestClient; using Org.Apache.REEF.Tang.Exceptions; using Org.Apache.REEF.Tang.Implementations.Tang; using Org.Apache.REEF.Tang.Util; +using Xunit; namespace Org.Apache.REEF.Client.Tests { - [TestClass] + [Collection("UrlProviderTests")] public class MultipleRMUrlProviderTests { private const string HadoopConfDirEnvVariable = "HADOOP_CONF_DIR"; @@ -54,7 +54,7 @@ namespace Org.Apache.REEF.Client.Tests </property> </configuration>"; - [TestMethod] + [Fact] public void UrlProviderReadsEnvVarConfiguredConfigFileAndParsesCorrectHttpUrl() { string tempFile = Path.GetTempFileName(); @@ -71,24 +71,24 @@ namespace Org.Apache.REEF.Client.Tests foreach (var u in url) { i++; - Assert.AreEqual("http", u.Scheme); + Assert.Equal("http", u.Scheme); if (i == 1) { - Assert.AreEqual(AnyHttpAddressConfig.Split(':')[0], u.Host); - Assert.AreEqual(AnyHttpAddressConfig.Split(':')[1], + Assert.Equal(AnyHttpAddressConfig.Split(':')[0], u.Host); + Assert.Equal(AnyHttpAddressConfig.Split(':')[1], u.Port.ToString(CultureInfo.InvariantCulture)); } else { - Assert.AreEqual(AnyHttpAddressConfigUpdated.Split(':')[0], u.Host); - Assert.AreEqual(AnyHttpAddressConfigUpdated.Split(':')[1], + Assert.Equal(AnyHttpAddressConfigUpdated.Split(':')[0], u.Host); + Assert.Equal(AnyHttpAddressConfigUpdated.Split(':')[1], u.Port.ToString(CultureInfo.InvariantCulture)); } } } } - [TestMethod] + [Fact] public void CannotFindHadoopConfigDirThrowsArgumentException() { using (new YarnConfigurationUrlProviderTests.TemporaryOverrideEnvironmentVariable(HadoopConfDirEnvVariable, string.Empty)) @@ -96,11 +96,11 @@ namespace Org.Apache.REEF.Client.Tests try { IUrlProvider urlProviderNotUsed = GetYarnConfigurationUrlProvider(); - Assert.Fail("Should throw exception"); + Assert.True(false, "Should throw exception"); } catch (InjectionException injectionException) { - Assert.IsTrue(injectionException.GetBaseException() is ArgumentException); + Assert.True(injectionException.GetBaseException() is ArgumentException); } } } http://git-wip-us.apache.org/repos/asf/reef/blob/9e19eeaf/lang/cs/Org.Apache.REEF.Client.Tests/WindowsHadoopEmulatorYarnClientTests.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client.Tests/WindowsHadoopEmulatorYarnClientTests.cs b/lang/cs/Org.Apache.REEF.Client.Tests/WindowsHadoopEmulatorYarnClientTests.cs index 1e273f7..8605987 100644 --- a/lang/cs/Org.Apache.REEF.Client.Tests/WindowsHadoopEmulatorYarnClientTests.cs +++ b/lang/cs/Org.Apache.REEF.Client.Tests/WindowsHadoopEmulatorYarnClientTests.cs @@ -20,90 +20,95 @@ using System.Collections.Generic; using System.Linq; using System.ServiceProcess; using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Org.Apache.REEF.Client.Yarn.RestClient; using Org.Apache.REEF.Client.YARN.RestClient.DataModel; using Org.Apache.REEF.Tang.Implementations.Tang; +using Xunit; namespace Org.Apache.REEF.Client.Tests { - [TestClass] + // placed in the same collection as *UrlProviderTests to avoid running in parallel with them + // as they rely on setting the same environment variable to different values + [Collection("UrlProviderTests")] public class WindowsHadoopEmulatorYarnClientTests { /// <summary> - /// TestInit here checks if the required hadoop services are running on the local machine. - /// If the the services are not available, tests will be marked inconclusive. + /// This attribute checks if the required hadoop services are running on the local machine. + /// If the the services are not available, tests annotated with this attribute will be skipped. /// </summary> - [TestInitialize] - public void TestInit() + class IgnoreOnHadoopNotAvailableFactAttribute : FactAttribute { - ServiceController[] serviceControllers = ServiceController.GetServices(); - IEnumerable<string> actualServices = serviceControllers.Select(x => x.ServiceName); + public IgnoreOnHadoopNotAvailableFactAttribute() + { + ServiceController[] serviceControllers = ServiceController.GetServices(); + IEnumerable<string> actualServices = serviceControllers.Select(x => x.ServiceName); - string[] expectedServices = { "datanode", "namenode", "nodemanager", "resourcemanager" }; + string[] expectedServices = { "datanode", "namenode", "nodemanager", "resourcemanager" }; - bool allServicesExist = expectedServices.All(expectedService => actualServices.Contains(expectedService)); + bool allServicesExist = expectedServices.All(expectedService => actualServices.Contains(expectedService)); - if (!allServicesExist) - { - Assert.Inconclusive( - "At least some required windows services not installed. " + - "Two possible ways: HDInsight Emulator or HortonWorks Data Platform for Windows. " + - "Required services: " + string.Join(", ", expectedServices)); - } - - bool allServicesRunning = expectedServices.All( - expectedService => + if (!allServicesExist) { - ServiceController controller = serviceControllers.First(x => x.ServiceName == expectedService); - return controller.Status == ServiceControllerStatus.Running; - }); + Skip = + "At least some required windows services not installed. " + + "Two possible ways: HDInsight Emulator or HortonWorks Data Platform for Windows. " + + "Required services: " + string.Join(", ", expectedServices); + return; + } - if (!allServicesRunning) - { - Assert.Inconclusive("At least some required windows services are not running. " + - "Required services: " + string.Join(", ", expectedServices)); + bool allServicesRunning = expectedServices.All( + expectedService => + { + ServiceController controller = serviceControllers.First(x => x.ServiceName == expectedService); + return controller.Status == ServiceControllerStatus.Running; + }); + + if (!allServicesRunning) + { + Skip = "At least some required windows services are not running. " + + "Required services: " + string.Join(", ", expectedServices); + } } } - [TestMethod] - [TestCategory("Functional")] + [IgnoreOnHadoopNotAvailableFact] + [Trait("Category", "Functional")] public async Task TestGetClusterInfo() { var client = TangFactory.GetTang().NewInjector().GetInstance<IYarnRMClient>(); var clusterInfo = await client.GetClusterInfoAsync(); - Assert.IsNotNull(clusterInfo); - Assert.AreEqual(ClusterState.STARTED, clusterInfo.State); - Assert.IsTrue(clusterInfo.StartedOn > 0); + Assert.NotNull(clusterInfo); + Assert.Equal(ClusterState.STARTED, clusterInfo.State); + Assert.True(clusterInfo.StartedOn > 0); } - [TestMethod] - [TestCategory("Functional")] + [IgnoreOnHadoopNotAvailableFact] + [Trait("Category", "Functional")] public async Task TestGetClusterMetrics() { var client = TangFactory.GetTang().NewInjector().GetInstance<IYarnRMClient>(); var clusterMetrics = await client.GetClusterMetricsAsync(); - Assert.IsNotNull(clusterMetrics); - Assert.IsTrue(clusterMetrics.TotalMB > 0); - Assert.IsTrue(clusterMetrics.ActiveNodes > 0); + Assert.NotNull(clusterMetrics); + Assert.True(clusterMetrics.TotalMB > 0); + Assert.True(clusterMetrics.ActiveNodes > 0); } - [TestMethod] - [TestCategory("Functional")] + [IgnoreOnHadoopNotAvailableFact] + [Trait("Category", "Functional")] public async Task TestApplicationSubmissionAndQuery() { var client = TangFactory.GetTang().NewInjector().GetInstance<IYarnRMClient>(); var newApplication = await client.CreateNewApplicationAsync(); - Assert.IsNotNull(newApplication); - Assert.IsFalse(string.IsNullOrEmpty(newApplication.ApplicationId)); - Assert.IsTrue(newApplication.MaximumResourceCapability.MemoryMB > 0); - Assert.IsTrue(newApplication.MaximumResourceCapability.VCores > 0); + Assert.NotNull(newApplication); + Assert.False(string.IsNullOrEmpty(newApplication.ApplicationId)); + Assert.True(newApplication.MaximumResourceCapability.MemoryMB > 0); + Assert.True(newApplication.MaximumResourceCapability.VCores > 0); string applicationName = "REEFTEST_APPLICATION_" + Guid.NewGuid(); Console.WriteLine(applicationName); @@ -150,21 +155,21 @@ namespace Org.Apache.REEF.Client.Tests var application = await client.SubmitApplicationAsync(submitApplicationRequest); - Assert.IsNotNull(application); - Assert.AreEqual(newApplication.ApplicationId, application.Id); - Assert.AreEqual(applicationName, application.Name); - Assert.AreEqual(anyApplicationType, application.ApplicationType); + Assert.NotNull(application); + Assert.Equal(newApplication.ApplicationId, application.Id); + Assert.Equal(applicationName, application.Name); + Assert.Equal(anyApplicationType, application.ApplicationType); var getApplicationResult = client.GetApplicationAsync(newApplication.ApplicationId).GetAwaiter().GetResult(); - Assert.IsNotNull(getApplicationResult); - Assert.AreEqual(newApplication.ApplicationId, getApplicationResult.Id); - Assert.AreEqual(applicationName, getApplicationResult.Name); - Assert.AreEqual(anyApplicationType, getApplicationResult.ApplicationType); + Assert.NotNull(getApplicationResult); + Assert.Equal(newApplication.ApplicationId, getApplicationResult.Id); + Assert.Equal(applicationName, getApplicationResult.Name); + Assert.Equal(anyApplicationType, getApplicationResult.ApplicationType); } - [TestMethod] - [TestCategory("Functional")] + [IgnoreOnHadoopNotAvailableFact] + [Trait("Category", "Functional")] public async Task TestErrorResponse() { const string wrongApplicationName = @"Something"; @@ -174,11 +179,11 @@ namespace Org.Apache.REEF.Client.Tests try { await client.GetApplicationAsync(wrongApplicationName); - Assert.Fail("Should throw YarnRestAPIException"); + Assert.True(false, "Should throw YarnRestAPIException"); } catch (AggregateException aggregateException) { - Assert.IsInstanceOfType(aggregateException.GetBaseException(), typeof(YarnRestAPIException)); + Assert.IsType(typeof(YarnRestAPIException), aggregateException.GetBaseException()); } } } http://git-wip-us.apache.org/repos/asf/reef/blob/9e19eeaf/lang/cs/Org.Apache.REEF.Client.Tests/WindowsYarnJobCommandProviderTests.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client.Tests/WindowsYarnJobCommandProviderTests.cs b/lang/cs/Org.Apache.REEF.Client.Tests/WindowsYarnJobCommandProviderTests.cs index f93d225..a8472ad 100644 --- a/lang/cs/Org.Apache.REEF.Client.Tests/WindowsYarnJobCommandProviderTests.cs +++ b/lang/cs/Org.Apache.REEF.Client.Tests/WindowsYarnJobCommandProviderTests.cs @@ -16,17 +16,16 @@ // under the License. using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Org.Apache.REEF.Client.Yarn; using Org.Apache.REEF.Client.YARN; using Org.Apache.REEF.Client.YARN.Parameters; using Org.Apache.REEF.Tang.Implementations.Tang; using Org.Apache.REEF.Tang.Util; +using Xunit; namespace Org.Apache.REEF.Client.Tests { - [TestClass] public class WindowsYarnJobCommandProviderTests { private static readonly List<string> AnyClassPathItems = new List<string> @@ -53,13 +52,13 @@ namespace Org.Apache.REEF.Client.Tests "%HADOOP_HOME%/share/hadoop/mapreduce/lib/*" }; - [TestMethod] + [Fact] public void YarnJobCommandBuilderIsDefaultImplementationOfIYarnJobCommandBuilder() { - Assert.IsInstanceOfType(TangFactory.GetTang().NewInjector().GetInstance<IYarnJobCommandProvider>(), typeof(WindowsYarnJobCommandProvider)); + Assert.IsType(typeof(WindowsYarnJobCommandProvider), TangFactory.GetTang().NewInjector().GetInstance<IYarnJobCommandProvider>()); } - [TestMethod] + [Fact] public void GetJobSubmissionCommandGeneratesCorrectCommand() { var testContext = new TestContext(); @@ -79,10 +78,10 @@ namespace Org.Apache.REEF.Client.Tests var commandBuilder = testContext.GetCommandBuilder(); var jobSubmissionCommand = commandBuilder.GetJobSubmissionCommand(); - Assert.AreEqual(expectedCommand, jobSubmissionCommand); + Assert.Equal(expectedCommand, jobSubmissionCommand); } - [TestMethod] + [Fact] public void GetJobSubmissionCommandLoggingEnabledGeneratesCorrectCommand() { var testContext = new TestContext(); @@ -102,10 +101,10 @@ namespace Org.Apache.REEF.Client.Tests "ion-params.json 1> <LOG_DIR>/driver.stdout 2> <LOG_DIR>/driver.stderr"; var commandBuilder = testContext.GetCommandBuilder(true); var jobSubmissionCommand = commandBuilder.GetJobSubmissionCommand(); - Assert.AreEqual(expectedCommand, jobSubmissionCommand); + Assert.Equal(expectedCommand, jobSubmissionCommand); } - [TestMethod] + [Fact] public void GetJobSubmissionCommandSetsCorrectDriverMemoryAllocationSize() { var testContext = new TestContext(); @@ -126,10 +125,10 @@ namespace Org.Apache.REEF.Client.Tests string expectedCommand = string.Format(expectedCommandFormat, sizeMB); var commandBuilder = testContext.GetCommandBuilder(maxMemAllocPoolSize: sizeMB); var jobSubmissionCommand = commandBuilder.GetJobSubmissionCommand(); - Assert.AreEqual(expectedCommand, jobSubmissionCommand); + Assert.Equal(expectedCommand, jobSubmissionCommand); } - [TestMethod] + [Fact] public void GetJobSubmissionCommandSetsCorrectMaxPermSize() { var testContext = new TestContext(); @@ -152,7 +151,7 @@ namespace Org.Apache.REEF.Client.Tests var commandBuilder = testContext.GetCommandBuilder(maxPermSize: sizeMB); var jobSubmissionCommand = commandBuilder.GetJobSubmissionCommand(); - Assert.AreEqual(expectedCommand, jobSubmissionCommand); + Assert.Equal(expectedCommand, jobSubmissionCommand); } private class TestContext http://git-wip-us.apache.org/repos/asf/reef/blob/9e19eeaf/lang/cs/Org.Apache.REEF.Client.Tests/YarnClientTests.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client.Tests/YarnClientTests.cs b/lang/cs/Org.Apache.REEF.Client.Tests/YarnClientTests.cs index 986ac5e..fe07cc0 100644 --- a/lang/cs/Org.Apache.REEF.Client.Tests/YarnClientTests.cs +++ b/lang/cs/Org.Apache.REEF.Client.Tests/YarnClientTests.cs @@ -21,7 +21,6 @@ using System.Linq; using System.Net; using System.Threading; using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; using Org.Apache.REEF.Client.Yarn.RestClient; using Org.Apache.REEF.Client.YARN.RestClient; @@ -29,13 +28,13 @@ using Org.Apache.REEF.Client.YARN.RestClient.DataModel; using Org.Apache.REEF.Tang.Implementations.Tang; using Org.Apache.REEF.Tang.Util; using RestSharp; +using Xunit; namespace Org.Apache.REEF.Client.Tests { - [TestClass] public class YarnClientTests { - [TestMethod] + [Fact] public async Task TestGetClusterInfo() { // arrange @@ -63,11 +62,11 @@ namespace Org.Apache.REEF.Client.Tests ClusterInfo actualClusterInfo = await yarnClient.GetClusterInfoAsync(); // assert - Assert.AreEqual(anyClusterInfo, actualClusterInfo); + Assert.Equal(anyClusterInfo, actualClusterInfo); var unused = urlProvider.Received(1).GetUrlAsync(); } - [TestMethod] + [Fact] public async Task TestGetClusterMetrics() { var ctx = new TestContext(); @@ -93,11 +92,11 @@ namespace Org.Apache.REEF.Client.Tests var yarnClient = ctx.GetClient(); ClusterMetrics actualClusterMetrics = await yarnClient.GetClusterMetricsAsync(); - Assert.AreEqual(anyClusterMetrics, actualClusterMetrics); + Assert.Equal(anyClusterMetrics, actualClusterMetrics); var unused = urlProvider.Received(1).GetUrlAsync(); } - [TestMethod] + [Fact] public async Task TestGetApplication() { var ctx = new TestContext(); @@ -128,11 +127,11 @@ namespace Org.Apache.REEF.Client.Tests var yarnClient = ctx.GetClient(); Application actualApplication = await yarnClient.GetApplicationAsync(applicationId); - Assert.AreEqual(anyApplication, actualApplication); + Assert.Equal(anyApplication, actualApplication); var unused = urlProvider.Received(1).GetUrlAsync(); } - [TestMethod] + [Fact] public async Task TestGetApplicationFinalStatus() { var ctx = new TestContext(); @@ -165,10 +164,10 @@ namespace Org.Apache.REEF.Client.Tests Application actualApplication = await yarnClient.GetApplicationAsync(applicationId); - Assert.AreEqual(actualApplication.FinalStatus, FinalState.SUCCEEDED); + Assert.Equal(actualApplication.FinalStatus, FinalState.SUCCEEDED); } - [TestMethod] + [Fact] public async Task TestCreateNewApplication() { var ctx = new TestContext(); @@ -192,11 +191,11 @@ namespace Org.Apache.REEF.Client.Tests var yarnClient = ctx.GetClient(); NewApplication actualNewApplication = await yarnClient.CreateNewApplicationAsync(); - Assert.AreEqual(anyNewApplication, actualNewApplication); + Assert.Equal(anyNewApplication, actualNewApplication); var unused = urlProvider.Received(1).GetUrlAsync(); } - [TestMethod] + [Fact] public async Task TestSubmitNewApplication() { var ctx = new TestContext(); @@ -333,7 +332,7 @@ namespace Org.Apache.REEF.Client.Tests var yarnClient = ctx.GetClient(); Application actualApplication = await yarnClient.SubmitApplicationAsync(anySubmitApplication); - Assert.AreEqual(thisApplication, actualApplication); + Assert.Equal(thisApplication, actualApplication); var unused = urlProvider.Received(2).GetUrlAsync(); } http://git-wip-us.apache.org/repos/asf/reef/blob/9e19eeaf/lang/cs/Org.Apache.REEF.Client.Tests/YarnConfigurationUrlProviderTests.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client.Tests/YarnConfigurationUrlProviderTests.cs b/lang/cs/Org.Apache.REEF.Client.Tests/YarnConfigurationUrlProviderTests.cs index 9a8223b..ba42625 100644 --- a/lang/cs/Org.Apache.REEF.Client.Tests/YarnConfigurationUrlProviderTests.cs +++ b/lang/cs/Org.Apache.REEF.Client.Tests/YarnConfigurationUrlProviderTests.cs @@ -21,15 +21,15 @@ using System.Globalization; using System.IO; using System.Linq; using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Org.Apache.REEF.Client.Yarn.RestClient; using Org.Apache.REEF.Client.YARN.RestClient; using Org.Apache.REEF.Tang.Exceptions; using Org.Apache.REEF.Tang.Implementations.Tang; +using Xunit; namespace Org.Apache.REEF.Client.Tests { - [TestClass] + [Collection("UrlProviderTests")] public class YarnConfigurationUrlProviderTests { private const string HadoopConfDirEnvVariable = "HADOOP_CONF_DIR"; @@ -74,7 +74,7 @@ namespace Org.Apache.REEF.Client.Tests </property> </configuration>"; - [TestMethod] + [Fact] public void UrlProviderReadsEnvVarConfiguredConfigFileAndParsesCorrectHttpUrl() { string tempFile = Path.GetTempFileName(); @@ -87,13 +87,13 @@ namespace Org.Apache.REEF.Client.Tests YarnConfigurationUrlProvider urlProvider = GetYarnConfigurationUrlProvider(); var url = urlProvider.GetUrlAsync().GetAwaiter().GetResult(); - Assert.AreEqual("http", url.First().Scheme); - Assert.AreEqual(AnyHttpAddressConfig.Split(':')[0], url.First().Host); - Assert.AreEqual(AnyHttpAddressConfig.Split(':')[1], url.First().Port.ToString(CultureInfo.InvariantCulture)); + Assert.Equal("http", url.First().Scheme); + Assert.Equal(AnyHttpAddressConfig.Split(':')[0], url.First().Host); + Assert.Equal(AnyHttpAddressConfig.Split(':')[1], url.First().Port.ToString(CultureInfo.InvariantCulture)); } } - [TestMethod] + [Fact] public void UrlProviderReadsEnvVarConfiguredConfigFileAndParsesCorrectHttpsUrl() { string tempFile = Path.GetTempFileName(); @@ -106,13 +106,13 @@ namespace Org.Apache.REEF.Client.Tests YarnConfigurationUrlProvider urlProvider = GetYarnConfigurationUrlProvider(useHttps: true); IEnumerable<Uri> url = urlProvider.GetUrlAsync().GetAwaiter().GetResult(); - Assert.AreEqual("https", url.First().Scheme); - Assert.AreEqual(AnyHttpsAddressConfig.Split(':')[0], url.First().Host); - Assert.AreEqual(AnyHttpsAddressConfig.Split(':')[1], url.First().Port.ToString(CultureInfo.InvariantCulture)); + Assert.Equal("https", url.First().Scheme); + Assert.Equal(AnyHttpsAddressConfig.Split(':')[0], url.First().Host); + Assert.Equal(AnyHttpsAddressConfig.Split(':')[1], url.First().Port.ToString(CultureInfo.InvariantCulture)); } } - [TestMethod] + [Fact] public void UrlProviderReadsUserProvidedConfigFileAndParsesCorrectHttpsUrl() { string tempFile = Path.GetTempFileName(); @@ -126,13 +126,13 @@ namespace Org.Apache.REEF.Client.Tests useHttps: true); var url = urlProvider.GetUrlAsync().GetAwaiter().GetResult(); - Assert.AreEqual("https", url.First().Scheme); - Assert.AreEqual(AnyHttpsAddressConfig.Split(':')[0], url.First().Host); - Assert.AreEqual(AnyHttpsAddressConfig.Split(':')[1], url.First().Port.ToString(CultureInfo.InvariantCulture)); + Assert.Equal("https", url.First().Scheme); + Assert.Equal(AnyHttpsAddressConfig.Split(':')[0], url.First().Host); + Assert.Equal(AnyHttpsAddressConfig.Split(':')[1], url.First().Port.ToString(CultureInfo.InvariantCulture)); } } - [TestMethod] + [Fact] public void CannotFindHadoopConfigDirThrowsArgumentException() { using (new TemporaryOverrideEnvironmentVariable(HadoopConfDirEnvVariable, string.Empty)) @@ -140,11 +140,11 @@ namespace Org.Apache.REEF.Client.Tests try { YarnConfigurationUrlProvider urlProviderNotUsed = GetYarnConfigurationUrlProvider(); - Assert.Fail("Should throw exception"); + Assert.True(false, "Should throw exception"); } catch (InjectionException injectionException) { - Assert.IsTrue(injectionException.GetBaseException() is ArgumentException); + Assert.True(injectionException.GetBaseException() is ArgumentException); } } }
