Repository: ignite Updated Branches: refs/heads/master 600542d53 -> 82d690f97
.NET: Fix LoadDllTest, IgniteStartStopTest Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/82d690f9 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/82d690f9 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/82d690f9 Branch: refs/heads/master Commit: 82d690f97bd1c6933e9e5c96d070a33f0d6c9246 Parents: 600542d Author: Pavel Tupitsyn <[email protected]> Authored: Sun Feb 18 23:22:27 2018 +0300 Committer: Pavel Tupitsyn <[email protected]> Committed: Sun Feb 18 23:22:27 2018 +0300 ---------------------------------------------------------------------- .../Client/Cache/CacheClientAsyncWrapper.cs | 1 - .../IgniteStartStopTest.cs | 77 +++++------------ .../Apache.Ignite.Core.Tests/LoadDllTest.cs | 88 ++++---------------- 3 files changed, 36 insertions(+), 130 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/82d690f9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs index 1075ddf..6d812cf 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs @@ -17,7 +17,6 @@ namespace Apache.Ignite.Core.Tests.Client.Cache { - using System; using System.Collections.Generic; using System.Threading.Tasks; using Apache.Ignite.Core.Cache; http://git-wip-us.apache.org/repos/asf/ignite/blob/82d690f9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs index 43afb7a..792b33d 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteStartStopTest.cs @@ -18,7 +18,6 @@ namespace Apache.Ignite.Core.Tests { using System; - using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; @@ -67,7 +66,7 @@ namespace Apache.Ignite.Core.Tests { var cfg = new IgniteConfiguration { - SpringConfigUrl = "config\\start-test-grid1.xml", + SpringConfigUrl = "config\\spring-test.xml", JvmClasspath = TestUtils.CreateTestClasspath() }; @@ -84,31 +83,18 @@ namespace Apache.Ignite.Core.Tests [Test] public void TestStartGetStop() { - var cfgs = new List<string> { "config\\start-test-grid1.xml", "config\\start-test-grid2.xml", "config\\start-test-grid3.xml" }; - - var cfg = new IgniteConfiguration - { - SpringConfigUrl = cfgs[0], - JvmOptions = TestUtils.TestJavaOptions(), - JvmClasspath = TestUtils.CreateTestClasspath() - }; - - var grid1 = Ignition.Start(cfg); + var grid1 = Ignition.Start(TestUtils.GetTestConfiguration(name: "grid1")); Assert.AreEqual("grid1", grid1.Name); Assert.AreSame(grid1, Ignition.GetIgnite()); Assert.AreSame(grid1, Ignition.GetAll().Single()); - cfg.SpringConfigUrl = cfgs[1]; - - var grid2 = Ignition.Start(cfg); + var grid2 = Ignition.Start(TestUtils.GetTestConfiguration(name: "grid2")); Assert.AreEqual("grid2", grid2.Name); Assert.Throws<IgniteException>(() => Ignition.GetIgnite()); - cfg.SpringConfigUrl = cfgs[2]; - - var grid3 = Ignition.Start(cfg); + var grid3 = Ignition.Start(TestUtils.GetTestConfiguration()); Assert.IsNull(grid3.Name); @@ -138,20 +124,17 @@ namespace Apache.Ignite.Core.Tests grid3.Dispose(); Assert.Throws<IgniteException>(() => Ignition.GetIgnite("grid3")); - foreach (var cfgName in cfgs) - { - cfg.SpringConfigUrl = cfgName; - cfg.JvmOptions = TestUtils.TestJavaOptions(); - - Ignition.Start(cfg); - } + // Restart. + Ignition.Start(TestUtils.GetTestConfiguration(name: "grid1")); + Ignition.Start(TestUtils.GetTestConfiguration(name: "grid2")); + Ignition.Start(TestUtils.GetTestConfiguration()); - foreach (var gridName in new List<string> { "grid1", "grid2", null }) + foreach (var gridName in new [] { "grid1", "grid2", null }) Assert.IsNotNull(Ignition.GetIgnite(gridName)); Ignition.StopAll(true); - foreach (var gridName in new List<string> {"grid1", "grid2", null}) + foreach (var gridName in new [] {"grid1", "grid2", null}) Assert.Throws<IgniteException>(() => Ignition.GetIgnite(gridName)); } @@ -161,13 +144,8 @@ namespace Apache.Ignite.Core.Tests [Test] public void TestStartTheSameName() { - var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) - { - SpringConfigUrl = "config\\start-test-grid1.xml", - }; - + var cfg = TestUtils.GetTestConfiguration(name: "grid1"); var grid1 = Ignition.Start(cfg); - Assert.AreEqual("grid1", grid1.Name); var ex = Assert.Throws<IgniteException>(() => Ignition.Start(cfg)); @@ -199,21 +177,16 @@ namespace Apache.Ignite.Core.Tests [Test] public void TestUsageAfterStop() { - var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) - { - SpringConfigUrl = "config\\start-test-grid1.xml", - }; - - var grid = Ignition.Start(cfg); + var grid = Ignition.Start(TestUtils.GetTestConfiguration()); - Assert.IsNotNull(grid.GetCache<int, int>("cache1")); + Assert.IsNotNull(grid.GetOrCreateCache<int, int>("cache1")); grid.Dispose(); var ex = Assert.Throws<InvalidOperationException>(() => grid.GetCache<int, int>("cache1")); Assert.AreEqual("Grid is in invalid state to perform this operation. " + "It either not started yet or has already being or have stopped " + - "[igniteInstanceName=grid1, state=STOPPED]", ex.Message); + "[igniteInstanceName=null, state=STOPPED]", ex.Message); } /// <summary> @@ -222,12 +195,7 @@ namespace Apache.Ignite.Core.Tests [Test] public void TestStartStopLeak() { - var cfg = new IgniteConfiguration - { - SpringConfigUrl = "config\\start-test-grid1.xml", - JvmOptions = new List<string> {"-Xcheck:jni", "-Xms256m", "-Xmx256m", "-XX:+HeapDumpOnOutOfMemoryError"}, - JvmClasspath = TestUtils.CreateTestClasspath() - }; + var cfg = TestUtils.GetTestConfiguration(); for (var i = 0; i < 50; i++) { @@ -256,15 +224,8 @@ namespace Apache.Ignite.Core.Tests [Test] public void TestClientMode() { - var servCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) - { - SpringConfigUrl = "config\\start-test-grid1.xml", - }; - - var clientCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) - { - SpringConfigUrl = "config\\start-test-grid2.xml", - }; + var servCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration(name: "serv")); + var clientCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration(name: "client")); try { @@ -306,7 +267,7 @@ namespace Apache.Ignite.Core.Tests Assert.IsNotNull(prj.GetCompute()); - var cache = ignite.GetCache<int, int>("cache1"); + var cache = ignite.GetOrCreateCache<int, int>("cache1"); Assert.IsNotNull(cache); @@ -323,7 +284,7 @@ namespace Apache.Ignite.Core.Tests { var cfg = new IgniteConfiguration { - SpringConfigUrl = "config\\start-test-grid1.xml", + SpringConfigUrl = "Config\\spring-test.xml", JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath() }; http://git-wip-us.apache.org/repos/asf/ignite/blob/82d690f9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs index e466642..3c498d7 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/LoadDllTest.cs @@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Tests { using System; using System.CodeDom.Compiler; - using System.Collections.Generic; using System.IO; using System.Linq; using Apache.Ignite.Core.Common; @@ -56,23 +55,7 @@ namespace Apache.Ignite.Core.Tests public void TestLoadFromGac() { Assert.False(IsLoaded("System.Data.Linq")); - - var cfg = new IgniteConfiguration - { - SpringConfigUrl = "config\\start-test-grid3.xml", - Assemblies = - new List<string> - { - "System.Data.Linq,Culture=neutral,Version=1.0.0.0,PublicKeyToken=b77a5c561934e089" - }, - JvmClasspath = TestUtils.CreateTestClasspath() - }; - - - var grid = Ignition.Start(cfg); - - Assert.IsNotNull(grid); - + StartWithDll("System.Data.Linq,Culture=neutral,Version=1.0.0.0,PublicKeyToken=b77a5c561934e089"); Assert.True(IsLoaded("System.Data.Linq")); } @@ -83,20 +66,8 @@ namespace Apache.Ignite.Core.Tests public void TestLoadFromCurrentDir() { Assert.False(IsLoaded("testDll")); - GenerateDll("testDll.dll"); - - var cfg = new IgniteConfiguration - { - SpringConfigUrl = "config\\start-test-grid3.xml", - Assemblies = new List<string> {"testDll.dll"}, - JvmClasspath = TestUtils.CreateTestClasspath() - }; - - var grid = Ignition.Start(cfg); - - Assert.IsNotNull(grid); - + StartWithDll("testDll.dll"); Assert.True(IsLoaded("testDll")); } @@ -115,16 +86,7 @@ namespace Apache.Ignite.Core.Tests GenerateDll(dirInfo.FullName + "/dllFromDir2.dll"); File.WriteAllText(dirInfo.FullName + "/notADll.txt", "notADll"); - var cfg = new IgniteConfiguration - { - SpringConfigUrl = "config\\start-test-grid3.xml", - Assemblies = new List<string> {dirInfo.FullName}, - JvmClasspath = TestUtils.CreateTestClasspath() - }; - - var grid = Ignition.Start(cfg); - - Assert.IsNotNull(grid); + StartWithDll(dirInfo.FullName); Assert.True(IsLoaded("dllFromDir1")); Assert.True(IsLoaded("dllFromDir2")); @@ -137,20 +99,8 @@ namespace Apache.Ignite.Core.Tests public void TestLoadFromCurrentDirByName() { Assert.False(IsLoaded("testDllByName")); - GenerateDll("testDllByName.dll"); - - var cfg = new IgniteConfiguration - { - SpringConfigUrl = "config\\start-test-grid3.xml", - Assemblies = new List<string> {"testDllByName"}, - JvmClasspath = TestUtils.CreateTestClasspath() - }; - - var grid = Ignition.Start(cfg); - - Assert.IsNotNull(grid); - + StartWithDll("testDllByName"); Assert.True(IsLoaded("testDllByName")); } @@ -162,20 +112,8 @@ namespace Apache.Ignite.Core.Tests { var dllPath = Path.GetTempPath() + "/tempDll.dll"; Assert.False(IsLoaded("tempDll")); - GenerateDll(dllPath); - - var cfg = new IgniteConfiguration - { - SpringConfigUrl = "config\\start-test-grid3.xml", - Assemblies = new List<string> {dllPath}, - JvmClasspath = TestUtils.CreateTestClasspath() - }; - - var grid = Ignition.Start(cfg); - - Assert.IsNotNull(grid); - + StartWithDll(dllPath); Assert.True(IsLoaded("tempDll")); } @@ -185,16 +123,24 @@ namespace Apache.Ignite.Core.Tests [Test] public void TestLoadUnexistingLibrary() { - var cfg = new IgniteConfiguration + var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { - SpringConfigUrl = "config\\start-test-grid3.xml", - Assemblies = new List<string> {"unexistingAssembly.820482.dll"}, - JvmClasspath = TestUtils.CreateTestClasspath() + Assemblies = new [] {"unexistingAssembly.820482.dll"}, }; Assert.Throws<IgniteException>(() => Ignition.Start(cfg)); } + private static void StartWithDll(string dll) + { + var ignite = Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) + { + Assemblies = new[] {dll} + }); + + Assert.IsNotNull(ignite); + } + /// <summary> /// /// </summary>
