This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new dfeefe472e IGNITE-23757 .NET: Fix
TestDroppedConnectionsAreRestoredInBackground flakiness (#4783)
dfeefe472e is described below
commit dfeefe472e64f7639b937c50819ab5dcedc9e301
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Mon Nov 25 10:29:02 2024 +0200
IGNITE-23757 .NET: Fix TestDroppedConnectionsAreRestoredInBackground
flakiness (#4783)
Add `IgniteServerBase.AllowMultipleConnections` (default false) to speed up
tests based on `FakeServer`.
---
.../Apache.Ignite.Tests/IgniteClientGroupTests.cs | 5 ++++-
.../dotnet/Apache.Ignite.Tests/IgniteServerBase.cs | 19 +++++++++++++++----
.../dotnet/Apache.Ignite.Tests/ReconnectTests.cs | 1 +
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git
a/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteClientGroupTests.cs
b/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteClientGroupTests.cs
index fbe37172fa..1137bb7b9b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteClientGroupTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteClientGroupTests.cs
@@ -29,7 +29,10 @@ public class IgniteClientGroupTests
private FakeServer _server;
[SetUp]
- public void StartServer() => _server = new FakeServer();
+ public void StartServer() => _server = new FakeServer
+ {
+ AllowMultipleConnections = true
+ };
[TearDown]
public void StopServer() => _server.Dispose();
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteServerBase.cs
b/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteServerBase.cs
index c57101e404..de05e6da3e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteServerBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/IgniteServerBase.cs
@@ -59,6 +59,8 @@ public abstract class IgniteServerBase : IDisposable
public string Endpoint => "127.0.0.1:" + Port;
+ public bool AllowMultipleConnections { get; set; }
+
public bool DropNewConnections
{
get => _dropNewConnections;
@@ -174,6 +176,8 @@ public abstract class IgniteServerBase : IDisposable
while (!_cts.IsCancellationRequested)
{
Socket handler = _listener.Accept();
+ handler.NoDelay = true;
+
if (DropNewConnections)
{
handler.Disconnect(true);
@@ -184,17 +188,24 @@ public abstract class IgniteServerBase : IDisposable
_handlers[handler] = null;
- Task.Run(() =>
+ var handleAction = () =>
{
using (handler)
{
- handler.NoDelay = true;
-
Handle(handler, _cts.Token);
handler.Disconnect(true);
_handlers.TryRemove(handler, out _);
}
- });
+ };
+
+ if (AllowMultipleConnections)
+ {
+ Task.Run(handleAction);
+ }
+ else
+ {
+ handleAction();
+ }
}
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/ReconnectTests.cs
b/modules/platforms/dotnet/Apache.Ignite.Tests/ReconnectTests.cs
index 1c04272072..922ed13670 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/ReconnectTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/ReconnectTests.cs
@@ -86,6 +86,7 @@ public class ReconnectTests
}
[Test]
+ [Timeout(30_000)]
public async Task TestDroppedConnectionsAreRestoredInBackground()
{
var cfg = new IgniteClientConfiguration