Skip to content

Commit 90b13b3

Browse files
authored
Reducing number of tests we run with forwards and backwards compatibility (#26187)
1 parent e7d5306 commit 90b13b3

File tree

8 files changed

+166
-60
lines changed

8 files changed

+166
-60
lines changed

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

Lines changed: 111 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,33 @@ public async Task CallStopAsyncOnRequestThread_DoesNotHangIndefinitely(string pa
6767
}
6868

6969

70-
[ConditionalTheory]
71-
[InlineData(HostingModel.InProcess)]
72-
[InlineData(HostingModel.OutOfProcess)]
73-
public async Task AppOfflineDroppedWhileSiteIsDown_SiteReturns503(HostingModel hostingModel)
70+
[ConditionalFact]
71+
public async Task AppOfflineDroppedWhileSiteIsDown_SiteReturns503_InProcess()
7472
{
75-
var deploymentResult = await DeployApp(hostingModel);
73+
var deploymentResult = await DeployApp(HostingModel.InProcess);
7674

7775
AddAppOffline(deploymentResult.ContentRoot);
7876

7977
await AssertAppOffline(deploymentResult);
8078
DeletePublishOutput(deploymentResult);
8179
}
8280

83-
[ConditionalTheory]
84-
[InlineData(HostingModel.InProcess)]
85-
[InlineData(HostingModel.OutOfProcess)]
86-
public async Task LockedAppOfflineDroppedWhileSiteIsDown_SiteReturns503(HostingModel hostingModel)
81+
[ConditionalFact]
82+
[RequiresNewShim]
83+
public async Task AppOfflineDroppedWhileSiteIsDown_SiteReturns503_OutOfProcess()
84+
{
85+
var deploymentResult = await DeployApp(HostingModel.OutOfProcess);
86+
87+
AddAppOffline(deploymentResult.ContentRoot);
88+
89+
await AssertAppOffline(deploymentResult);
90+
DeletePublishOutput(deploymentResult);
91+
}
92+
93+
[ConditionalFact]
94+
public async Task LockedAppOfflineDroppedWhileSiteIsDown_SiteReturns503_InProcess()
8795
{
88-
var deploymentResult = await DeployApp(hostingModel);
96+
var deploymentResult = await DeployApp(HostingModel.InProcess);
8997

9098
// Add app_offline without shared access
9199
using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None))
@@ -99,19 +107,54 @@ public async Task LockedAppOfflineDroppedWhileSiteIsDown_SiteReturns503(HostingM
99107
DeletePublishOutput(deploymentResult);
100108
}
101109

102-
[ConditionalTheory]
103-
[InlineData(HostingModel.InProcess, 500, "500.0")]
104-
[InlineData(HostingModel.OutOfProcess, 502, "502.5")]
105-
public async Task AppOfflineDroppedWhileSiteFailedToStartInShim_AppOfflineServed(HostingModel hostingModel, int statusCode, string content)
110+
[ConditionalFact]
111+
[RequiresNewShim]
112+
public async Task LockedAppOfflineDroppedWhileSiteIsDown_SiteReturns503_OutOfProcess()
113+
{
114+
var deploymentResult = await DeployApp(HostingModel.OutOfProcess);
115+
116+
// Add app_offline without shared access
117+
using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None))
118+
using (var writer = new StreamWriter(stream))
119+
{
120+
await writer.WriteLineAsync("App if offline but you wouldn't see this message");
121+
await writer.FlushAsync();
122+
await AssertAppOffline(deploymentResult, "");
123+
}
124+
125+
DeletePublishOutput(deploymentResult);
126+
}
127+
128+
[ConditionalFact]
129+
public async Task AppOfflineDroppedWhileSiteFailedToStartInShim_AppOfflineServed_InProcess()
130+
{
131+
var deploymentParameters = Fixture.GetBaseDeploymentParameters(hostingModel: HostingModel.InProcess);
132+
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", "nonexistent"));
133+
134+
var deploymentResult = await DeployAsync(deploymentParameters);
135+
136+
var result = await deploymentResult.HttpClient.GetAsync("/");
137+
Assert.Equal(500, (int)result.StatusCode);
138+
Assert.Contains("500.0", await result.Content.ReadAsStringAsync());
139+
140+
AddAppOffline(deploymentResult.ContentRoot);
141+
142+
await AssertAppOffline(deploymentResult);
143+
DeletePublishOutput(deploymentResult);
144+
}
145+
146+
[ConditionalFact]
147+
[RequiresNewShim]
148+
public async Task AppOfflineDroppedWhileSiteFailedToStartInShim_AppOfflineServed_OutOfProcess()
106149
{
107-
var deploymentParameters = Fixture.GetBaseDeploymentParameters(hostingModel: hostingModel);
150+
var deploymentParameters = Fixture.GetBaseDeploymentParameters(hostingModel: HostingModel.OutOfProcess);
108151
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", "nonexistent"));
109152

110153
var deploymentResult = await DeployAsync(deploymentParameters);
111154

112155
var result = await deploymentResult.HttpClient.GetAsync("/");
113-
Assert.Equal(statusCode, (int)result.StatusCode);
114-
Assert.Contains(content, await result.Content.ReadAsStringAsync());
156+
Assert.Equal(502, (int)result.StatusCode);
157+
Assert.Contains("502.5", await result.Content.ReadAsStringAsync());
115158

116159
AddAppOffline(deploymentResult.ContentRoot);
117160

@@ -220,6 +263,7 @@ public async Task AppOfflineDroppedWhileSiteRunning_SiteShutsDown_InProcess()
220263
}
221264

