Skip to content

Commit 92b90fd

Browse files
authored
Deflaking a lot of tests (#10960)
1 parent 7a8487e commit 92b90fd

File tree

7 files changed

+133
-21
lines changed

7 files changed

+133
-21
lines changed

src/Servers/FunctionalTests.sln

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerComparison.TestSites"
2525
EndProject
2626
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IIS", "IIS\IIS\src\Microsoft.AspNetCore.Server.IIS.csproj", "{5DAF9603-999A-4759-AEE4-5E0F4D6D9AF7}"
2727
EndProject
28+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IntegrationTesting.IIS", "IIS\IntegrationTesting.IIS\src\Microsoft.AspNetCore.Server.IntegrationTesting.IIS.csproj", "{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}"
29+
EndProject
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.Negotiate", "..\Security\Authentication\Negotiate\src\Microsoft.AspNetCore.Authentication.Negotiate.csproj", "{F3BAB460-05C9-417A-BFDF-4FE93055A915}"
31+
EndProject
32+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication", "..\Security\Authentication\Core\src\Microsoft.AspNetCore.Authentication.csproj", "{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}"
33+
EndProject
34+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.DataProtection", "..\DataProtection\DataProtection\src\Microsoft.AspNetCore.DataProtection.csproj", "{81827F08-E8C8-4366-8E0D-6F2C832371F1}"
35+
EndProject
36+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.DataProtection.Abstractions", "..\DataProtection\Abstractions\src\Microsoft.AspNetCore.DataProtection.Abstractions.csproj", "{AA9993DE-EE40-4884-AA5B-1A5AB630B123}"
37+
EndProject
38+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Cryptography.Internal", "..\DataProtection\Cryptography.Internal\src\Microsoft.AspNetCore.Cryptography.Internal.csproj", "{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}"
39+
EndProject
2840
Global
2941
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3042
Debug|Any CPU = Debug|Any CPU
@@ -153,6 +165,78 @@ Global
153165
{5DAF9603-999A-4759-AEE4-5E0F4D6D9AF7}.Release|x64.Build.0 = Release|Any CPU
154166
{5DAF9603-999A-4759-AEE4-5E0F4D6D9AF7}.Release|x86.ActiveCfg = Release|Any CPU
155167
{5DAF9603-999A-4759-AEE4-5E0F4D6D9AF7}.Release|x86.Build.0 = Release|Any CPU
168+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
169+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Debug|Any CPU.Build.0 = Debug|Any CPU
170+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Debug|x64.ActiveCfg = Debug|Any CPU
171+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Debug|x64.Build.0 = Debug|Any CPU
172+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Debug|x86.ActiveCfg = Debug|Any CPU
173+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Debug|x86.Build.0 = Debug|Any CPU
174+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Release|Any CPU.ActiveCfg = Release|Any CPU
175+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Release|Any CPU.Build.0 = Release|Any CPU
176+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Release|x64.ActiveCfg = Release|Any CPU
177+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Release|x64.Build.0 = Release|Any CPU
178+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Release|x86.ActiveCfg = Release|Any CPU
179+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815}.Release|x86.Build.0 = Release|Any CPU
180+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
181+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Debug|Any CPU.Build.0 = Debug|Any CPU
182+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Debug|x64.ActiveCfg = Debug|Any CPU
183+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Debug|x64.Build.0 = Debug|Any CPU
184+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Debug|x86.ActiveCfg = Debug|Any CPU
185+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Debug|x86.Build.0 = Debug|Any CPU
186+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Release|Any CPU.ActiveCfg = Release|Any CPU
187+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Release|Any CPU.Build.0 = Release|Any CPU
188+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Release|x64.ActiveCfg = Release|Any CPU
189+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Release|x64.Build.0 = Release|Any CPU
190+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Release|x86.ActiveCfg = Release|Any CPU
191+
{F3BAB460-05C9-417A-BFDF-4FE93055A915}.Release|x86.Build.0 = Release|Any CPU
192+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
193+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
194+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Debug|x64.ActiveCfg = Debug|Any CPU
195+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Debug|x64.Build.0 = Debug|Any CPU
196+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Debug|x86.ActiveCfg = Debug|Any CPU
197+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Debug|x86.Build.0 = Debug|Any CPU
198+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
199+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Release|Any CPU.Build.0 = Release|Any CPU
200+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Release|x64.ActiveCfg = Release|Any CPU
201+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Release|x64.Build.0 = Release|Any CPU
202+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Release|x86.ActiveCfg = Release|Any CPU
203+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE}.Release|x86.Build.0 = Release|Any CPU
204+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
205+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
206+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Debug|x64.ActiveCfg = Debug|Any CPU
207+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Debug|x64.Build.0 = Debug|Any CPU
208+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Debug|x86.ActiveCfg = Debug|Any CPU
209+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Debug|x86.Build.0 = Debug|Any CPU
210+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
211+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Release|Any CPU.Build.0 = Release|Any CPU
212+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Release|x64.ActiveCfg = Release|Any CPU
213+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Release|x64.Build.0 = Release|Any CPU
214+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Release|x86.ActiveCfg = Release|Any CPU
215+
{81827F08-E8C8-4366-8E0D-6F2C832371F1}.Release|x86.Build.0 = Release|Any CPU
216+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
217+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Debug|Any CPU.Build.0 = Debug|Any CPU
218+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Debug|x64.ActiveCfg = Debug|Any CPU
219+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Debug|x64.Build.0 = Debug|Any CPU
220+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Debug|x86.ActiveCfg = Debug|Any CPU
221+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Debug|x86.Build.0 = Debug|Any CPU
222+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Release|Any CPU.ActiveCfg = Release|Any CPU
223+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Release|Any CPU.Build.0 = Release|Any CPU
224+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Release|x64.ActiveCfg = Release|Any CPU
225+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Release|x64.Build.0 = Release|Any CPU
226+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Release|x86.ActiveCfg = Release|Any CPU
227+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123}.Release|x86.Build.0 = Release|Any CPU
228+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
229+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
230+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Debug|x64.ActiveCfg = Debug|Any CPU
231+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Debug|x64.Build.0 = Debug|Any CPU
232+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Debug|x86.ActiveCfg = Debug|Any CPU
233+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Debug|x86.Build.0 = Debug|Any CPU
234+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
235+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Release|Any CPU.Build.0 = Release|Any CPU
236+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Release|x64.ActiveCfg = Release|Any CPU
237+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Release|x64.Build.0 = Release|Any CPU
238+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Release|x86.ActiveCfg = Release|Any CPU
239+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC}.Release|x86.Build.0 = Release|Any CPU
156240
EndGlobalSection
157241
GlobalSection(SolutionProperties) = preSolution
158242
HideSolutionNode = FALSE
@@ -166,6 +250,12 @@ Global
166250
{9DD063D3-CAE1-49C2-9C24-DE3499E79322} = {25B4D0F2-96D1-4F34-896E-ABA1E803A230}
167251
{0DD5F47B-EDA3-405A-A2F3-08CB2566E30D} = {25B4D0F2-96D1-4F34-896E-ABA1E803A230}
168252
{5DAF9603-999A-4759-AEE4-5E0F4D6D9AF7} = {25B4D0F2-96D1-4F34-896E-ABA1E803A230}
253+
{689572FA-D5BA-4C70-94EA-C7CD3C1F2815} = {25B4D0F2-96D1-4F34-896E-ABA1E803A230}
254+
{F3BAB460-05C9-417A-BFDF-4FE93055A915} = {25B4D0F2-96D1-4F34-896E-ABA1E803A230}
255+
{0F15D893-B455-4D44-8F00-AFCA9D90C1BE} = {25B4D0F2-96D1-4F34-896E-ABA1E803A230}
256+
{81827F08-E8C8-4366-8E0D-6F2C832371F1} = {25B4D0F2-96D1-4F34-896E-ABA1E803A230}
257+
{AA9993DE-EE40-4884-AA5B-1A5AB630B123} = {25B4D0F2-96D1-4F34-896E-ABA1E803A230}
258+
{DB802A16-1630-4C3D-A366-EB96A2C5AEBC} = {25B4D0F2-96D1-4F34-896E-ABA1E803A230}
169259
EndGlobalSection
170260
GlobalSection(ExtensibilityGlobals) = postSolution
171261
SolutionGuid = {F4D963C1-44FE-45AE-9B2A-11CD86C7539F}

