Skip to content

Commit e79ba29

Browse files
author
John Luo
authored
Prevent background process from crashing test when writing to… (#20254)
1 parent da4bd70 commit e79ba29

File tree

4 files changed

+22
-61
lines changed

4 files changed

+22
-61
lines changed

src/Grpc/Grpc.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteropWebsite", "test\test
1313
EndProject
1414
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InteropClient", "test\testassets\InteropClient\InteropClient.csproj", "{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}"
1515
EndProject
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependencies", "dependencies", "{285E2F1E-E0F9-47ED-BE43-6D84B9A49DA0}"
17+
EndProject
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Testing", "..\Testing\src\Microsoft.AspNetCore.Testing.csproj", "{3B2B746A-F12E-4E04-9782-6E12F855B50D}"
19+
EndProject
1620
Global
1721
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1822
Debug|Any CPU = Debug|Any CPU
@@ -31,6 +35,10 @@ Global
3135
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
3236
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
3337
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{3B2B746A-F12E-4E04-9782-6E12F855B50D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{3B2B746A-F12E-4E04-9782-6E12F855B50D}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{3B2B746A-F12E-4E04-9782-6E12F855B50D}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{3B2B746A-F12E-4E04-9782-6E12F855B50D}.Release|Any CPU.Build.0 = Release|Any CPU
3442
EndGlobalSection
3543
GlobalSection(SolutionProperties) = preSolution
3644
HideSolutionNode = FALSE
@@ -39,6 +47,7 @@ Global
3947
{90BF37E6-B3F1-4EFC-A233-8288D8B32DD2} = {0FFB3605-0203-450F-80C8-F82CA2E8269F}
4048
{3AB7E8E4-BA36-44CE-844E-39DB66E46D45} = {F5841B0A-901A-448F-9CC5-4CB393CE86AF}
4149
{66E6C55E-E4E3-4F4B-834A-BB34BFE00D2F} = {F5841B0A-901A-448F-9CC5-4CB393CE86AF}
50+
{3B2B746A-F12E-4E04-9782-6E12F855B50D} = {285E2F1E-E0F9-47ED-BE43-6D84B9A49DA0}
4251
EndGlobalSection
4352
GlobalSection(ExtensibilityGlobals) = postSolution
4453
SolutionGuid = {3CAE66FD-9A59-49C2-B133-1D599225259A}

src/Grpc/test/InteropTests/Helpers/InteropTestsFixture.cs

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/Grpc/test/InteropTests/InteropTests.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,34 @@
1414

1515
namespace InteropTests
1616
{
17-
public class InteropTests : IClassFixture<InteropTestsFixture>
17+
public class InteropTests
1818
{
1919
private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);
20-
2120
private readonly string _clientPath = Path.Combine(Directory.GetCurrentDirectory(), "InteropClient", "InteropClient.dll");
22-
private readonly InteropTestsFixture _fixture;
21+
private readonly string _serverPath = Path.Combine(Directory.GetCurrentDirectory(), "InteropWebsite", "InteropWebsite.dll");
2322
private readonly ITestOutputHelper _output;
2423

25-
public InteropTests(InteropTestsFixture fixture, ITestOutputHelper output)
24+
public InteropTests(ITestOutputHelper output)
2625
{
27-
var attributes = Assembly.GetExecutingAssembly()
28-
.GetCustomAttributes<AssemblyMetadataAttribute>();
29-
30-
fixture.Path = Path.Combine(Directory.GetCurrentDirectory(), "InteropWebsite", "InteropWebsite.dll");
31-
32-
_fixture = fixture;
3326
_output = output;
3427
}
3528

3629
[Theory]
3730
[MemberData(nameof(TestCaseData))]
3831
public async Task InteropTestCase(string name)
3932
{
40-
await _fixture.EnsureStarted(_output).TimeoutAfter(DefaultTimeout);
41-
42-
using (var clientProcess = new ClientProcess(_output, _clientPath, _fixture.ServerPort, name))
33+
using (var serverProcess = new WebsiteProcess(_serverPath, _output))
4334
{
44-
await clientProcess.WaitForReady().TimeoutAfter(DefaultTimeout);
35+
await serverProcess.WaitForReady().TimeoutAfter(DefaultTimeout);
36+
37+
using (var clientProcess = new ClientProcess(_output, _clientPath, serverProcess.ServerPort, name))
38+
{
39+
await clientProcess.WaitForReady().TimeoutAfter(DefaultTimeout);
4540

46-
await clientProcess.Exited.TimeoutAfter(DefaultTimeout);
41+
await clientProcess.Exited.TimeoutAfter(DefaultTimeout);
4742

48-
Assert.Equal(0, clientProcess.ExitCode);
43+
Assert.Equal(0, clientProcess.ExitCode);
44+
}
4945
}
5046
}
5147

src/Grpc/test/testassets/InteropClient/InteropClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private async Task<IChannelWrapper> HttpClientCreateChannel()
152152
}
153153

154154
var httpClientHandler = new HttpClientHandler();
155-
httpClientHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
155+
httpClientHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator!;
156156

157157
if (options.UseTestCa ?? false)
158158
{

0 commit comments

Comments
 (0)