Skip to content

Don't check stdout for entire string contents #30023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions src/Servers/IIS/IIS/test/Common.FunctionalTests/StartupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1006,9 +1006,14 @@ public async Task CheckStdoutWithLargeWrites_TestSink(string mode)

StopServer();

var expectedString = new string('a', 30000);
Assert.Contains(TestSink.Writes, context => context.Message.Contains(expectedString));
EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", expectedString), Logger);
// 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
// string instead of the entire string. The entire string will still be present in the event log.
var expectedLogString = new string('a', 16);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this have the same issue as the 30k a's, just a lot less likely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there are only a few log messages that can be spliced in between. So there is no way to split every string to a size smaller than 16.


Assert.Contains(TestSink.Writes, context => context.Message.Contains(expectedLogString));
var expectedEventLogString = new string('a', 30000);

EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", expectedEventLogString), Logger);
}

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

var contents = GetLogFileContent(deploymentResult);
var expectedString = new string('a', 30000);

Assert.Contains(expectedString, contents);
EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", expectedString), Logger);
// 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
// string instead of the entire string. The entire string will still be present in the event log.
var expectedLogString = new string('a', 16);

Assert.Contains(expectedLogString, contents);

var expectedEventLogString = new string('a', 30000);

EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", expectedEventLogString), Logger);
}

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

Assert.DoesNotContain("shouldberemoved", await GetStringAsync(deploymentParameters,"/GetEnvironmentVariable?name=ASPNETCORE_IIS_HTTPAUTH"));
Assert.DoesNotContain("shouldberemoved", await GetStringAsync(deploymentParameters, "/GetEnvironmentVariable?name=ASPNETCORE_IIS_HTTPAUTH"));
}

[ConditionalFact]
Expand Down Expand Up @@ -1314,7 +1325,8 @@ public async Task ServerAddressesIncludesBaseAddress()
deploymentParameters.AddHttpsToServerConfig();
deploymentParameters.SetWindowsAuth(false);
deploymentParameters.AddServerConfigAction(
(element, root) => {
(element, root) =>
{
element.Descendants("site").Single().Element("application").SetAttributeValue("path", "/" + appName);
Helpers.CreateEmptyApplication(element, root);
});
Expand All @@ -1332,7 +1344,8 @@ public async Task AncmHttpsPortCanBeOverriden()
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);

deploymentParameters.AddServerConfigAction(
element => {
element =>
{
element.Descendants("bindings")
.Single()
.GetOrAdd("binding", "protocol", "https")
Expand All @@ -1358,7 +1371,8 @@ public async Task HttpsRedirectionWorksIn30AndNot22()
deploymentParameters.ApplicationBaseUriHint = $"http://localhost:{TestPortHelper.GetNextPort()}/";

deploymentParameters.AddServerConfigAction(
element => {
element =>
{
element.Descendants("bindings")
.Single()
.AddAndGetInnerElement("binding", "protocol", "https")
Expand Down Expand Up @@ -1403,7 +1417,8 @@ public async Task MultipleHttpsPortsProduceNoEnvVar()
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);

deploymentParameters.AddServerConfigAction(
element => {
element =>
{
element.Descendants("bindings")
.Single()
.Add(
Expand Down