Exemplo n.º 1
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), Logger, allowMultiple: true);
            }
        }
Exemplo n.º 2
0
        public async Task FrameworkNotFoundExceptionLogged_File()
        {
            var deploymentParameters =
                Fixture.GetBaseDeploymentParameters(Fixture.InProcessTestSite);

            deploymentParameters.EnableLogging(_logFolderPath);

            var deploymentResult = await DeployAsync(deploymentParameters);

            Helpers.ModifyFrameworkVersionInRuntimeConfig(deploymentResult);

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

            Assert.False(response.IsSuccessStatusCode);

            StopServer();

            var contents       = Helpers.ReadAllTextFromFile(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath), Logger);
            var expectedString = "The specified framework 'Microsoft.NETCore.App', version '2.9.9' was not found.";

            EventLogHelpers.VerifyEventLogEvent(deploymentResult, expectedString, Logger);
            Assert.Contains(expectedString, contents);
        }
        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", await result2.Content.ReadAsStringAsync());
            }

            EventLogHelpers.VerifyEventLogEvent(result, EventLogHelpers.OnlyOneAppPerAppPool(), Logger);
        }
Exemplo n.º 4
0
        public async Task EnableCoreHostTraceLogging_FileCaptureNativeLogs(string path)
        {
            var deploymentParameters =
                Fixture.GetBaseDeploymentParameters(Fixture.InProcessTestSite);

            deploymentParameters.EnvironmentVariables["COREHOST_TRACE"] = "1";
            deploymentParameters.TransformArguments((a, _) => $"{a} {path}");

            deploymentParameters.EnableLogging(_logFolderPath);

            var deploymentResult = await DeployAsync(deploymentParameters);

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

            Assert.False(response.IsSuccessStatusCode);

            StopServer();

            var fileInDirectory = Directory.GetFiles(_logFolderPath).First();
            var contents        = Helpers.ReadAllTextFromFile(fileInDirectory, Logger);

            EventLogHelpers.VerifyEventLogEvent(deploymentResult, "Invoked hostfxr", Logger);
            Assert.Contains("Invoked hostfxr", contents);
        }
Exemplo n.º 5
0
        public async Task ApplicationInitializationPageIsRequested(HostingModel hostingModel)
        {
            // This test often hits a memory leak in warmup.dll module, it has been reported to IIS team
            using (AppVerifier.Disable(DeployerSelector.ServerType, 0x900))
            {
                var baseDeploymentParameters = Fixture.GetBaseDeploymentParameters(hostingModel);
                EnablePreload(baseDeploymentParameters);

                baseDeploymentParameters.ServerConfigActionList.Add(
                    (config, _) => {
                    config
                    .RequiredElement("system.webServer")
                    .GetOrAdd("applicationInitialization")
                    .GetOrAdd("add", "initializationPage", "/CreateFile");
                });

                var result = await DeployAsync(baseDeploymentParameters);

                await Helpers.Retry(async() => await File.ReadAllTextAsync(Path.Combine(result.ContentRoot, "Started.txt")), TimeoutExtensions.DefaultTimeoutValue);

                StopServer();
                EventLogHelpers.VerifyEventLogEvent(result, EventLogHelpers.Started(result), Logger);
            }
        }
Exemplo n.º 6
0
        public async Task GracefulShutdownWorksWithMultipleRequestsInFlight_InProcess()
        {
            // The goal of this test is to have multiple requests currently in progress
            // and for app offline to be dropped. We expect that all requests are eventually drained
            // and graceful shutdown occurs.
            var deploymentParameters = Fixture.GetBaseDeploymentParameters(Fixture.InProcessTestSite);

            deploymentParameters.TransformArguments((a, _) => $"{a} IncreaseShutdownLimit");

            var deploymentResult = await DeployAsync(deploymentParameters);

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

            // Send two requests that will hang until data is sent from the client.
            var connectionList = new List <TestConnection>();

            for (var i = 0; i < 2; i++)
            {
                var connection = new TestConnection(deploymentResult.HttpClient.BaseAddress.Port);
                await connection.Send(
                    "POST /ReadAndCountRequestBody HTTP/1.1",
                    "Content-Length: 1",
                    "Host: localhost",
                    "Connection: close",
                    "",
                    "");

                await connection.Receive(
                    "HTTP/1.1 200 OK", "");

                await connection.ReceiveHeaders();

                await connection.Receive("1", $"{i + 1}");

                connectionList.Add(connection);
            }

            // Send a request that will end once app lifetime is triggered (ApplicationStopping cts).
            var statusConnection = new TestConnection(deploymentResult.HttpClient.BaseAddress.Port);

            await statusConnection.Send(
                "GET /WaitForAppToStartShuttingDown HTTP/1.1",
                "Host: localhost",
                "Connection: close",
                "",
                "");

            await statusConnection.Receive("HTTP/1.1 200 OK",
                                           "");

            await statusConnection.ReceiveHeaders();

            // Receiving some data means we are currently waiting for IHostApplicationLifetime.
            await statusConnection.Receive("5",
                                           "test1",
                                           "");

            AddAppOffline(deploymentResult.ContentRoot);

            // Receive the rest of all open connections.
            await statusConnection.Receive("5", "test2", "");

            for (var i = 0; i < 2; i++)
            {
                await connectionList[i].Send("a", "");
                await connectionList[i].Receive("", "4", "done");
                connectionList[i].Dispose();
            }

            deploymentResult.AssertWorkerProcessStop();

            // Shutdown should be graceful here!
            EventLogHelpers.VerifyEventLogEvent(deploymentResult,
                                                EventLogHelpers.InProcessShutdown(), Logger);
        }