public void Deserialize(IXunitSerializationInfo info) { Skip = info.GetValue <string>(nameof(Skip)); Server = info.GetValue <ServerType>(nameof(Server)); Tfm = info.GetValue <string>(nameof(Tfm)); ApplicationType = info.GetValue <ApplicationType>(nameof(ApplicationType)); Architecture = info.GetValue <RuntimeArchitecture>(nameof(Architecture)); HostingModel = info.GetValue <HostingModel>(nameof(HostingModel)); AncmVersion = info.GetValue <AncmVersion>(nameof(AncmVersion)); }
public Task Startup(AncmVersion ancmVersion) { // ANCM v1 currently does *not* retry if an app fails to start the first time due to a port collision. // So, this test is expected to fail on v1 approximately 1 in 1,000 times (probably of at least one collision // when 10 sites choose a random port from the range 1025-48000). Adding one retry should reduce the failure // rate from 1 in 1,000 to 1 in 1,000,000. The previous product code (with "srand(GetTickCount())") should still // fail the test reliably. // https://github.com/aspnet/IISIntegration/issues/1350 // // ANCM v2 does retry on port collisions, so no retries should be required. var attempts = (ancmVersion == AncmVersion.AspNetCoreModule) ? 2 : 1; return(Helpers.Retry(async() => { const int numApps = 10; using (var deployers = new DisposableList <ApplicationDeployer>()) { var deploymentResults = new List <DeploymentResult>(); // Deploy all apps for (var i = 0; i < numApps; i++) { var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel: IntegrationTesting.HostingModel.OutOfProcess); deploymentParameters.AncmVersion = ancmVersion; var deployer = CreateDeployer(deploymentParameters); deployers.Add(deployer); deploymentResults.Add(await deployer.DeployAsync()); } // Start all requests as quickly as possible, so apps are started as quickly as possible, // to test possible race conditions when multiple apps start at the same time. var requestTasks = new List <Task <HttpResponseMessage> >(); foreach (var deploymentResult in deploymentResults) { requestTasks.Add(deploymentResult.HttpClient.GetAsync("/HelloWorld")); } // Verify all apps started and return expected response foreach (var requestTask in requestTasks) { var response = await requestTask; Assert.Equal(HttpStatusCode.OK, response.StatusCode); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal("Hello World", responseText); } } }, attempts: attempts, msDelay: 0)); }
public async Task ConfigurationChangeForcesChildProcessRestart(AncmVersion version) { var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true); deploymentParameters.AncmVersion = version; var deploymentResult = await DeployAsync(deploymentParameters); var processBefore = await deploymentResult.HttpClient.GetStringAsync("/ProcessId"); // Just "touching" web.config should be enough deploymentResult.ModifyWebConfig(element => {}); // Have to retry here to allow ANCM to receive notification and react to it // Verify that worker process gets restarted with new process id await deploymentResult.HttpClient.RetryRequestAsync("/ProcessId", async r => await r.Content.ReadAsStringAsync() != processBefore); }
protected string GetAncmLocation(AncmVersion version) { var ancmDllName = version == AncmVersion.AspNetCoreModuleV2 ? "aspnetcorev2.dll" : "aspnetcore.dll"; var arch = DeploymentParameters.RuntimeArchitecture == RuntimeArchitecture.x64 ? $@"x64\{ancmDllName}" : $@"x86\{ancmDllName}"; var ancmFile = Path.Combine(AppContext.BaseDirectory, arch); if (!File.Exists(Environment.ExpandEnvironmentVariables(ancmFile))) { ancmFile = Path.Combine(AppContext.BaseDirectory, ancmDllName); if (!File.Exists(Environment.ExpandEnvironmentVariables(ancmFile))) { throw new FileNotFoundException("AspNetCoreModule could not be found.", ancmFile); } } return(ancmFile); }
public async Task Startup(AncmVersion ancmVersion) { const int numApps = 10; using (var deployers = new DisposableList <ApplicationDeployer>()) { var deploymentResults = new List <DeploymentResult>(); // Deploy all apps for (var i = 0; i < numApps; i++) { var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel: IntegrationTesting.HostingModel.OutOfProcess); deploymentParameters.AncmVersion = ancmVersion; var deployer = CreateDeployer(deploymentParameters); deployers.Add(deployer); deploymentResults.Add(await deployer.DeployAsync()); } // Start all requests as quickly as possible, so apps are started as quickly as possible, // to test possible race conditions when multiple apps start at the same time. var requestTasks = new List <Task <HttpResponseMessage> >(); foreach (var deploymentResult in deploymentResults) { requestTasks.Add(deploymentResult.HttpClient.GetAsync("/HelloWorld")); } // Verify all apps started and return expected response foreach (var requestTask in requestTasks) { var response = await requestTask; Assert.Equal(HttpStatusCode.OK, response.StatusCode); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal("Hello World", responseText); } } }
private void VaryByAncmHostingModel(IList <TestVariant> variants, ServerType server, string tfm, ApplicationType type, RuntimeArchitecture arch, string skip, AncmVersion version) { foreach (var hostingModel in HostingModels) { var skipAncm = skip; if (hostingModel == HostingModel.InProcess) { // Not supported if (Tfm.Matches(Tfm.Net461, tfm) || Tfm.Matches(Tfm.NetCoreApp20, tfm) || version == AncmVersion.AspNetCoreModule) { continue; } if (!IISExpressAncmSchema.SupportsInProcessHosting) { skipAncm = skipAncm ?? IISExpressAncmSchema.SkipReason; } } variants.Add(new TestVariant() { Server = server, Tfm = tfm, ApplicationType = type, Architecture = arch, AncmVersion = version, HostingModel = hostingModel, Skip = skipAncm, }); } }