src/Servers/IIS/IIS/test/Common.FunctionalTests/AppOfflineTests.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,10 @@ public async Task AppOfflineDroppedWhileSiteRunning_SiteShutsDown_OutOfProcess()
183183
{
184184
var deploymentResult = await AssertStarts(HostingModel.OutOfProcess);
185185

186-
// Repeat dropping file and restarting multiple times
187-
for (int i = 0; i < 5; i++)
188-
{
189-
AddAppOffline(deploymentResult.ContentRoot);
190-
await AssertAppOffline(deploymentResult);
191-
RemoveAppOffline(deploymentResult.ContentRoot);
192-
await AssertRunning(deploymentResult);
193-
}
186+
AddAppOffline(deploymentResult.ContentRoot);
187+
await AssertAppOffline(deploymentResult);
188+
RemoveAppOffline(deploymentResult.ContentRoot);
189+
await AssertRunning(deploymentResult);
194190

195191
AddAppOffline(deploymentResult.ContentRoot);
196192
await AssertAppOffline(deploymentResult);

src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/FrebTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
1111
using Microsoft.AspNetCore.Server.IntegrationTesting;
1212
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
13+
using Microsoft.AspNetCore.Testing;
1314
using Microsoft.AspNetCore.Testing.xunit;
1415
using Microsoft.Extensions.Logging;
16+
using Microsoft.Extensions.Logging.Testing;
1517
using Xunit;
1618

1719
namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests.InProcess
@@ -76,7 +78,11 @@ public async Task CheckFailedRequestEvents()
7678
AssertFrebLogs(result, new FrebLogItem("ANCM_INPROC_ASYNC_COMPLETION_COMPLETION", "2"));
7779
}
7880

