Пример #1
0
        public async Task RemoveInProcessReference_FailedToFindRequestHandler()
        {
            var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);

            deploymentParameters.ApplicationType = ApplicationType.Standalone;
            var deploymentResult = await DeployAsync(deploymentParameters);

            File.Delete(Path.Combine(deploymentResult.ContentRoot, "aspnetcorev2_inprocess.dll"));

            await AssertSiteFailsToStartWithInProcessStaticContent(deploymentResult);

            if (DeployerSelector.IsForwardsCompatibilityTest)
            {
                EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessFailedToFindNativeDependencies(deploymentResult), Logger);
            }
            else
            {
                EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessFailedToFindRequestHandler(deploymentResult), Logger);
            }
        }
Пример #2
0
        public async Task StartupTimeoutIsApplied()
        {
            var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);

            deploymentParameters.TransformArguments((a, _) => $"{a} Hang");
            deploymentParameters.WebConfigActionList.Add(
                WebConfigHelpers.AddOrModifyAspNetCoreSection("startupTimeLimit", "1"));

            var deploymentResult = await DeployAsync(deploymentParameters);

            var response = await deploymentResult.HttpClient.GetAsync("/");

            Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);

            StopServer();

            EventLogHelpers.VerifyEventLogEvents(deploymentResult,
                                                 EventLogHelpers.InProcessFailedToStart(deploymentResult, "Managed server didn't initialize after 1000 ms.")
                                                 );
        }
Пример #3
0
        public async Task InvalidFilePathForLogs_ServerStillRuns(TestVariant variant)
        {
            var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);

            deploymentParameters.WebConfigActionList.Add(
                WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogEnabled", "true"));
            deploymentParameters.WebConfigActionList.Add(
                WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogFile", Path.Combine("Q:", "std")));

            var deploymentResult = await DeployAsync(deploymentParameters);

            await Helpers.AssertStarts(deploymentResult, "HelloWorld");

            StopServer();
            if (variant.HostingModel == HostingModel.InProcess)
            {
                // Error is getting logged twice, from shim and handler
                EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.CouldNotStartStdoutFileRedirection("Q:\\std", deploymentResult), allowMultiple: true);
            }
        }
Пример #4
0
        public async Task InvalidFilePathForLogs_ServerStillRuns(TestVariant variant)
        {
            var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);

            deploymentParameters.WebConfigActionList.Add(
                WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogEnabled", "true"));
            deploymentParameters.WebConfigActionList.Add(
                WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogFile", Path.Combine("Q:", "std")));

            var deploymentResult = await DeployAsync(deploymentParameters);

            await Helpers.AssertStarts(deploymentResult, "HelloWorld");

            StopServer();
            if (variant.HostingModel == HostingModel.InProcess)
            {
                EventLogHelpers.VerifyEventLogEvent(deploymentResult, "Could not start stdout redirection in (.*)aspnetcorev2.dll. Exception message: HRESULT 0x80070003");
                EventLogHelpers.VerifyEventLogEvent(deploymentResult, "Could not stop stdout redirection in (.*)aspnetcorev2.dll. Exception message: HRESULT 0x80070002");
            }
        }
Пример #5
0
        public async Task ReportsWebConfigAuthoringErrors(string scenario)
        {
            var(expectedError, action) = InvalidConfigTransformations[scenario];
            var iisDeploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);

            iisDeploymentParameters.WebConfigActionList.Add((element, _) => action(element));
            var deploymentResult = await DeployAsync(iisDeploymentParameters);

            var result = await deploymentResult.HttpClient.GetAsync("/HelloWorld");

            Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);

            // Config load errors might not allow us to initialize log file
            deploymentResult.AllowNoLogs();

            StopServer();

            EventLogHelpers.VerifyEventLogEvents(deploymentResult,
                                                 EventLogHelpers.ConfigurationLoadError(deploymentResult, expectedError)
                                                 );
        }
Пример #6
0
        public async Task FailsAndLogsEventLogForMixedHostingModel(HostingModel firstApp)
        {
            var parameters = _fixture.GetBaseDeploymentParameters(firstApp);

            parameters.ServerConfigActionList.Add(DuplicateApplication);
            var result = await DeployAsync(parameters);

            // Modify hosting model of other app to be the opposite
            var otherApp = firstApp == HostingModel.InProcess ? HostingModel.OutOfProcess : HostingModel.InProcess;

            SetHostingModel(_publishedApplication.Path, otherApp);

            var result1 = await result.HttpClient.GetAsync("/app1/HelloWorld");

            var result2 = await result.HttpClient.GetAsync("/app2/HelloWorld");

            Assert.Equal(200, (int)result1.StatusCode);
            Assert.Equal(500, (int)result2.StatusCode);
            StopServer();
            EventLogHelpers.VerifyEventLogEvent(result, "Mixed hosting model is not supported.");
        }
