Merge branch 'troy/quickfix' into rel/1.0.0
This commit is contained in:
commit
2f53c23738
2 changed files with 32 additions and 14 deletions
|
@ -9,6 +9,7 @@ using System.Net;
|
|||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
|
||||
|
@ -20,7 +21,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
private readonly BinaryReader _reader;
|
||||
private readonly BinaryWriter _writer;
|
||||
private readonly NetworkStream _networkStream;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly BlockingCollection<DthMessage> _messageQueue;
|
||||
private readonly CancellationTokenSource _readCancellationToken;
|
||||
|
||||
|
@ -31,11 +32,13 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
private int _nextContextId;
|
||||
private readonly Socket _socket;
|
||||
|
||||
public DthTestClient(DthTestServer server)
|
||||
public DthTestClient(DthTestServer server, ILoggerFactory loggerFactory)
|
||||
{
|
||||
// Avoid Socket exception 10006 on Linux
|
||||
Thread.Sleep(100);
|
||||
|
||||
_logger = loggerFactory.CreateLogger<DthTestClient>();
|
||||
|
||||
_socket = new Socket(AddressFamily.InterNetwork,
|
||||
SocketType.Stream,
|
||||
ProtocolType.Tcp);
|
||||
|
@ -225,7 +228,18 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
_writer.Dispose();
|
||||
_networkStream.Dispose();
|
||||
_readCancellationToken.Cancel();
|
||||
_socket.Shutdown(SocketShutdown.Both);
|
||||
|
||||
try
|
||||
{
|
||||
_socket.Shutdown(SocketShutdown.Both);
|
||||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
// Swallow this error for now.
|
||||
// This is a temporary fix for a random failure on CI. The issue happens on Windowx x86
|
||||
// only.
|
||||
_logger.LogError($"Exception thrown durning socket shutting down: {ex.SocketErrorCode}.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadMessage(CancellationToken cancellationToken)
|
||||
|
|
|
@ -39,6 +39,10 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
{
|
||||
_loggerFactory.AddConsole(LogLevel.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loggerFactory.AddConsole(LogLevel.Error);
|
||||
}
|
||||
|
||||
_testAssetsManager = new TestAssetsManager(
|
||||
Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "DthTestProjects", "src"));
|
||||
|
@ -51,7 +55,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
Assert.NotNull(projectPath);
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
|
||||
|
@ -81,7 +85,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
public void DthStartup_ProtocolNegotiation(int requestVersion, int expectVersion)
|
||||
{
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
client.SetProtocolVersion(requestVersion);
|
||||
|
||||
|
@ -96,7 +100,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
public void DthStartup_ProtocolNegotiation_ZeroIsNoAllowed()
|
||||
{
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
client.SetProtocolVersion(0);
|
||||
|
||||
|
@ -126,7 +130,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
Assert.NotNull(projectPath);
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
|
||||
|
@ -180,7 +184,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
public void DthNegative_BrokenProjectPathInLockFile()
|
||||
{
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
// After restore the project is copied to another place so that
|
||||
// the relative path in project lock file is invalid.
|
||||
|
@ -214,7 +218,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
Assert.True(Directory.Exists(projectPath));
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
var testProject = Path.Combine(projectPath, "home", "src", "MainProject");
|
||||
|
||||
|
@ -271,7 +275,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
var projectPath = _testAssetsManager.CreateTestInstance("EmptyConsoleApp").TestRoot;
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
client.Initialize(projectPath);
|
||||
var messages = client.DrainAllMessages();
|
||||
|
@ -297,7 +301,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
var testSource = assetsManager.CreateTestInstance("IncorrectProjectJson").TestRoot;
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
client.Initialize(Path.Combine(_testAssetsManager.AssetsRoot, "EmptyLibrary"));
|
||||
client.Initialize(testSource);
|
||||
|
@ -330,7 +334,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
var testSource = assetsManager.CreateTestInstance("IncorrectGlobalJson");
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
client.Initialize(Path.Combine(testSource.TestRoot, "src", "Project1"));
|
||||
|
||||
|
@ -349,7 +353,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
.TestRoot;
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
var projectFile = Path.Combine(testProject, Project.FileName);
|
||||
var content = File.ReadAllText(projectFile);
|
||||
|
@ -376,7 +380,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
|||
.TestRoot;
|
||||
|
||||
using (var server = new DthTestServer(_loggerFactory))
|
||||
using (var client = new DthTestClient(server))
|
||||
using (var client = new DthTestClient(server, _loggerFactory))
|
||||
{
|
||||
var lockFilePath = Path.Combine(testProject, LockFile.FileName);
|
||||
var lockFileContent = File.ReadAllText(lockFilePath);
|
||||
|
|
Loading…
Reference in a new issue