81+
// I think this test is flaky due to freb file not being created quickly enough.
82+
// Adding extra logging, marking as flaky, and repeating should help
7983
[ConditionalFact]
84+
[Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/2570", FlakyOn.Helix.All)]
85+
[Repeat(10)]
8086
[RequiresIIS(IISCapability.FailedRequestTracingModule)]
8187
public async Task CheckFrebDisconnect()
8288
{
@@ -120,16 +126,18 @@ private void AssertFrebLogs(IISDeploymentResult result, IEnumerable<FrebLogItem>
120126
var frebEvent = GetFrebLogItems(result);
121127
foreach (var expectedEvent in expectedFrebEvents)
122128
{
129+
result.Logger.LogInformation($"Checking if {expectedEvent.ToString()} exists.");
123130
Assert.Contains(expectedEvent, frebEvent);
124131
}
125132
}
126133

127134
private IEnumerable<FrebLogItem> GetFrebLogItems(IISDeploymentResult result)
128135
{
129136
var folderPath = Helpers.GetFrebFolder(_logFolderPath, result);
130-
var xmlFiles = Directory.GetFiles(folderPath).Where(f => f.EndsWith("xml"));
137+
var xmlFiles = Directory.GetFiles(folderPath).Where(f => f.EndsWith("xml")).ToList();
131138
var frebEvents = new List<FrebLogItem>();
132139

140+
result.Logger.LogInformation($"Number of freb files available {xmlFiles.Count}.");
133141
foreach (var xmlFile in xmlFiles)
134142
{
135143
var xDocument = XDocument.Load(xmlFile).Root;
@@ -174,6 +182,11 @@ public override int GetHashCode()
174182
{
175183
return HashCode.Combine(_opCode, _requestStatus);
176184
}
185+
186+
public override string ToString()
187+
{
188+
return $"FrebLogItem: opCode: {_opCode}, requestStatus: {_requestStatus}";
189+
}
177190
}
178191
}
179192
}

src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/MaxRequestBodySizeTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Net;
55
using System.Net.Http;
66
using System.Threading.Tasks;
7-
using Microsoft.AspNetCore.Server.IIS;
87
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
98
using Microsoft.AspNetCore.Server.IntegrationTesting;
109
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
@@ -91,6 +90,9 @@ public async Task SetIISLimitMaxRequestBodyLogsWarning()
9190

9291
var result = await deploymentResult.HttpClient.PostAsync("/DecreaseRequestLimit", new StringContent("1"));
9392
Assert.Equal(HttpStatusCode.OK, result.StatusCode);
93+
94+
StopServer();
95+
9496
if (deploymentParameters.ServerType == ServerType.IISExpress)
9597
{
9698
Assert.Single(TestSink.Writes, w => w.Message.Contains("Increasing the MaxRequestBodySize conflicts with the max value for IIS limit maxAllowedContentLength." +

src/Servers/IIS/IIS/test/Common.FunctionalTests/Utilities/Helpers.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using System.Xml.Linq;
1212
using Microsoft.AspNetCore.Server.IntegrationTesting;
1313
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
14-
using Microsoft.AspNetCore.Testing;
1514
using Microsoft.Extensions.Logging;
1615
using Newtonsoft.Json;
1716
using Xunit;
@@ -20,7 +19,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
2019
{
2120
public static class Helpers
2221
{
23-
private static readonly TimeSpan RetryRequestDelay = TimeSpan.FromMilliseconds(100);
22+
private static readonly TimeSpan RetryRequestDelay = TimeSpan.FromMilliseconds(10);
2423
private static readonly int RetryRequestCount = 10;
2524

2625
public static string GetInProcessTestSitesName()
@@ -105,12 +104,14 @@ public static Task<HttpResponseMessage> RetryRequestAsync(this HttpClient client
105104
public static async Task<HttpResponseMessage> RetryRequestAsync(this HttpClient client, string uri, Func<HttpResponseMessage, Task<bool>> predicate)
106105
{
107106
HttpResponseMessage response = await client.GetAsync(uri);
108-
107+
var delay = RetryRequestDelay;
109108
for (var i = 0; i < RetryRequestCount && !await predicate(response); i++)
110109
{
111110
// Keep retrying until app_offline is present.
112111
response = await client.GetAsync(uri);
113-
await Task.Delay(RetryRequestDelay);
112+
await Task.Delay(delay);
113+
// This will max out at a 5 second delay
114+
delay *= 2;
114115
}
115116

116117
if (!await predicate(response))

src/Servers/IIS/IIS/test/IIS.Tests/ClientDisconnectTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Threading;
66
using System.Threading.Tasks;
77
using Microsoft.AspNetCore.Connections;
8-
using Microsoft.AspNetCore.Http;
98
using Microsoft.AspNetCore.Server.IntegrationTesting;
109
using Microsoft.AspNetCore.Testing;
1110
using Microsoft.AspNetCore.Testing.xunit;
@@ -20,19 +19,20 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
2019
public class ClientDisconnectTests : StrictTestServerTests
2120
{
2221
[ConditionalFact]
23-
[Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/2358", FlakyOn.All)]
2422
public async Task WritesSucceedAfterClientDisconnect()
2523
{
2624
var requestStartedCompletionSource = CreateTaskCompletionSource();
27-
var clientDisconnectedCompletionSource = CreateTaskCompletionSource();
2825
var requestCompletedCompletionSource = CreateTaskCompletionSource();
26+
var requestAborted = CreateTaskCompletionSource();
2927

3028
var data = new byte[1024];
3129
using (var testServer = await TestServer.Create(
3230
async ctx =>
3331
{
3432
requestStartedCompletionSource.SetResult(true);
35-
await clientDisconnectedCompletionSource.Task;
33+
ctx.RequestAborted.Register(() => requestAborted.SetResult(true));
34+
35+
await requestAborted.Task.DefaultTimeout();
3636
for (var i = 0; i < 1000; i++)
3737
{
3838
await ctx.Response.Body.WriteAsync(data);
@@ -46,7 +46,8 @@ public async Task WritesSucceedAfterClientDisconnect()
4646
await SendContentLength1Post(connection);
4747
await requestStartedCompletionSource.Task.DefaultTimeout();
4848
}
49-
clientDisconnectedCompletionSource.SetResult(true);
49+
50+
await requestAborted.Task.DefaultTimeout();
5051

5152
await requestCompletedCompletionSource.Task.DefaultTimeout();
5253
}
@@ -55,7 +56,6 @@ public async Task WritesSucceedAfterClientDisconnect()
5556
}
5657

5758
[ConditionalFact]
58-
[Repeat(20)]
5959
public async Task WritesCanceledWhenUsingAbortedToken()
6060
{
6161
var requestStartedCompletionSource = CreateTaskCompletionSource();

src/Servers/IIS/IntegrationTesting.IIS/src/IISExpressDeployer.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ private string CheckIfPublishIsRequired()
264264
Logger.LogInformation("Started iisexpress successfully. Process Id : {processId}, Port: {port}", _hostProcess.Id, port);
265265
return (url: url, hostExitToken: hostExitTokenSource.Token);
266266
}
267+
268+
ChangePort(contentRoot, (uri.Scheme == "https") ? TestPortHelper.GetNextSSLPort() : TestPortHelper.GetNextPort());
267269
}
268270

269271
var message = $"Failed to initialize IIS Express after {MaximumAttempts} attempts to select a port";
@@ -274,7 +276,7 @@ private string CheckIfPublishIsRequired()
274276

275277
private void PrepareConfig(string contentRoot, int port)
276278
{
277-
var serverConfig = DeploymentParameters.ServerConfigTemplateContent;;
279+
var serverConfig = DeploymentParameters.ServerConfigTemplateContent;
278280
// Config is required. If not present then fall back to one we carry with us.
279281
if (string.IsNullOrEmpty(serverConfig))
280282
{
@@ -313,6 +315,14 @@ private void PrepareConfig(string contentRoot, int port)
313315
File.WriteAllText(DeploymentParameters.ServerConfigLocation, serverConfig);
314316
}
315317

318+
private void ChangePort(string contentRoot, int port)
319+
{
320+
var serverConfig = File.ReadAllText(DeploymentParameters.ServerConfigLocation);
321+
XDocument config = XDocument.Parse(serverConfig);
322+
ConfigureModuleAndBinding(config.Root, contentRoot, port);
323+
File.WriteAllText(DeploymentParameters.ServerConfigLocation, serverConfig);
324+
}
325+
316326
private void AddAspNetCoreElement(XElement config)
317327
{
318328
var aspNetCore = config

0 commit comments

Comments
 (0)