101 lines
4.3 KiB
C#
101 lines
4.3 KiB
C#
// Copyright (c) .NET Foundation. All rights reserved.
|
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
|
|
using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
|
using Microsoft.AspNetCore.Testing.xunit;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|
{
|
|
[Collection(PublishedSitesCollection.Name)]
|
|
public class StartupExceptionTests : LogFileTestBase
|
|
{
|
|
private readonly PublishedSitesFixture _fixture;
|
|
|
|
public StartupExceptionTests(PublishedSitesFixture fixture)
|
|
{
|
|
_fixture = fixture;
|
|
}
|
|
|
|
[ConditionalTheory]
|
|
[InlineData("CheckLargeStdErrWrites")]
|
|
[InlineData("CheckLargeStdOutWrites")]
|
|
[InlineData("CheckOversizedStdErrWrites")]
|
|
[InlineData("CheckOversizedStdOutWrites")]
|
|
public async Task CheckStdoutWithLargeWrites_TestSink(string mode)
|
|
{
|
|
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
|
|
deploymentParameters.TransformArguments((a, _) => $"{a} {mode}");
|
|
var deploymentResult = await DeployAsync(deploymentParameters);
|
|
|
|
await AssertFailsToStart(deploymentResult);
|
|
var expectedString = new string('a', 30000);
|
|
Assert.Contains(TestSink.Writes, context => context.Message.Contains(expectedString));
|
|
EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", expectedString));
|
|
}
|
|
|
|
[ConditionalTheory]
|
|
[InlineData("CheckLargeStdErrWrites")]
|
|
[InlineData("CheckLargeStdOutWrites")]
|
|
[InlineData("CheckOversizedStdErrWrites")]
|
|
[InlineData("CheckOversizedStdOutWrites")]
|
|
public async Task CheckStdoutWithLargeWrites_LogFile(string mode)
|
|
{
|
|
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
|
|
deploymentParameters.TransformArguments((a, _) => $"{a} {mode}");
|
|
deploymentParameters.EnableLogging(_logFolderPath);
|
|
|
|
var deploymentResult = await DeployAsync(deploymentParameters);
|
|
|
|
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));
|
|
}
|
|
|
|
[ConditionalFact]
|
|
public async Task CheckValidConsoleFunctions()
|
|
{
|
|
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
|
|
deploymentParameters.TransformArguments((a, _) => $"{a} CheckConsoleFunctions");
|
|
|
|
var deploymentResult = await DeployAsync(deploymentParameters);
|
|
|
|
await AssertFailsToStart(deploymentResult);
|
|
|
|
Assert.Contains(TestSink.Writes, context => context.Message.Contains("Is Console redirection: True"));
|
|
}
|
|
|
|
private async Task AssertFailsToStart(IISDeploymentResult deploymentResult)
|
|
{
|
|
var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld");
|
|
|
|
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
|
|
|
StopServer();
|
|
}
|
|
|
|
[ConditionalFact]
|
|
public async Task Gets500_30_ErrorPage()
|
|
{
|
|
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
|
|
deploymentParameters.TransformArguments((a, _) => $"{a} EarlyReturn");
|
|
|
|
var deploymentResult = await DeployAsync(deploymentParameters);
|
|
|
|
var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld");
|
|
Assert.False(response.IsSuccessStatusCode);
|
|
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
|
|
|
|
var responseText = await response.Content.ReadAsStringAsync();
|
|
Assert.Contains("500.30 - ANCM In-Process Start Failure", responseText);
|
|
}
|
|
}
|
|
}
|