Add a functional test to verify that build-time compiled views play w… (#839)
* Add a functional test to verify that build-time compiled views play with DeveloperExceptionPage Use RazorSdk to compile in E2E scenarios Fixes #835 Fixes #836
This commit is contained in:
parent
68bb45bfb9
commit
d0a8ef02cf
|
|
@ -3,37 +3,37 @@
|
|||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Package Versions">
|
||||
<MicrosoftAspNetCoreAllPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreAllPackageVersion>
|
||||
<MicrosoftAspNetCoreAspNetCoreModulePackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreAspNetCoreModulePackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationFacebookPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreAuthenticationFacebookPackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationGooglePackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreAuthenticationGooglePackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationMicrosoftAccountPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreAuthenticationMicrosoftAccountPackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationTwitterPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreAuthenticationTwitterPackageVersion>
|
||||
<MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>
|
||||
<MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>
|
||||
<MicrosoftAspNetCoreIdentityPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreIdentityPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreMvcPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion>
|
||||
<MicrosoftAspNetCorePackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCorePackageVersion>
|
||||
<MicrosoftAspNetCoreServerHttpSysPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreServerHttpSysPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview2-30077</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
|
||||
<MicrosoftAspNetCoreSessionPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreSessionPackageVersion>
|
||||
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreStaticFilesPackageVersion>
|
||||
<MicrosoftAspNetCoreWebUtilitiesPackageVersion>2.1.0-preview2-30077</MicrosoftAspNetCoreWebUtilitiesPackageVersion>
|
||||
<MicrosoftEntityFrameworkCoreInMemoryPackageVersion>2.1.0-preview2-30077</MicrosoftEntityFrameworkCoreInMemoryPackageVersion>
|
||||
<MicrosoftEntityFrameworkCoreSqlServerPackageVersion>2.1.0-preview2-30077</MicrosoftEntityFrameworkCoreSqlServerPackageVersion>
|
||||
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>2.1.0-preview2-30077</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationBinderPackageVersion>2.1.0-preview2-30077</MicrosoftExtensionsConfigurationBinderPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.1.0-preview2-30077</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
|
||||
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.0-preview2-30077</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.0-preview2-30077</MicrosoftExtensionsConfigurationJsonPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationUserSecretsPackageVersion>2.1.0-preview2-30077</MicrosoftExtensionsConfigurationUserSecretsPackageVersion>
|
||||
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview2-30077</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview2-30077</MicrosoftExtensionsLoggingPackageVersion>
|
||||
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview2-30077</MicrosoftExtensionsLoggingTestingPackageVersion>
|
||||
<MicrosoftAspNetCoreAllPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreAllPackageVersion>
|
||||
<MicrosoftAspNetCoreAspNetCoreModulePackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreAspNetCoreModulePackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationCorePackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreAuthenticationCorePackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationFacebookPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreAuthenticationFacebookPackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationGooglePackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreAuthenticationGooglePackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationMicrosoftAccountPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreAuthenticationMicrosoftAccountPackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion>
|
||||
<MicrosoftAspNetCoreAuthenticationTwitterPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreAuthenticationTwitterPackageVersion>
|
||||
<MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>
|
||||
<MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>
|
||||
<MicrosoftAspNetCoreIdentityPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreIdentityPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreMvcPackageVersion>
|
||||
<MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion>
|
||||
<MicrosoftAspNetCorePackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCorePackageVersion>
|
||||
<MicrosoftAspNetCoreServerHttpSysPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreServerHttpSysPackageVersion>
|
||||
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview2-30106</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
|
||||
<MicrosoftAspNetCoreSessionPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreSessionPackageVersion>
|
||||
<MicrosoftAspNetCoreStaticFilesPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreStaticFilesPackageVersion>
|
||||
<MicrosoftAspNetCoreWebUtilitiesPackageVersion>2.1.0-preview2-30106</MicrosoftAspNetCoreWebUtilitiesPackageVersion>
|
||||
<MicrosoftEntityFrameworkCoreInMemoryPackageVersion>2.1.0-preview2-30106</MicrosoftEntityFrameworkCoreInMemoryPackageVersion>
|
||||
<MicrosoftEntityFrameworkCoreSqlServerPackageVersion>2.1.0-preview2-30106</MicrosoftEntityFrameworkCoreSqlServerPackageVersion>
|
||||
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>2.1.0-preview2-30106</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationBinderPackageVersion>2.1.0-preview2-30106</MicrosoftExtensionsConfigurationBinderPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.1.0-preview2-30106</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
|
||||
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.0-preview2-30106</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.0-preview2-30106</MicrosoftExtensionsConfigurationJsonPackageVersion>
|
||||
<MicrosoftExtensionsConfigurationUserSecretsPackageVersion>2.1.0-preview2-30106</MicrosoftExtensionsConfigurationUserSecretsPackageVersion>
|
||||
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview2-30106</MicrosoftExtensionsLoggingConsolePackageVersion>
|
||||
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview2-30106</MicrosoftExtensionsLoggingPackageVersion>
|
||||
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview2-30106</MicrosoftExtensionsLoggingTestingPackageVersion>
|
||||
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
|
||||
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview2-26130-04</MicrosoftNETCoreApp21PackageVersion>
|
||||
<MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
version:2.1.0-preview2-15698
|
||||
commithash:7216e5068cb1957e09d45fcbe58a744dd5c2de73
|
||||
version:2.1.0-preview2-15704
|
||||
commithash:21fdd9f5254226f407a2b4b3ef963693c2fd7998
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@
|
|||
<Description>Music store application on ASP.NET Core</Description>
|
||||
<TargetFrameworks>netcoreapp2.1;netcoreapp2.0;net461</TargetFrameworks>
|
||||
<DefineConstants>$(DefineConstants);DEMO</DefineConstants>
|
||||
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
|
||||
<RazorCompileOnBuild>true</RazorCompileOnBuild>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<RuntimeIdentifiers Condition="'$(Configuration)' != 'RuntimeStore'">win7-x86;win7-x64;linux-x64;osx-x64</RuntimeIdentifiers>
|
||||
<Configurations>Debug;Release;RuntimeStore</Configurations>
|
||||
<DebugType Condition="'$(TargetFramework)' == 'net461'">full</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -41,4 +42,14 @@
|
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(MicrosoftEntityFrameworkCoreSqlServerPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="$(MicrosoftExtensionsConfigurationCommandLinePackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="VerifyPrecompiledViews" AfterTargets="Publish">
|
||||
<Error Text="Did not use Razor Sdk to compile views. Actual $(ResolvedRazorCompileToolset)" Condition="'$(ResolvedRazorCompileToolset)' != 'RazorSdk'" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ExpectedViewOutput>$(PublishDir)$(RazorTargetName).dll</ExpectedViewOutput>
|
||||
</PropertyGroup>
|
||||
|
||||
<Error Text="Did not precompiled view binary '$(ExpectedViewOutput)'" Condition="!Exists('$(ExpectedViewOutput)')" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
@page
|
||||
@{ throw new InvalidOperationException(); }
|
||||
|
|
@ -127,6 +127,13 @@ namespace E2ETests
|
|||
StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public async Task VerifyDeveloperExceptionPage(HttpResponseMessage response)
|
||||
{
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
Assert.Contains(responseContent, "PageThatThrows.cshtml");
|
||||
Assert.Contains(responseContent, "@{ throw new InvalidOperationException(); }");
|
||||
}
|
||||
|
||||
public void ValidateLayoutPage(string responseContent)
|
||||
{
|
||||
Assert.Contains("ASP.NET MVC Music Store", responseContent, StringComparison.OrdinalIgnoreCase);
|
||||
|
|
@ -539,4 +546,4 @@ namespace E2ETests
|
|||
.Select(c => c.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,5 +85,58 @@ namespace E2ETests
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RunDeveloperTests(
|
||||
ServerType serverType,
|
||||
RuntimeFlavor runtimeFlavor,
|
||||
ApplicationType applicationType,
|
||||
RuntimeArchitecture runtimeArchitecture)
|
||||
{
|
||||
var testName = $"PublishAndRunTests_{serverType}_{runtimeFlavor}_{applicationType}";
|
||||
using (StartLog(out var loggerFactory, testName))
|
||||
{
|
||||
var logger = loggerFactory.CreateLogger("Publish_And_Run_Development");
|
||||
var musicStoreDbName = DbUtils.GetUniqueName();
|
||||
|
||||
var deploymentParameters = new DeploymentParameters(
|
||||
Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, runtimeArchitecture)
|
||||
{
|
||||
PublishApplicationBeforeDeployment = true,
|
||||
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
|
||||
TargetFramework = Helpers.GetTargetFramework(runtimeFlavor),
|
||||
Configuration = Helpers.GetCurrentBuildConfiguration(),
|
||||
EnvironmentName = "Development",
|
||||
ApplicationType = applicationType,
|
||||
UserAdditionalCleanup = parameters =>
|
||||
{
|
||||
DbUtils.DropDatabase(musicStoreDbName, logger);
|
||||
}
|
||||
};
|
||||
|
||||
// Override the connection strings using environment based configuration
|
||||
deploymentParameters.EnvironmentVariables
|
||||
.Add(new KeyValuePair<string, string>(
|
||||
MusicStoreConfig.ConnectionStringKey,
|
||||
DbUtils.CreateConnectionString(musicStoreDbName)));
|
||||
|
||||
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
|
||||
{
|
||||
var deploymentResult = await deployer.DeployAsync();
|
||||
var httpClientHandler = new HttpClientHandler { UseDefaultCredentials = true };
|
||||
var httpClient = deploymentResult.CreateHttpClient(httpClientHandler);
|
||||
|
||||
// Request to base address and check if various parts of the body are rendered &
|
||||
// measure the cold startup time.
|
||||
// Add retry logic since tests are flaky on mono due to connection issues
|
||||
var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult);
|
||||
var response = await RetryHelper.RetryRequest(() => httpClient.GetAsync("PageThatThrows"), logger, cancellationToken: deploymentResult.HostShutdownToken);
|
||||
|
||||
logger.LogInformation("Verifying developer exception page");
|
||||
await validator.VerifyDeveloperExceptionPage(response);
|
||||
|
||||
logger.LogInformation("Variation completed successfully.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,24 +17,21 @@ namespace E2ETests
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
|
||||
public Task PublishAndRunTests_X64_WebListener_CoreCLR_Portable()
|
||||
{
|
||||
return RunTests(ServerType.WebListener, RuntimeFlavor.CoreClr, ApplicationType.Portable);
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
|
||||
public Task PublishAndRunTests_X64_WebListener_CoreCLR_Standalone()
|
||||
{
|
||||
return RunTests(ServerType.WebListener, RuntimeFlavor.CoreClr, ApplicationType.Standalone);
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
|
||||
public Task PublishAndRunTests_X64_WebListener_Clr()
|
||||
{
|
||||
// CLR must be published as standalone to perform rid specific deployment
|
||||
|
|
@ -47,6 +44,19 @@ namespace E2ETests
|
|||
return RunTests(ServerType.Kestrel, RuntimeFlavor.CoreClr, ApplicationType.Portable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task PublishAndRunDevelopmentTests_X64_Kestrel_CoreClr_Portable()
|
||||
{
|
||||
return _testRunner.RunTests(ServerType.Kestrel, RuntimeFlavor.CoreClr, ApplicationType.Portable, RuntimeArchitecture.x64);
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
|
||||
public Task PublishAndRunDevelopmentTests_X64_Kestrel_Clr_Portable()
|
||||
{
|
||||
return _testRunner.RunTests(ServerType.Kestrel, RuntimeFlavor.Clr, ApplicationType.Portable, RuntimeArchitecture.x64);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task PublishAndRunTests_X64_Kestrel_CoreClr_Standalone()
|
||||
{
|
||||
|
|
@ -54,8 +64,7 @@ namespace E2ETests
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
|
||||
public Task PublishAndRunTests_X64_Kestrel_Clr()
|
||||
{
|
||||
// CLR must be published as standalone to perform rid specific deployment
|
||||
|
|
|
|||
Loading…
Reference in New Issue