Skip to content

Commit 580153e

Browse files
authored
Don't check stdout for entire string contents (#30023)
1 parent dd20d8d commit 580153e

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

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

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,9 +1006,14 @@ public async Task CheckStdoutWithLargeWrites_TestSink(string mode)
10061006

10071007
StopServer();
10081008

1009-
var expectedString = new string('a', 30000);
1010-
Assert.Contains(TestSink.Writes, context => context.Message.Contains(expectedString));
1011-
EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", expectedString), Logger);
1009+
// Logs can be split due to the ANCM logging occuring at the same time as logs from the app, so check for a portion of the
1010+
// string instead of the entire string. The entire string will still be present in the event log.
1011+
var expectedLogString = new string('a', 16);
1012+
1013+
Assert.Contains(TestSink.Writes, context => context.Message.Contains(expectedLogString));
1014+
var expectedEventLogString = new string('a', 30000);
1015+
1016+
EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", expectedEventLogString), Logger);
10121017
}
10131018

10141019
[ConditionalTheory]
@@ -1027,10 +1032,16 @@ public async Task CheckStdoutWithLargeWrites_LogFile(string mode)
10271032
await AssertFailsToStart(deploymentResult);
10281033

10291034
var contents = GetLogFileContent(deploymentResult);
1030-
var expectedString = new string('a', 30000);
10311035

1032-
Assert.Contains(expectedString, contents);
1033-
EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", expectedString), Logger);
1036+
// Logs can be split due to the ANCM logging occuring at the same time as logs from the app, so check for a portion of the
1037+
// string instead of the entire string. The entire string will still be present in the event log.
1038+
var expectedLogString = new string('a', 16);
1039+
1040+
Assert.Contains(expectedLogString, contents);
1041+
1042+
var expectedEventLogString = new string('a', 30000);
1043+
1044+
EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", expectedEventLogString), Logger);
10341045
}
10351046

10361047
[ConditionalFact]
@@ -1202,7 +1213,7 @@ private async Task AuthHeaderEnvironmentVariableRemoved(HostingModel hostingMode
12021213
var deploymentParameters = Fixture.GetBaseDeploymentParameters(hostingModel);
12031214
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_IIS_HTTPAUTH"] = "shouldberemoved";
12041215

1205-
Assert.DoesNotContain("shouldberemoved", await GetStringAsync(deploymentParameters,"/GetEnvironmentVariable?name=ASPNETCORE_IIS_HTTPAUTH"));
1216+
Assert.DoesNotContain("shouldberemoved", await GetStringAsync(deploymentParameters, "/GetEnvironmentVariable?name=ASPNETCORE_IIS_HTTPAUTH"));
12061217
}
12071218

12081219
[ConditionalFact]
@@ -1314,7 +1325,8 @@ public async Task ServerAddressesIncludesBaseAddress()
13141325
deploymentParameters.AddHttpsToServerConfig();
13151326
deploymentParameters.SetWindowsAuth(false);
13161327
deploymentParameters.AddServerConfigAction(
1317-
(element, root) => {
1328+
(element, root) =>
1329+
{
13181330
element.Descendants("site").Single().Element("application").SetAttributeValue("path", "/" + appName);
13191331
Helpers.CreateEmptyApplication(element, root);
13201332
});
@@ -1332,7 +1344,8 @@ public async Task AncmHttpsPortCanBeOverriden()
13321344
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
13331345

13341346
deploymentParameters.AddServerConfigAction(
1335-
element => {
1347+
element =>
1348+
{
13361349
element.Descendants("bindings")
13371350
.Single()
13381351
.GetOrAdd("binding", "protocol", "https")
@@ -1358,7 +1371,8 @@ public async Task HttpsRedirectionWorksIn30AndNot22()
13581371
deploymentParameters.ApplicationBaseUriHint = $"http://localhost:{TestPortHelper.GetNextPort()}/";
13591372

13601373
deploymentParameters.AddServerConfigAction(
1361-
element => {
1374+
element =>
1375+
{
13621376
element.Descendants("bindings")
13631377
.Single()
13641378
.AddAndGetInnerElement("binding", "protocol", "https")
@@ -1403,7 +1417,8 @@ public async Task MultipleHttpsPortsProduceNoEnvVar()
14031417
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
14041418

14051419
deploymentParameters.AddServerConfigAction(
1406-
element => {
1420+
element =>
1421+
{
14071422
element.Descendants("bindings")
14081423
.Single()
14091424
.Add(

0 commit comments

Comments
 (0)