mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-14 15:51:43 +01:00
Runtime + test stability
This commit is contained in:
parent
ee974940c0
commit
611199af83
@ -98,10 +98,7 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void PrepareNextTest()
|
public void PrepareNextTest()
|
||||||
{
|
{
|
||||||
if (++TcpPort >= 65534)
|
IncrementTcpPort();
|
||||||
{
|
|
||||||
TcpPort = 49152;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod, Timeout(10000)]
|
[TestMethod, Timeout(10000)]
|
||||||
|
@ -8,6 +8,7 @@ using Capnp.Rpc;
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Capnp.Net.Runtime.Tests.GenImpls;
|
using Capnp.Net.Runtime.Tests.GenImpls;
|
||||||
using Capnproto_test.Capnp.Test;
|
using Capnproto_test.Capnp.Test;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Capnp.Net.Runtime.Tests
|
namespace Capnp.Net.Runtime.Tests
|
||||||
{
|
{
|
||||||
@ -470,7 +471,17 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
var call4 = pipeline.GetCallSequence(4, default);
|
var call4 = pipeline.GetCallSequence(4, default);
|
||||||
var call5 = pipeline.GetCallSequence(5, default);
|
var call5 = pipeline.GetCallSequence(5, default);
|
||||||
|
|
||||||
Assert.IsTrue(call0.Wait(MediumNonDbgTimeout));
|
try
|
||||||
|
{
|
||||||
|
bool flag = call0.Wait(MediumNonDbgTimeout);
|
||||||
|
Assert.IsTrue(flag);
|
||||||
|
}
|
||||||
|
catch (RpcException exception) when (exception.Message == "Cannot access a disposed object.")
|
||||||
|
{
|
||||||
|
Logger.Log(LogLevel.Information, $"Oops, object disposed. Counter = {cap.Count}, tx count = {client.SendCount}, rx count = {client.RecvCount}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
Assert.IsTrue(call1.Wait(MediumNonDbgTimeout));
|
Assert.IsTrue(call1.Wait(MediumNonDbgTimeout));
|
||||||
Assert.IsTrue(call2.Wait(MediumNonDbgTimeout));
|
Assert.IsTrue(call2.Wait(MediumNonDbgTimeout));
|
||||||
Assert.IsTrue(call3.Wait(MediumNonDbgTimeout));
|
Assert.IsTrue(call3.Wait(MediumNonDbgTimeout));
|
||||||
|
@ -18,6 +18,7 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
Logger.LogTrace("Repetition {0}", i);
|
Logger.LogTrace("Repetition {0}", i);
|
||||||
|
IncrementTcpPort();
|
||||||
action();
|
action();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,6 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
public static int LargeNonDbgTimeout => Debugger.IsAttached ? Timeout.Infinite : 20000;
|
public static int LargeNonDbgTimeout => Debugger.IsAttached ? Timeout.Infinite : 20000;
|
||||||
public static int ShortTimeout => 500;
|
public static int ShortTimeout => 500;
|
||||||
|
|
||||||
public static int GetNextTcpPort()
|
|
||||||
{
|
|
||||||
if (++TcpPort == 65535)
|
|
||||||
TcpPort = 49152;
|
|
||||||
return TcpPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ILogger Logger { get; set; }
|
protected ILogger Logger { get; set; }
|
||||||
|
|
||||||
protected TcpRpcClient SetupClient() => new TcpRpcClient("localhost", TcpPort);
|
protected TcpRpcClient SetupClient() => new TcpRpcClient("localhost", TcpPort);
|
||||||
@ -37,6 +30,14 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
return (server, client);
|
return (server, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void IncrementTcpPort()
|
||||||
|
{
|
||||||
|
if (++TcpPort > 49200)
|
||||||
|
{
|
||||||
|
TcpPort = 49152;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void InitConsoleLogging()
|
public void InitConsoleLogging()
|
||||||
{
|
{
|
||||||
|
@ -192,6 +192,8 @@ namespace Capnp.Rpc
|
|||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
for (int retry = 0; retry < 5; ++retry)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -199,13 +201,19 @@ namespace Capnp.Rpc
|
|||||||
{
|
{
|
||||||
Logger.LogError("Unable to join TCP acceptor thread within timeout");
|
Logger.LogError("Unable to join TCP acceptor thread within timeout");
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
catch (ThreadStateException)
|
catch (ThreadStateException)
|
||||||
{
|
{
|
||||||
|
// In rare cases it happens that despite _acceptorThread.Start() was called, the thread did not actually start yet.
|
||||||
|
Logger.LogDebug("Waiting for TCP acceptor thread to start in order to join it");
|
||||||
|
Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
catch (System.Exception exception)
|
catch (System.Exception exception)
|
||||||
{
|
{
|
||||||
Logger.LogError($"Unable to join TCP acceptor thread: {exception.Message}");
|
Logger.LogError($"Unable to join TCP acceptor thread: {exception.Message}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ThreadStateException)
|
catch (ThreadStateException)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user