222265
[ConditionalFact]
266+
[RequiresNewShim]
223267
public async Task AppOfflineDroppedWhileSiteRunning_SiteShutsDown_OutOfProcess()
224268
{
225269
var deploymentResult = await AssertStarts(HostingModel.OutOfProcess);
@@ -234,12 +278,10 @@ public async Task AppOfflineDroppedWhileSiteRunning_SiteShutsDown_OutOfProcess()
234278
DeletePublishOutput(deploymentResult);
235279
}
236280

237-
[ConditionalTheory]
238-
[InlineData(HostingModel.InProcess)]
239-
[InlineData(HostingModel.OutOfProcess)]
240-
public async Task AppOfflineDropped_CanRemoveAppOfflineAfterAddingAndSiteWorks(HostingModel hostingModel)
281+
[ConditionalFact]
282+
public async Task AppOfflineDropped_CanRemoveAppOfflineAfterAddingAndSiteWorks_InProcess()
241283
{
242-
var deploymentResult = await DeployApp(hostingModel);
284+
var deploymentResult = await DeployApp(HostingModel.InProcess);
243285

244286
AddAppOffline(deploymentResult.ContentRoot);
245287

@@ -250,12 +292,37 @@ public async Task AppOfflineDropped_CanRemoveAppOfflineAfterAddingAndSiteWorks(H
250292
await AssertRunning(deploymentResult);
251293
}
252294

253-
[ConditionalTheory]
254-
[InlineData(HostingModel.InProcess)]
255-
[InlineData(HostingModel.OutOfProcess)]
256-
public async Task AppOfflineAddedAndRemovedStress(HostingModel hostingModel)
295+
[ConditionalFact]
296+
[RequiresNewShim]
297+
public async Task AppOfflineDropped_CanRemoveAppOfflineAfterAddingAndSiteWorks_OutOfProcess()
298+
{
299+
var deploymentResult = await DeployApp(HostingModel.OutOfProcess);
300+
301+
AddAppOffline(deploymentResult.ContentRoot);
302+
303+
await AssertAppOffline(deploymentResult);
304+
305+
RemoveAppOffline(deploymentResult.ContentRoot);
306+
307+
await AssertRunning(deploymentResult);
308+
}
309+
310+
[ConditionalFact]
311+
public async Task AppOfflineAddedAndRemovedStress_InProcess()
312+
{
313+
await AppOfflineAddAndRemovedStress(HostingModel.InProcess);
314+
}
315+
316+
[ConditionalFact]
317+
[RequiresNewShim]
318+
public async Task AppOfflineAddedAndRemovedStress_OutOfProcess()
319+
{
320+
await AppOfflineAddAndRemovedStress(HostingModel.OutOfProcess);
321+
}
322+
323+
private async Task AppOfflineAddAndRemovedStress(HostingModel hostingModel)
257324
{
258-
var deploymentResult = await AssertStarts(hostingModel);
325+
var deploymentResult = await AssertStarts(hostingModel);
259326

260327
var load = Helpers.StressLoad(deploymentResult.HttpClient, "/HelloWorld", response =>
261328
{
@@ -269,7 +336,7 @@ public async Task AppOfflineAddedAndRemovedStress(HostingModel hostingModel)
269336
Assert.True(statusCode == 200 || statusCode == 503, "Status code was " + statusCode);
270337
});
271338

272-
for (int i = 0; i < 100; i++)
339+
for (int i = 0; i < 5; i++)
273340
{
274341
// AddAppOffline might fail if app_offline is being read by ANCM and deleted at the same time
275342
RetryHelper.RetryOperation(
@@ -310,6 +377,7 @@ public async Task ConfigurationChangeStopsInProcess()
310377
}
311378

312379
[ConditionalFact]
380+
[RequiresNewShim]
313381
public async Task ConfigurationChangeForcesChildProcessRestart()
314382
{
315383
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
@@ -347,11 +415,21 @@ public async Task OutOfProcessToInProcessHostingModelSwitchWorks()
347415
await deploymentResult.HttpClient.RetryRequestAsync("/HelloWorld", r => r.Headers.Server.ToString().StartsWith("Microsoft"));
348416
}
349417

350-
[ConditionalTheory]
351-
[InlineData(HostingModel.InProcess)]
352-
[InlineData(HostingModel.OutOfProcess)]
418+
[ConditionalFact]
353419
[QuarantinedTest("https://github.com/dotnet/aspnetcore-internal/issues/1794")]
354-
public async Task ConfigurationTouchedStress(HostingModel hostingModel)
420+
public async Task ConfigurationTouchedStress_InProcess()
421+
{
422+
await ConfigurationTouchedStress(HostingModel.InProcess);
423+
}
424+
425+
[ConditionalFact]
426+
[RequiresNewShim]
427+
public async Task ConfigurationTouchedStress_OutOfProcess()
428+
{
429+
await ConfigurationTouchedStress(HostingModel.OutOfProcess);
430+
}
431+
432+
private async Task ConfigurationTouchedStress(HostingModel hostingModel)
355433
{
356434
var deploymentResult = await DeployAsync(Fixture.GetBaseDeploymentParameters(hostingModel));
357435

@@ -387,6 +465,7 @@ public async Task ConfigurationTouchedStress(HostingModel hostingModel)
387465
}
388466

389467
[ConditionalFact]
468+
[RequiresNewShim]
390469
public async Task ClosesConnectionOnServerAbortOutOfProcess()
391470
{
392471
try

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,7 @@ public async Task IncludesAdditionalErrorPageTextInProcessHandlerLoadFailure_Cor
10791079

10801080
[ConditionalFact]
10811081
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
1082+
[RequiresNewShim]
10821083
[MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_20H1, SkipReason = "Shutdown hangs https://github.com/dotnet/aspnetcore/issues/25107")]
10831084
public async Task IncludesAdditionalErrorPageTextOutOfProcessStartupFailure_CorrectString()
10841085
{
@@ -1098,6 +1099,7 @@ public async Task IncludesAdditionalErrorPageTextOutOfProcessStartupFailure_Corr
10981099

10991100
[ConditionalFact]
11001101
[MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_20H1, SkipReason = "Shutdown hangs https://github.com/dotnet/aspnetcore/issues/25107")]
1102+
[RequiresNewShim]
11011103
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
11021104
public async Task IncludesAdditionalErrorPageTextOutOfProcessHandlerLoadFailure_CorrectString()
11031105
{
@@ -1144,10 +1146,8 @@ public async Task IncludesAdditionalErrorPageTextInProcessStartupFailure_Correct
11441146
}
11451147

11461148

1147-
[ConditionalTheory]
1148-
[InlineData(HostingModel.InProcess)]
1149-
[InlineData(HostingModel.OutOfProcess)]
1150-
public async Task GetLongEnvironmentVariable(HostingModel hostingModel)
1149+
[ConditionalFact]
1150+
public async Task GetLongEnvironmentVariable_InProcess()
11511151
{
11521152
var expectedValue = "AReallyLongValueThatIsGreaterThan300CharactersToForceResizeInNative" +
11531153
"AReallyLongValueThatIsGreaterThan300CharactersToForceResizeInNative" +
@@ -1157,7 +1157,27 @@ public async Task GetLongEnvironmentVariable(HostingModel hostingModel)
11571157
"AReallyLongValueThatIsGreaterThan300CharactersToForceResizeInNative";
11581158

11591159

1160-
var deploymentParameters = Fixture.GetBaseDeploymentParameters(hostingModel);
1160+
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.InProcess);
1161+
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_TESTING_LONG_VALUE"] = expectedValue;
1162+
1163+
Assert.Equal(
1164+
expectedValue,
1165+
await GetStringAsync(deploymentParameters, "/GetEnvironmentVariable?name=ASPNETCORE_INPROCESS_TESTING_LONG_VALUE"));
1166+
}
1167+
1168+
[ConditionalFact]
1169+
[RequiresNewShim]
1170+
public async Task GetLongEnvironmentVariable_OutOfProcess()
1171+
{
1172+
var expectedValue = "AReallyLongValueThatIsGreaterThan300CharactersToForceResizeInNative" +
1173+
"AReallyLongValueThatIsGreaterThan300CharactersToForceResizeInNative" +
1174+
"AReallyLongValueThatIsGreaterThan300CharactersToForceResizeInNative" +
1175+
"AReallyLongValueThatIsGreaterThan300CharactersToForceResizeInNative" +
1176+
"AReallyLongValueThatIsGreaterThan300CharactersToForceResizeInNative" +
1177+
"AReallyLongValueThatIsGreaterThan300CharactersToForceResizeInNative";
1178+
1179+
1180+
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
11611181
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_TESTING_LONG_VALUE"] = expectedValue;
11621182

11631183
Assert.Equal(
@@ -1186,6 +1206,7 @@ private async Task AuthHeaderEnvironmentVariableRemoved(HostingModel hostingMode
11861206
public Task WebConfigOverridesGlobalEnvironmentVariables_InProcess() => WebConfigOverridesGlobalEnvironmentVariables(HostingModel.InProcess);
11871207

11881208
[ConditionalFact]
1209+
[RequiresNewShim]
11891210
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
11901211
public Task WebConfigOverridesGlobalEnvironmentVariables_OutOfProcess() => WebConfigOverridesGlobalEnvironmentVariables(HostingModel.OutOfProcess);
11911212

@@ -1203,6 +1224,7 @@ private async Task WebConfigOverridesGlobalEnvironmentVariables(HostingModel hos
12031224
public Task WebConfigAppendsHostingStartup_InProcess() => WebConfigAppendsHostingStartup(HostingModel.InProcess);
12041225

12051226
[ConditionalFact]
1227+
[RequiresNewShim]
12061228
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
12071229
public Task WebConfigAppendsHostingStartup_OutOfProcess() => WebConfigAppendsHostingStartup(HostingModel.OutOfProcess);
12081230

@@ -1226,6 +1248,7 @@ private async Task WebConfigAppendsHostingStartup(HostingModel hostingModel)
12261248
public Task WebConfigOverridesHostingStartup_InProcess() => WebConfigOverridesHostingStartup(HostingModel.InProcess);
12271249

12281250
[ConditionalFact]
1251+
[RequiresNewShim]
12291252
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
12301253
public Task WebConfigOverridesHostingStartup_OutOfProcess() => WebConfigOverridesHostingStartup(HostingModel.OutOfProcess);
12311254

@@ -1243,6 +1266,7 @@ private async Task WebConfigOverridesHostingStartup(HostingModel hostingModel)
12431266
public Task WebConfigExpandsVariables_InProcess() => WebConfigExpandsVariables(HostingModel.InProcess);
12441267

12451268
[ConditionalFact]
1269+
[RequiresNewShim]
12461270
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
12471271
public Task WebConfigExpandsVariables_OutOfProcess() => WebConfigExpandsVariables(HostingModel.OutOfProcess);
12481272

src/Servers/IIS/IIS/test/IIS.NewHandler.FunctionalTests/IIS.NewHandler.FunctionalTests.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
<Import Project="../FunctionalTest.props" />
1212

1313
<ItemGroup>
14-
<Compile Include="..\Common.FunctionalTests\**\*.cs" />
15-
<Compile Include="..\IIS.Shared.FunctionalTests\**\*.cs" />
14+
<Compile Include="..\Common.FunctionalTests\StartupTests.cs" />
15+
<Compile Include="..\Common.FunctionalTests\ShutdownTests.cs" />
16+
<Compile Include="..\Common.FunctionalTests\Infrastructure\*.cs" />
1617
<Compile Include="$(SharedSourceRoot)Http2cat\**\*.cs" LinkBase="Shared\Http2cat" />
1718
<Compile Include="$(SharedSourceRoot)runtime\Http2\**\*.cs" LinkBase="Shared\Http2\" />
1819
<Compile Include="$(SharedSourceRoot)runtime\IHttpHeadersHandler.cs" LinkBase="Shared\IHttpHeadersHandler.cs" />

src/Servers/IIS/IIS/test/IIS.NewHandler.FunctionalTests/NewHandlerTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@
33

44
using System.Diagnostics;
55
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
67
using Microsoft.AspNetCore.Testing;
78
using Xunit;
89
using Xunit.Sdk;
910

1011
namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
1112
{
12-
[Collection(IISTestSiteCollection.Name)]
13-
public class NewHandlerTests : FixtureLoggedTest
13+
[Collection(PublishedSitesCollection.Name)]
14+
public class NewHandlerTests : IISFunctionalTestBase
1415
{
15-
private readonly IISTestSiteFixture _fixture;
16-
17-
public NewHandlerTests(IISTestSiteFixture fixture) : base(fixture)
16+
public NewHandlerTests(PublishedSitesFixture fixture) : base(fixture)
1817
{
19-
_fixture = fixture;
2018
}
2119

2220
[ConditionalFact]
2321
public async Task CheckNewHandlerIsUsed()
2422
{
25-
var response = await _fixture.Client.GetAsync("/HelloWorld");
23+
var deploymentParameters = Fixture.GetBaseDeploymentParameters();
24+
var result = await DeployAsync(deploymentParameters);
25+
var response = await result.HttpClient.GetAsync("/HelloWorld");
2626

2727
Assert.True(response.IsSuccessStatusCode);
2828

29-
_fixture.DeploymentResult.HostProcess.Refresh();
30-
var handles = _fixture.DeploymentResult.HostProcess.Modules;
29+
result.HostProcess.Refresh();
30+
var handles = result.HostProcess.Modules;
3131

3232
foreach (ProcessModule handle in handles)
3333
{
@@ -37,7 +37,7 @@ public async Task CheckNewHandlerIsUsed()
3737
return;
3838
}
3939
}
40-
throw new XunitException($"Could not find aspnetcorev2.dll loaded in process {_fixture.DeploymentResult.HostProcess.ProcessName}");
40+
throw new XunitException($"Could not find aspnetcorev2.dll loaded in process {result.HostProcess.ProcessName}");
4141
}
4242
}
4343
}

src/Servers/IIS/IIS/test/IIS.NewShim.FunctionalTests/IIS.NewShim.FunctionalTests.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<Compile Include="..\Common.FunctionalTests\**\*.cs" />
24-
<Compile Include="..\IIS.Shared.FunctionalTests\**\*.cs" />
23+
<Compile Include="..\Common.FunctionalTests\StartupTests.cs" />
24+
<Compile Include="..\Common.FunctionalTests\ShutdownTests.cs" />
25+
<Compile Include="..\Common.FunctionalTests\Infrastructure\*.cs" />
2526
<Compile Include="$(SharedSourceRoot)Http2cat\**\*.cs" LinkBase="Shared\Http2cat" />
2627
<Compile Include="$(SharedSourceRoot)runtime\Http2\**\*.cs" LinkBase="Shared\Http2\" />
2728
<Compile Include="$(SharedSourceRoot)runtime\IHttpHeadersHandler.cs" LinkBase="Shared\IHttpHeadersHandler.cs" />

0 commit comments

Comments
 (0)