mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 14:51:41 +01:00
Runtime + test stability
This commit is contained in:
parent
ee974940c0
commit
611199af83
@ -98,10 +98,7 @@ namespace Capnp.Net.Runtime.Tests
|
||||
[TestInitialize]
|
||||
public void PrepareNextTest()
|
||||
{
|
||||
if (++TcpPort >= 65534)
|
||||
{
|
||||
TcpPort = 49152;
|
||||
}
|
||||
IncrementTcpPort();
|
||||
}
|
||||
|
||||
[TestMethod, Timeout(10000)]
|
||||
|
@ -8,6 +8,7 @@ using Capnp.Rpc;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Capnp.Net.Runtime.Tests.GenImpls;
|
||||
using Capnproto_test.Capnp.Test;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Capnp.Net.Runtime.Tests
|
||||
{
|
||||
@ -470,7 +471,17 @@ namespace Capnp.Net.Runtime.Tests
|
||||
var call4 = pipeline.GetCallSequence(4, 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(call2.Wait(MediumNonDbgTimeout));
|
||||
Assert.IsTrue(call3.Wait(MediumNonDbgTimeout));
|
||||
|
@ -18,6 +18,7 @@ namespace Capnp.Net.Runtime.Tests
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Logger.LogTrace("Repetition {0}", i);
|
||||
IncrementTcpPort();
|
||||
action();
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,6 @@ namespace Capnp.Net.Runtime.Tests
|
||||
public static int LargeNonDbgTimeout => Debugger.IsAttached ? Timeout.Infinite : 20000;
|
||||
public static int ShortTimeout => 500;
|
||||
|
||||
public static int GetNextTcpPort()
|
||||
{
|
||||
if (++TcpPort == 65535)
|
||||
TcpPort = 49152;
|
||||
return TcpPort;
|
||||
}
|
||||
|
||||
protected ILogger Logger { get; set; }
|
||||
|
||||
protected TcpRpcClient SetupClient() => new TcpRpcClient("localhost", TcpPort);
|
||||
@ -37,6 +30,14 @@ namespace Capnp.Net.Runtime.Tests
|
||||
return (server, client);
|
||||
}
|
||||
|
||||
public static void IncrementTcpPort()
|
||||
{
|
||||
if (++TcpPort > 49200)
|
||||
{
|
||||
TcpPort = 49152;
|
||||
}
|
||||
}
|
||||
|
||||
[TestInitialize]
|
||||
public void InitConsoleLogging()
|
||||
{
|
||||
|
@ -193,19 +193,27 @@ namespace Capnp.Rpc
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
for (int retry = 0; retry < 5; ++retry)
|
||||
{
|
||||
if (!_acceptorThread.Join(500))
|
||||
try
|
||||
{
|
||||
Logger.LogError("Unable to join TCP acceptor thread within timeout");
|
||||
if (!_acceptorThread.Join(500))
|
||||
{
|
||||
Logger.LogError("Unable to join TCP acceptor thread within timeout");
|
||||
}
|
||||
break;
|
||||
}
|
||||
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)
|
||||
{
|
||||
Logger.LogError($"Unable to join TCP acceptor thread: {exception.Message}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (ThreadStateException)
|
||||
{
|
||||
}
|
||||
catch (System.Exception exception)
|
||||
{
|
||||
Logger.LogError($"Unable to join TCP acceptor thread: {exception.Message}");
|
||||
}
|
||||
}
|
||||
catch (ThreadStateException)
|
||||
|
Loading…
x
Reference in New Issue
Block a user