Log the Socket error code
This commit is contained in:
parent
d82c2f557a
commit
1b8d69abc1
2 changed files with 11 additions and 3 deletions
|
@ -9,6 +9,7 @@ using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||||
private readonly BinaryReader _reader;
|
private readonly BinaryReader _reader;
|
||||||
private readonly BinaryWriter _writer;
|
private readonly BinaryWriter _writer;
|
||||||
private readonly NetworkStream _networkStream;
|
private readonly NetworkStream _networkStream;
|
||||||
|
private readonly ILogger _logger;
|
||||||
private readonly BlockingCollection<DthMessage> _messageQueue;
|
private readonly BlockingCollection<DthMessage> _messageQueue;
|
||||||
private readonly CancellationTokenSource _readCancellationToken;
|
private readonly CancellationTokenSource _readCancellationToken;
|
||||||
|
|
||||||
|
@ -31,11 +32,13 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||||
private int _nextContextId;
|
private int _nextContextId;
|
||||||
private readonly Socket _socket;
|
private readonly Socket _socket;
|
||||||
|
|
||||||
public DthTestClient(DthTestServer server)
|
public DthTestClient(DthTestServer server, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
// Avoid Socket exception 10006 on Linux
|
// Avoid Socket exception 10006 on Linux
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
|
|
||||||
|
_logger = loggerFactory.CreateLogger<DthTestClient>();
|
||||||
|
|
||||||
_socket = new Socket(AddressFamily.InterNetwork,
|
_socket = new Socket(AddressFamily.InterNetwork,
|
||||||
SocketType.Stream,
|
SocketType.Stream,
|
||||||
ProtocolType.Tcp);
|
ProtocolType.Tcp);
|
||||||
|
@ -230,11 +233,12 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||||
{
|
{
|
||||||
_socket.Shutdown(SocketShutdown.Both);
|
_socket.Shutdown(SocketShutdown.Both);
|
||||||
}
|
}
|
||||||
catch (SocketException)
|
catch (SocketException ex)
|
||||||
{
|
{
|
||||||
// Swallow this error for now.
|
// Swallow this error for now.
|
||||||
// This is a temporary fix for a random failure on CI. The issue happens on Windowx x86
|
// This is a temporary fix for a random failure on CI. The issue happens on Windowx x86
|
||||||
// only.
|
// only.
|
||||||
|
_logger.LogError($"Exception thrown durning socket shutting down: {ex.SocketErrorCode}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,10 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||||
{
|
{
|
||||||
_loggerFactory.AddConsole(LogLevel.Warning);
|
_loggerFactory.AddConsole(LogLevel.Warning);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_loggerFactory.AddConsole(LogLevel.Error);
|
||||||
|
}
|
||||||
|
|
||||||
_testAssetsManager = new TestAssetsManager(
|
_testAssetsManager = new TestAssetsManager(
|
||||||
Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "DthTestProjects", "src"));
|
Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "DthTestProjects", "src"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue