Remove Out-Of-Process test site fixture and make deployer check physical (#8659)

This commit is contained in:
Justin Kotalik 2019-03-20 08:33:26 -07:00 committed by GitHub
parent 9f1a978230
commit b8e7cbad02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 93 deletions

View File

@ -5,41 +5,53 @@ using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.Testing.xunit;
using Xunit; using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
[Collection(IISCompressionSiteCollection.Name)] [Collection(PublishedSitesCollection.Name)]
public abstract class CompressionTests : FixtureLoggedTest public class CompressionTests : IISFunctionalTestBase
{ {
private readonly IISTestSiteFixture _fixture; public CompressionTests(PublishedSitesFixture fixture) : base(fixture)
[Collection(IISTestSiteCollection.Name)]
public class InProc: CompressionTests
{ {
public InProc(IISTestSiteFixture fixture) : base(fixture) { }
}
[Collection(OutOfProcessTestSiteCollection.Name)]
public class OutOfProcess: CompressionTests
{
public OutOfProcess(OutOfProcessTestSiteFixture fixture) : base(fixture) { }
}
protected CompressionTests(IISTestSiteFixture fixture) : base(fixture)
{
_fixture = fixture;
} }
[ConditionalFact] [ConditionalFact]
public async Task PassesThroughCompression() public async Task PassesThroughCompressionOutOfProcess()
{ {
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
var deploymentResult = await DeployAsync(deploymentParameters);
var request = new HttpRequestMessage(HttpMethod.Get, "/CompressedData"); var request = new HttpRequestMessage(HttpMethod.Get, "/CompressedData");
request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip")); request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
var response = await _fixture.Client.SendAsync(request); var response = await deploymentResult.HttpClient.SendAsync(request);
Assert.Equal("gzip", response.Content.Headers.ContentEncoding.Single());
Assert.Equal(
new byte[] {
0x1F, 0x8B, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x0A, 0x63, 0x60, 0xA0, 0x3D, 0x00, 0x00,
0xCA, 0xC6, 0x88, 0x99, 0x64, 0x00, 0x00, 0x00 },
await response.Content.ReadAsByteArrayAsync());
}
[ConditionalFact]
public async Task PassesThroughCompressionInProcess()
{
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.InProcess);
var deploymentResult = await DeployAsync(deploymentParameters);
var request = new HttpRequestMessage(HttpMethod.Get, "/CompressedData");
request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
var response = await deploymentResult.HttpClient.SendAsync(request);
Assert.Equal("gzip", response.Content.Headers.ContentEncoding.Single()); Assert.Equal("gzip", response.Content.Headers.ContentEncoding.Single());
Assert.Equal( Assert.Equal(
new byte[] { new byte[] {

View File

@ -4,51 +4,52 @@
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities;
using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.Testing.xunit;
using Xunit; using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
public abstract class ServerAbortTests: FixtureLoggedTest [Collection(PublishedSitesCollection.Name)]
public class ServerAbortOutOfProcessTests : IISFunctionalTestBase
{ {
private readonly IISTestSiteFixture _fixture; public ServerAbortOutOfProcessTests(PublishedSitesFixture fixture) : base(fixture)
[Collection(IISTestSiteCollection.Name)]
public class InProc: ServerAbortTests
{ {
public InProc(IISTestSiteFixture fixture) : base(fixture) { }
}
[Collection(OutOfProcessTestSiteCollection.Name)]
public class OutOfProcess: ServerAbortTests
{
public OutOfProcess(OutOfProcessTestSiteFixture fixture) : base(fixture) { }
}
protected ServerAbortTests(IISTestSiteFixture fixture) : base(fixture)
{
_fixture = fixture;
} }
[ConditionalFact] [ConditionalFact]
public async Task ClosesConnectionOnServerAbort() public async Task ClosesConnectionOnServerAbortOutOfProcess()
{ {
try try
{ {
var response = await _fixture.Client.GetAsync("/Abort").DefaultTimeout(); var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
// 502 is expected for outofproc but not for inproc var deploymentResult = await DeployAsync(deploymentParameters);
if (_fixture.DeploymentResult.DeploymentParameters.HostingModel == HostingModel.OutOfProcess)
{ var response = await deploymentResult.HttpClient.GetAsync("/Abort").DefaultTimeout();
Assert.Equal(HttpStatusCode.BadGateway, response.StatusCode);
// 0x80072f78 ERROR_HTTP_INVALID_SERVER_RESPONSE The server returned an invalid or unrecognized response Assert.Equal(HttpStatusCode.BadGateway, response.StatusCode);
Assert.Contains("0x80072f78", await response.Content.ReadAsStringAsync()); // 0x80072f78 ERROR_HTTP_INVALID_SERVER_RESPONSE The server returned an invalid or unrecognized response
} Assert.Contains("0x80072f78", await response.Content.ReadAsStringAsync());
else }
{ catch (HttpRequestException)
Assert.True(false, "Should not reach here"); {
} // Connection reset is expected
}
}
[ConditionalFact]
public async Task ClosesConnectionOnServerAbortInProcess()
{
try
{
var deploymentParameters = Fixture.GetBaseDeploymentParameters(HostingModel.InProcess);
var deploymentResult = await DeployAsync(deploymentParameters);
var response = await deploymentResult.HttpClient.GetAsync("/Abort").DefaultTimeout();
Assert.True(false, "Should not reach here");
} }
catch (HttpRequestException) catch (HttpRequestException)
{ {

View File

@ -13,17 +13,4 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
public const string Name = nameof(IISTestSiteCollection); public const string Name = nameof(IISTestSiteCollection);
} }
[CollectionDefinition(Name)]
public class OutOfProcessTestSiteCollection : ICollectionFixture<OutOfProcessTestSiteFixture>
{
public const string Name = nameof(OutOfProcessTestSiteCollection);
}
[CollectionDefinition(Name)]
public class OutOfProcessV1TestSiteCollection : ICollectionFixture<OutOfProcessV1TestSiteFixture>
{
public const string Name = nameof(OutOfProcessV1TestSiteCollection);
}
} }

View File

@ -11,33 +11,6 @@ using Microsoft.Extensions.Logging.Testing;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{ {
public class OutOfProcessTestSiteFixture : IISTestSiteFixture
{
public OutOfProcessTestSiteFixture() : base(Configure)
{
}
private static void Configure(IISDeploymentParameters deploymentParameters)
{
deploymentParameters.ApplicationPublisher = new PublishedApplicationPublisher(Helpers.GetOutOfProcessTestSitesName());;
deploymentParameters.HostingModel = HostingModel.OutOfProcess;
}
}
public class OutOfProcessV1TestSiteFixture : IISTestSiteFixture
{
public OutOfProcessV1TestSiteFixture() : base(Configure)
{
}
private static void Configure(IISDeploymentParameters deploymentParameters)
{
deploymentParameters.ApplicationPublisher = new PublishedApplicationPublisher(Helpers.GetOutOfProcessTestSitesName());;
deploymentParameters.ApplicationPath = Helpers.GetOutOfProcessTestSitesName();
deploymentParameters.HostingModel = HostingModel.OutOfProcess;
}
}
public class IISTestSiteFixture : IDisposable public class IISTestSiteFixture : IDisposable
{ {
private ApplicationDeployer _deployer; private ApplicationDeployer _deployer;

View File

@ -22,8 +22,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact] [ConditionalFact]
public async Task CheckBackwardsCompatibilityIsUsed() public async Task CheckBackwardsCompatibilityIsUsed()
{ {
var response = await _fixture.Client.GetAsync("/HelloWorld"); var response = await _fixture.Client.GetAsync("/HelloWorld");
Assert.True(response.IsSuccessStatusCode);
_fixture.DeploymentResult.HostProcess.Refresh(); _fixture.DeploymentResult.HostProcess.Refresh();
var handles = _fixture.DeploymentResult.HostProcess.Modules; var handles = _fixture.DeploymentResult.HostProcess.Modules;

View File

@ -218,11 +218,11 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
AddTemporaryAppHostConfig(contentRoot, port); AddTemporaryAppHostConfig(contentRoot, port);
WaitUntilSiteStarted(); WaitUntilSiteStarted(contentRoot);
} }
} }
private void WaitUntilSiteStarted() private void WaitUntilSiteStarted(string contentRoot)
{ {
ServiceController serviceController = new ServiceController("w3svc"); ServiceController serviceController = new ServiceController("w3svc");
Logger.LogInformation("W3SVC status " + serviceController.Status); Logger.LogInformation("W3SVC status " + serviceController.Status);
@ -241,6 +241,12 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
var site = serverManager.Sites.Single(); var site = serverManager.Sites.Single();
var appPool = serverManager.ApplicationPools.Single(); var appPool = serverManager.ApplicationPools.Single();
var actualPath = site.Applications.FirstOrDefault().VirtualDirectories.Single().PhysicalPath;
if (actualPath != contentRoot)
{
throw new InvalidOperationException($"Wrong physical path. Expected: {contentRoot} Actual: {actualPath}");
}
if (appPool.State != ObjectState.Started && appPool.State != ObjectState.Starting) if (appPool.State != ObjectState.Started && appPool.State != ObjectState.Starting)
{ {
var state = appPool.Start(); var state = appPool.Start();