Prevent background process from crashing test when writing to… (#20254)
This commit is contained in:
parent
da4bd70813
commit
e79ba297fd
|
|
@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteropWebsite", "test\test
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteropClient", "test\testassets\InteropClient\InteropClient.csproj", "{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteropClient", "test\testassets\InteropClient\InteropClient.csproj", "{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependencies", "dependencies", "{285E2F1E-E0F9-47ED-BE43-6D84B9A49DA0}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Testing", "..\Testing\src\Microsoft.AspNetCore.Testing.csproj", "{3B2B746A-F12E-4E04-9782-6E12F855B50D}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
@ -31,6 +35,10 @@ Global
|
||||||
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3B2B746A-F12E-4E04-9782-6E12F855B50D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3B2B746A-F12E-4E04-9782-6E12F855B50D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3B2B746A-F12E-4E04-9782-6E12F855B50D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3B2B746A-F12E-4E04-9782-6E12F855B50D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
@ -39,6 +47,7 @@ Global
|
||||||
{90BF37E6-B3F1-4EFC-A233-8288D8B32DD2} = {0FFB3605-0203-450F-80C8-F82CA2E8269F}
|
{90BF37E6-B3F1-4EFC-A233-8288D8B32DD2} = {0FFB3605-0203-450F-80C8-F82CA2E8269F}
|
||||||
{3AB7E8E4-BA36-44CE-844E-39DB66E46D45} = {F5841B0A-901A-448F-9CC5-4CB393CE86AF}
|
{3AB7E8E4-BA36-44CE-844E-39DB66E46D45} = {F5841B0A-901A-448F-9CC5-4CB393CE86AF}
|
||||||
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F} = {F5841B0A-901A-448F-9CC5-4CB393CE86AF}
|
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F} = {F5841B0A-901A-448F-9CC5-4CB393CE86AF}
|
||||||
|
{3B2B746A-F12E-4E04-9782-6E12F855B50D} = {285E2F1E-E0F9-47ED-BE43-6D84B9A49DA0}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {3CAE66FD-9A59-49C2-B133-1D599225259A}
|
SolutionGuid = {3CAE66FD-9A59-49C2-B133-1D599225259A}
|
||||||
|
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Xunit.Abstractions;
|
|
||||||
|
|
||||||
namespace InteropTests.Helpers
|
|
||||||
{
|
|
||||||
public class InteropTestsFixture : IDisposable
|
|
||||||
{
|
|
||||||
private WebsiteProcess _process;
|
|
||||||
|
|
||||||
public string Path { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public string ServerPort { get; private set; }
|
|
||||||
|
|
||||||
|
|
||||||
public async Task EnsureStarted(ITestOutputHelper output)
|
|
||||||
{
|
|
||||||
if (_process != null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(Path))
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Path has not been set.");
|
|
||||||
}
|
|
||||||
|
|
||||||
_process = new WebsiteProcess(Path, output);
|
|
||||||
|
|
||||||
await _process.WaitForReady();
|
|
||||||
|
|
||||||
ServerPort = _process.ServerPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_process.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -14,22 +14,15 @@ using Xunit.Abstractions;
|
||||||
|
|
||||||
namespace InteropTests
|
namespace InteropTests
|
||||||
{
|
{
|
||||||
public class InteropTests : IClassFixture<InteropTestsFixture>
|
public class InteropTests
|
||||||
{
|
{
|
||||||
private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);
|
private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);
|
||||||
|
|
||||||
private readonly string _clientPath = Path.Combine(Directory.GetCurrentDirectory(), "InteropClient", "InteropClient.dll");
|
private readonly string _clientPath = Path.Combine(Directory.GetCurrentDirectory(), "InteropClient", "InteropClient.dll");
|
||||||
private readonly InteropTestsFixture _fixture;
|
private readonly string _serverPath = Path.Combine(Directory.GetCurrentDirectory(), "InteropWebsite", "InteropWebsite.dll");
|
||||||
private readonly ITestOutputHelper _output;
|
private readonly ITestOutputHelper _output;
|
||||||
|
|
||||||
public InteropTests(InteropTestsFixture fixture, ITestOutputHelper output)
|
public InteropTests(ITestOutputHelper output)
|
||||||
{
|
{
|
||||||
var attributes = Assembly.GetExecutingAssembly()
|
|
||||||
.GetCustomAttributes<AssemblyMetadataAttribute>();
|
|
||||||
|
|
||||||
fixture.Path = Path.Combine(Directory.GetCurrentDirectory(), "InteropWebsite", "InteropWebsite.dll");
|
|
||||||
|
|
||||||
_fixture = fixture;
|
|
||||||
_output = output;
|
_output = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,15 +30,18 @@ namespace InteropTests
|
||||||
[MemberData(nameof(TestCaseData))]
|
[MemberData(nameof(TestCaseData))]
|
||||||
public async Task InteropTestCase(string name)
|
public async Task InteropTestCase(string name)
|
||||||
{
|
{
|
||||||
await _fixture.EnsureStarted(_output).TimeoutAfter(DefaultTimeout);
|
using (var serverProcess = new WebsiteProcess(_serverPath, _output))
|
||||||
|
|
||||||
using (var clientProcess = new ClientProcess(_output, _clientPath, _fixture.ServerPort, name))
|
|
||||||
{
|
{
|
||||||
await clientProcess.WaitForReady().TimeoutAfter(DefaultTimeout);
|
await serverProcess.WaitForReady().TimeoutAfter(DefaultTimeout);
|
||||||
|
|
||||||
await clientProcess.Exited.TimeoutAfter(DefaultTimeout);
|
using (var clientProcess = new ClientProcess(_output, _clientPath, serverProcess.ServerPort, name))
|
||||||
|
{
|
||||||
|
await clientProcess.WaitForReady().TimeoutAfter(DefaultTimeout);
|
||||||
|
|
||||||
Assert.Equal(0, clientProcess.ExitCode);
|
await clientProcess.Exited.TimeoutAfter(DefaultTimeout);
|
||||||
|
|
||||||
|
Assert.Equal(0, clientProcess.ExitCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ namespace InteropTestsClient
|
||||||
}
|
}
|
||||||
|
|
||||||
var httpClientHandler = new HttpClientHandler();
|
var httpClientHandler = new HttpClientHandler();
|
||||||
httpClientHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
|
httpClientHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator!;
|
||||||
|
|
||||||
if (options.UseTestCa ?? false)
|
if (options.UseTestCa ?? false)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue