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 2021/11/25 10:33:34 UTC
[ignite] branch master updated: IGNITE-15986 .NET: Fix ClientConnectionTest.TestFailover flakiness (#9597)
This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 4e1477f IGNITE-15986 .NET: Fix ClientConnectionTest.TestFailover flakiness (#9597)
4e1477f is described below
commit 4e1477f186e08ce99dc409aa0e4cf6e666dd0c00
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Thu Nov 25 13:32:54 2021 +0300
IGNITE-15986 .NET: Fix ClientConnectionTest.TestFailover flakiness (#9597)
* Fix `TestFailover` flakiness.
* Fix `TestServerConnectionAborted` flakiness.
* Fix IDE warnings.
---
.../Cache/Platform/PlatformCacheTest.cs | 1 +
.../Client/ClientConnectionTest.cs | 41 +++++++++++++++-------
.../Services/CallPlatformServiceTest.cs | 1 +
.../Services/ServiceProxyTest.cs | 10 +++---
.../Services/ServicesAsyncWrapper.cs | 7 ++--
.../Impl/Services/ServiceContext.cs | 8 ++---
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 3 +-
.../Services/ServiceCallContextBuilder.cs | 7 ++--
8 files changed, 46 insertions(+), 32 deletions(-)
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Platform/PlatformCacheTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Platform/PlatformCacheTest.cs
index 74e2770..ccfc834 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Platform/PlatformCacheTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Platform/PlatformCacheTest.cs
@@ -15,6 +15,7 @@
* limitations under the License.
*/
+// ReSharper disable LoopVariableIsNeverChangedInsideLoop
namespace Apache.Ignite.Core.Tests.Cache.Platform
{
using System;
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
index 0cfe809..b7c65bb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
@@ -381,7 +381,7 @@ namespace Apache.Ignite.Core.Tests.Client
{
Assert.Contains(
socketEx.SocketErrorCode,
- new[] {SocketError.ConnectionAborted, SocketError.ConnectionReset});
+ new[] {SocketError.ConnectionAborted, SocketError.ConnectionReset, SocketError.ConnectionRefused});
}
else
{
@@ -596,32 +596,47 @@ namespace Apache.Ignite.Core.Tests.Client
}
};
+ // ReSharper disable AccessToDisposedClosure
using (var client = Ignition.StartClient(cfg))
{
Assert.AreEqual(0, client.GetCacheNames().Count);
- // Stop target node.
+ Action checkReconnect = () =>
+ {
+ // First operation may fail or may not.
+ // Sometimes the client will switch to another socket in background due to
+ // OnAffinityTopologyVersionChange callback.
+ var timeout = DateTime.Now.AddSeconds(0.3);
+
+ while (DateTime.Now < timeout)
+ {
+ try
+ {
+ Assert.AreEqual(0, client.GetCacheNames().Count);
+ break;
+ }
+ catch (Exception e)
+ {
+ Assert.IsNotNull(GetSocketException(e));
+ }
+ }
+ };
+
+ // Stop first node.
var nodeId = ((IPEndPoint) client.RemoteEndPoint).Port - port;
Ignition.Stop(nodeId.ToString(), true);
- // Check failure.
- Assert.IsNotNull(GetSocketException(Assert.Catch(() => client.GetCacheNames())));
-
- // Check reconnect.
- Assert.AreEqual(0, client.GetCacheNames().Count);
+ checkReconnect();
- // Stop target node.
+ // Stop second node.
nodeId = ((IPEndPoint) client.RemoteEndPoint).Port - port;
Ignition.Stop(nodeId.ToString(), true);
- // Check failure.
- Assert.IsNotNull(GetSocketException(Assert.Catch(() => client.GetCacheNames())));
-
- // Check reconnect.
- Assert.AreEqual(0, client.GetCacheNames().Count);
+ checkReconnect();
// Stop all nodes.
Ignition.StopAll(true);
+
Assert.IsNotNull(GetSocketException(Assert.Catch(() => client.GetCacheNames())));
Assert.IsNotNull(GetSocketException(Assert.Catch(() => client.GetCacheNames())));
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/CallPlatformServiceTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/CallPlatformServiceTest.cs
index 78dc48e..264ac93 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/CallPlatformServiceTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/CallPlatformServiceTest.cs
@@ -165,6 +165,7 @@ namespace Apache.Ignite.Core.Tests.Services
BinarizableTestValue AddOne(BinarizableTestValue val);
/** */
+ // ReSharper disable once InconsistentNaming
string contextAttribute(string name);
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
index 37ca0f7..bc6ec70 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
@@ -214,7 +214,7 @@ namespace Apache.Ignite.Core.Tests.Services
public void TestBinarizableMarshallingException()
{
var prx = GetProxy();
-
+
var ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionBinarizableMethod(false, false));
if (KeepBinary)
@@ -293,9 +293,9 @@ namespace Apache.Ignite.Core.Tests.Services
// 2) call InvokeServiceMethod
string mthdName;
object[] mthdArgs;
- IServiceCallContext callCtx;
+ IServiceCallContext unused;
- ServiceProxySerializer.ReadProxyMethod(inStream, _marsh, out mthdName, out mthdArgs, out callCtx);
+ ServiceProxySerializer.ReadProxyMethod(inStream, _marsh, out mthdName, out mthdArgs, out unused);
var result = ServiceProxyInvoker.InvokeServiceMethod(_svc, mthdName, mthdArgs);
@@ -759,7 +759,7 @@ namespace Apache.Ignite.Core.Tests.Services
public void TestBinarizableMethods()
{
var prx = GetProxy();
-
+
var obj = new TestBinarizableClass { Prop = "PropValue" };
var portObj = Binary.ToBinary<IBinaryObject>(obj);
@@ -768,4 +768,4 @@ namespace Apache.Ignite.Core.Tests.Services
Assert.AreEqual(obj.Prop, result.Deserialize<TestBinarizableClass>().Prop);
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
index a99ca37..6b834bf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
@@ -18,7 +18,6 @@
namespace Apache.Ignite.Core.Tests.Services
{
using System;
- using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using Apache.Ignite.Core.Cluster;
@@ -193,7 +192,7 @@ namespace Apache.Ignite.Core.Tests.Services
{
return _services.GetServiceProxy<T>(name, sticky);
}
-
+
/** <inheritDoc /> */
public T GetServiceProxy<T>(string name, bool sticky, IServiceCallContext callCtx) where T : class
{
@@ -211,7 +210,7 @@ namespace Apache.Ignite.Core.Tests.Services
{
return _services.GetDynamicServiceProxy(name, sticky);
}
-
+
/** <inheritDoc /> */
public dynamic GetDynamicServiceProxy(string name, bool sticky, IServiceCallContext callCtx)
{
@@ -230,4 +229,4 @@ namespace Apache.Ignite.Core.Tests.Services
return new ServicesAsyncWrapper(_services.WithServerKeepBinary());
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
index 94a6ac8..3c9276f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceContext.cs
@@ -29,7 +29,7 @@ namespace Apache.Ignite.Core.Impl.Services
internal class ServiceContext : IServiceContext
{
/** Service call context of the current thread. */
- private static readonly ThreadLocal<IServiceCallContext> locCallCtx = new ThreadLocal<IServiceCallContext>();
+ private static readonly ThreadLocal<IServiceCallContext> LocalCallContext = new ThreadLocal<IServiceCallContext>();
/// <summary>
/// Initializes a new instance of the <see cref="ServiceContext"/> class.
@@ -64,7 +64,7 @@ namespace Apache.Ignite.Core.Impl.Services
/** <inheritdoc /> */
public IServiceCallContext CurrentCallContext
{
- get { return locCallCtx.Value; }
+ get { return LocalCallContext.Value; }
}
/// <summary>
@@ -72,7 +72,7 @@ namespace Apache.Ignite.Core.Impl.Services
/// </summary>
/// <param name="callCtx">Service call context for the current thread.</param>
internal static void SetCurrentCallContext(IServiceCallContext callCtx) {
- locCallCtx.Value = callCtx;
+ LocalCallContext.Value = callCtx;
}
}
-}
\ No newline at end of file
+}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index c26a441..da5efd4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -18,7 +18,6 @@
namespace Apache.Ignite.Core.Impl.Unmanaged
{
using System;
- using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
@@ -1109,7 +1108,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
IServiceCallContext callCtx;
ServiceProxySerializer.ReadProxyMethod(stream, _ignite.Marshaller, out mthdName, out mthdArgs, out callCtx);
-
+
if (callCtx != null)
ServiceContext.SetCurrentCallContext(callCtx);
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Services/ServiceCallContextBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Services/ServiceCallContextBuilder.cs
index 2f0604c..e385683 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Services/ServiceCallContextBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Services/ServiceCallContextBuilder.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Services
{
using System;
using System.Collections;
- using System.Linq;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Services;
@@ -32,7 +31,7 @@ namespace Apache.Ignite.Core.Services
{
/** Context attributes. */
private readonly Hashtable _attrs = new Hashtable();
-
+
/// <summary>
/// Set string attribute.
/// </summary>
@@ -63,7 +62,7 @@ namespace Apache.Ignite.Core.Services
IgniteArgumentCheck.NotNull(value, "value");
_attrs[name] = value;
-
+
return this;
}
@@ -79,4 +78,4 @@ namespace Apache.Ignite.Core.Services
return new ServiceCallContext((Hashtable)_attrs.Clone());
}
}
-}
\ No newline at end of file
+}