You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2017/04/06 08:53:32 UTC
ignite git commit: IGNITE-4906 .NET: Fixed hanging examples tests
Repository: ignite
Updated Branches:
refs/heads/master 037bca6f9 -> b4653012b
IGNITE-4906 .NET: Fixed hanging examples tests
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b4653012
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b4653012
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b4653012
Branch: refs/heads/master
Commit: b4653012be2b251a6afa895c1273a833ca8918d6
Parents: 037bca6
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Apr 6 11:53:24 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Apr 6 11:53:24 2017 +0300
----------------------------------------------------------------------
.../Binary/BinaryDynamicRegistrationTest.cs | 50 ++++++++++++++++++--
.../Examples/ExamplesTest.cs | 22 +++++++--
.../examples/Apache.Ignite.Examples/App.config | 4 +-
.../Datagrid/MultiTieredCacheExample.cs | 4 +-
.../Misc/ClientReconnectExample.cs | 38 ++++++++++-----
5 files changed, 94 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4653012/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs
index 10e6e0b..dc5e7df 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryDynamicRegistrationTest.cs
@@ -230,11 +230,19 @@ namespace Apache.Ignite.Core.Tests.Binary
{
using (var ignite1 = Ignition.Start(TestUtils.GetTestConfiguration()))
{
- using (var ignite2 = Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration())
+ var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
{
IgniteInstanceName = "grid2",
ClientMode = clientMode
- }))
+ };
+
+ using (var ignite2 = Ignition.Start(cfg))
+ {
+ Test(ignite1, ignite2);
+ }
+
+ // Test twice to verify double registration.
+ using (var ignite2 = Ignition.Start(cfg))
{
Test(ignite1, ignite2);
}
@@ -242,6 +250,40 @@ namespace Apache.Ignite.Core.Tests.Binary
}
/// <summary>
+ /// Tests the situation where newly joined node attempts registration of a known type.
+ /// </summary>
+ [Test]
+ public void TestTwoGridsStartStop([Values(false, true)] bool clientMode)
+ {
+ using (Ignition.Start(TestUtils.GetTestConfiguration()))
+ {
+ var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+ {
+ IgniteInstanceName = "grid2",
+ ClientMode = clientMode
+ };
+
+ using (var ignite2 = Ignition.Start(cfg))
+ {
+ var cache = ignite2.CreateCache<int, Foo>("foos");
+
+ cache[1] = new Foo();
+ }
+
+ using (var ignite2 = Ignition.Start(cfg))
+ {
+ var cache = ignite2.GetCache<int, Foo>("foos");
+
+ // ignite2 does not know that Foo class is registered in cluster, and attempts to register.
+ cache[2] = new Foo();
+
+ Assert.AreEqual(0, cache[1].Int);
+ Assert.AreEqual(0, cache[2].Int);
+ }
+ }
+ }
+
+ /// <summary>
/// Tests interop scenario: Java and .NET exchange an object with the same type id,
/// but marshaller cache contains different entries for different platforms for the same id.
/// </summary>
@@ -283,12 +325,12 @@ namespace Apache.Ignite.Core.Tests.Binary
const string cacheName = "cache";
// Put on one grid.
- var cache1 = ignite1.CreateCache<int, object>(cacheName);
+ var cache1 = ignite1.GetOrCreateCache<int, object>(cacheName);
cache1[1] = new Foo {Int = 1, Str = "1"};
cache1[2] = ignite1.GetBinary().GetBuilder(typeof (Bar)).SetField("Int", 5).SetField("Str", "s").Build();
// Get on another grid.
- var cache2 = ignite2.GetCache<int, Foo>(cacheName);
+ var cache2 = ignite2.GetOrCreateCache<int, Foo>(cacheName);
var foo = cache2[1];
Assert.AreEqual(1, foo.Int);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4653012/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
index 56a17a3..e041fd7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
@@ -43,11 +43,15 @@ namespace Apache.Ignite.Core.Tests.Examples
/** */
private static readonly string[] NoDllExamples = { "BinaryModeExample", "NearCacheExample" };
+ /** Config file path. */
+ private string _configPath;
+
/** */
private IDisposable _changedConfig;
/** */
private bool _remoteNodeStarted;
+
/// <summary>
/// Tests the example in a single node mode.
/// </summary>
@@ -121,12 +125,12 @@ namespace Apache.Ignite.Core.Tests.Examples
Ignition.ClientMode = false;
using (var ignite = Ignition.StartFromApplicationConfiguration(
- "igniteConfiguration", PathUtil.ExamplesAppConfigPath))
+ "igniteConfiguration", _configPath))
{
var args = new List<string>
{
- "-configFileName=" + PathUtil.ExamplesAppConfigPath,
- " -assembly=" + typeof(AverageSalaryJob).Assembly.Location
+ "-configFileName=" + _configPath,
+ "-assembly=" + typeof(AverageSalaryJob).Assembly.Location
};
var proc = new IgniteProcess(args.ToArray());
@@ -163,7 +167,15 @@ namespace Apache.Ignite.Core.Tests.Examples
Directory.SetCurrentDirectory(PathUtil.IgniteHome);
- _changedConfig = TestAppConfig.Change(PathUtil.ExamplesAppConfigPath);
+ // Copy file to a temp location and replace multicast IP finder with static.
+ _configPath = Path.GetTempFileName();
+
+ var configText = File.ReadAllText(PathUtil.ExamplesAppConfigPath)
+ .Replace("TcpDiscoveryMulticastIpFinder", "TcpDiscoveryStaticIpFinder");
+
+ File.WriteAllText(_configPath, configText);
+
+ _changedConfig = TestAppConfig.Change(_configPath);
}
/// <summary>
@@ -177,6 +189,8 @@ namespace Apache.Ignite.Core.Tests.Examples
Ignition.StopAll(true);
IgniteProcess.KillAll();
+
+ File.Delete(_configPath);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4653012/modules/platforms/dotnet/examples/Apache.Ignite.Examples/App.config
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/App.config b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/App.config
index e3bc79d..ffec1ec 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/App.config
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/App.config
@@ -26,13 +26,13 @@
<gcServer enabled="true" />
</runtime>
- <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection">
+ <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection" localhost="127.0.0.1">
<atomicConfiguration atomicSequenceReserveSize="10" />
<discoverySpi type="TcpDiscoverySpi">
<ipFinder type="TcpDiscoveryMulticastIpFinder">
<endpoints>
- <string>127.0.0.1:47500</string>
+ <string>127.0.0.1:47500..47502</string>
</endpoints>
</ipFinder>
</discoverySpi>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4653012/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
index 629ed89..f905d86 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
@@ -26,7 +26,7 @@ namespace Apache.Ignite.Examples.Datagrid
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Eviction;
using Apache.Ignite.Core.Discovery.Tcp;
- using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+ using Apache.Ignite.Core.Discovery.Tcp.Static;
using Apache.Ignite.Core.SwapSpace.File;
/// <summary>
@@ -64,7 +64,7 @@ namespace Apache.Ignite.Examples.Datagrid
{
DiscoverySpi = new TcpDiscoverySpi
{
- IpFinder = new TcpDiscoveryMulticastIpFinder
+ IpFinder = new TcpDiscoveryStaticIpFinder
{
Endpoints = new[] { "127.0.0.1:47500" }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b4653012/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/ClientReconnectExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/ClientReconnectExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/ClientReconnectExample.cs
index fca0f9f..f6e1b4d 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/ClientReconnectExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Misc/ClientReconnectExample.cs
@@ -50,9 +50,15 @@ namespace Apache.Ignite.Examples.Misc
var evt = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(_ => RunServer(evt));
- Ignition.ClientMode = true;
+ // Wait a moment for server to begin startup.
+ Thread.Sleep(200);
- using (var ignite = Ignition.StartFromApplicationConfiguration())
+ var cfg = new IgniteConfiguration(GetIgniteConfiguration())
+ {
+ ClientMode = true
+ };
+
+ using (var ignite = Ignition.Start(cfg))
{
Console.WriteLine(">>> Client node connected to the cluster.");
@@ -110,20 +116,11 @@ namespace Apache.Ignite.Examples.Misc
/// <param name="evt"></param>
private static void RunServer(WaitHandle evt)
{
- var cfg = new IgniteConfiguration
+ var cfg = new IgniteConfiguration(GetIgniteConfiguration())
{
// Nodes within a single process are distinguished by GridName property.
IgniteInstanceName = "serverNode",
- // Discovery settings are the same as in app.config.
- DiscoverySpi = new TcpDiscoverySpi
- {
- IpFinder = new TcpDiscoveryStaticIpFinder
- {
- Endpoints = new[] {"127.0.0.1:47500"}
- }
- },
-
CacheConfiguration = new[] {new CacheConfiguration(CacheName)},
IncludedEventTypes = new[] {EventType.NodeJoined}
@@ -155,5 +152,22 @@ namespace Apache.Ignite.Examples.Misc
evt.WaitOne();
}
}
+
+ /// <summary>
+ /// Gets the base Ignite configuration.
+ /// </summary>
+ private static IgniteConfiguration GetIgniteConfiguration()
+ {
+ return new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[] { "127.0.0.1:47500" }
+ }
+ }
+ };
+ }
}
}