Пример #7
0
        public async Task OutOfProcessToInProcessHostingModelSwitchWorks()
        {
            var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);

            var deploymentResult = await DeployAsync(deploymentParameters);

            await deploymentResult.AssertStarts();

            deploymentResult.ModifyWebConfig(element => element
                                             .Descendants("system.webServer")
                                             .Single()
                                             .GetOrAdd("aspNetCore")
                                             .SetAttributeValue("hostingModel", "inprocess"));

            // Have to retry here to allow ANCM to receive notification and react to it
            // Verify that inprocess application was created and tried to start
            await deploymentResult.HttpClient.RetryRequestAsync("/HelloWorld", r => r.StatusCode == HttpStatusCode.InternalServerError);

            StopServer();
            EventLogHelpers.VerifyEventLogEvent(deploymentResult, TestSink, "Could not find the assembly 'aspnetcorev2_inprocess.dll'");
        }
Пример #8
0
        public async Task RemoveHostfxrFromApp_InProcessHostfxrLoadFailure()
        {
            var deploymentParameters = Fixture.GetBaseDeploymentParameters(Fixture.InProcessTestSite);

            deploymentParameters.ApplicationType = ApplicationType.Standalone;
            var deploymentResult = await DeployAsync(deploymentParameters);

            // We don't distinguish between load failure types so making dll empty should be enough
            File.WriteAllText(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll"), "");

            if (DeployerSelector.HasNewShim)
            {
                await AssertSiteFailsToStartWithInProcessStaticContent(deploymentResult, "HTTP Error 500.32 - ANCM Failed to Load dll");
            }
            else
            {
                await AssertSiteFailsToStartWithInProcessStaticContent(deploymentResult);
            }

            EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessHostfxrUnableToLoad(deploymentResult), Logger);
        }
Пример #9
0
        public async Task FailsAndLogsWhenRunningTwoInProcessApps()
        {
            var parameters = Fixture.GetBaseDeploymentParameters(HostingModel.InProcess);

            parameters.ServerConfigActionList.Add(DuplicateApplication);

            var result = await DeployAsync(parameters);

            var result1 = await result.HttpClient.GetAsync("/app1/HelloWorld");

            var result2 = await result.HttpClient.GetAsync("/app2/HelloWorld");

            Assert.Equal(200, (int)result1.StatusCode);
            Assert.Equal(500, (int)result2.StatusCode);
            StopServer();

            if (DeployerSelector.HasNewShim)
            {
                Assert.Contains("500.35 - ANCM Multiple In-Process Applications in same Process", await result2.Content.ReadAsStringAsync());
            }

            EventLogHelpers.VerifyEventLogEvent(result, EventLogHelpers.OnlyOneAppPerAppPool(), Logger);
        }
Пример #10
0
        public async Task RemoveHostfxrFromApp_InProcessHostfxrAPIAbsent()
        {
            var deploymentParameters = Fixture.GetBaseDeploymentParameters(Fixture.InProcessTestSite);

            deploymentParameters.ApplicationType = ApplicationType.Standalone;
            var deploymentResult = await DeployAsync(deploymentParameters);

            File.Copy(
                Path.Combine(deploymentResult.ContentRoot, "aspnetcorev2_inprocess.dll"),
                Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll"),
                true);

            if (DeployerSelector.HasNewShim)
            {
                await AssertSiteFailsToStartWithInProcessStaticContent(deploymentResult, "HTTP Error 500.32 - ANCM Failed to Load dll");
            }
            else
            {
                await AssertSiteFailsToStartWithInProcessStaticContent(deploymentResult);
            }

            EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessHostfxrInvalid(deploymentResult), Logger);
        }
Пример #11
0
        public async Task DoesNotStartIfDisabled()
        {
            var deploymentParameters = _fixture.GetBaseDeploymentParameters();

            using (new TestRegistryKey(
                       Registry.LocalMachine,
                       "SOFTWARE\\Microsoft\\IIS Extensions\\IIS AspNetCore Module V2\\Parameters",
                       "DisableANCM",
                       1))
            {
                var deploymentResult = await DeployAsync(deploymentParameters);

                // Disabling ANCM produces no log files
                deploymentResult.AllowNoLogs();

                var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld");

                Assert.False(response.IsSuccessStatusCode);

                StopServer();

                EventLogHelpers.VerifyEventLogEvent(deploymentResult, "AspNetCore Module is disabled");
            }
        }