.NET: Fix metrics test
@@ -25,6 +25,7 @@ namespace Apache.Ignite.Core.Tests.Cache
using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Cache;
using NUnit.Framework;
+ using System.Linq;
/// <summary>
/// Tests cache metrics propagation.
@@ -212,7 +213,8 @@ namespace Apache.Ignite.Core.Tests.Cache
{
func2 = func2 ?? func;
- var localCache = Ignition.GetIgnite().CreateCache<int, int>(new CacheConfiguration(cacheName)
+ var localIgnite = Ignition.GetIgnite();
+ var localCache = localIgnite.CreateCache<int, int>(new CacheConfiguration(cacheName)
{
EnableStatistics = true
});
@@ -222,9 +224,12 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.IsTrue(localCache.GetConfiguration().EnableStatistics);
Assert.IsTrue(remoteCache.GetConfiguration().EnableStatistics);
- localCache.Put(1, 1);
- localCache.Get(1);
+ var aff = localIgnite.GetAffinity(cacheName);
+ var localNode = localIgnite.GetCluster().GetLocalNode();
+ var localKey = Enumerable.Range(1, 10000).First(x => aff.IsPrimary(localNode, x));
+ localCache.Put(localKey, 1);
+ localCache.Get(localKey);
// Wait for metrics to propagate.
Thread.Sleep(TcpDiscoverySpi.DefaultHeartbeatFrequency);
