From 9eb706e694d8b03521e16d941a983ff5af5a6541 Mon Sep 17 00:00:00 2001 From: "ASP.NET CI" Date: Sun, 9 Sep 2018 12:15:58 -0700 Subject: [PATCH 1/4] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 54 ++++++++++++++++++++-------------------- korebuild-lock.txt | 4 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 3377ec3b0a..5915e116b1 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -4,39 +4,39 @@ 0.10.13 - 2.2.0-preview1-20180821.1 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 0.6.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 + 2.2.0-preview1-20180907.8 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 0.6.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 15.6.82 15.6.82 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 - 2.2.0-preview3-35179 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 + 2.2.0-preview3-35202 2.0.9 2.1.3 2.2.0-preview2-26905-02 1.0.1 - 2.2.0-preview3-35179 + 2.2.0-preview3-35202 15.6.1 11.1.0 2.0.3 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index 524a2323d0..552300b0ce 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.2.0-preview1-20180821.1 -commithash:c8d0cc52cd1abb697be24e288ffd54f8fae8bf17 +version:2.2.0-preview1-20180907.8 +commithash:078918eb5c1f176ee1da351c584fb4a4d7491aa0 From 3649f5bb81ef45e1e8b3ad1f9c312ed12c88d709 Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Wed, 12 Sep 2018 23:20:52 -0700 Subject: [PATCH 2/4] Add OutOfProc logging tests/ merge all inproc test sites into a single site (#1384) --- IISIntegration.NoV1.sln | 28 - IISIntegration.sln | 42 - .../IIS.Performance/IIS.Performance.csproj | 8 +- .../IISDeployer.cs | 7 +- .../IISExpressDeployer.cs | 2 +- .../Inprocess/LogPipeTests.cs | 85 ++ .../Inprocess/StartupExceptionTests.cs | 18 +- .../LoggingTests.cs => LogFileTests.cs} | 205 ++- .../PublishedSitesFixture.cs | 4 - .../Utilities/EventLogHelpers.cs | 7 + .../Utilities/Helpers.cs | 10 +- .../IIS.FunctionalTests.csproj | 8 +- .../Inprocess/StdOutRedirectionTests.cs | 29 +- .../InProcess/StartupTests.cs | 21 +- .../DummyServer.cs} | 22 +- test/WebSites/InProcessWebSite/Program.cs | 111 +- .../InProcessWebSite/Startup.WebSockets.cs | 2 +- test/WebSites/InProcessWebSite/Startup.cs | 1236 ++++++++--------- test/WebSites/OutOfProcessWebSite/Program.cs | 2 +- test/WebSites/OutOfProcessWebSite/Startup.cs | 15 +- .../OverriddenServerWebSite.csproj | 18 - .../Properties/launchSettings.json | 41 - .../StartupExceptionWebSite/Program.cs | 79 -- .../Properties/launchSettings.json | 41 - .../StartupExceptionWebSite.csproj | 18 - .../StartupExceptionWebSite/web.config | 10 - .../shared/SharedStartup/Startup.shared.cs | 37 + 27 files changed, 933 insertions(+), 1173 deletions(-) create mode 100644 test/Common.FunctionalTests/Inprocess/LogPipeTests.cs rename test/Common.FunctionalTests/{Inprocess/LoggingTests.cs => LogFileTests.cs} (61%) rename test/WebSites/{OverriddenServerWebSite/Program.cs => InProcessWebSite/DummyServer.cs} (53%) delete mode 100644 test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj delete mode 100644 test/WebSites/OverriddenServerWebSite/Properties/launchSettings.json delete mode 100644 test/WebSites/StartupExceptionWebSite/Program.cs delete mode 100644 test/WebSites/StartupExceptionWebSite/Properties/launchSettings.json delete mode 100644 test/WebSites/StartupExceptionWebSite/StartupExceptionWebSite.csproj delete mode 100644 test/WebSites/StartupExceptionWebSite/web.config create mode 100644 test/WebSites/shared/SharedStartup/Startup.shared.cs diff --git a/IISIntegration.NoV1.sln b/IISIntegration.NoV1.sln index 09ad7eac29..cbe801fc32 100644 --- a/IISIntegration.NoV1.sln +++ b/IISIntegration.NoV1.sln @@ -75,8 +75,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestTasks", "test\TestTasks EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebSites", "WebSites", "{744ACDC6-F6A0-4FF9-9421-F25C5F2DC520}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OverriddenServerWebSite", "test\WebSites\OverriddenServerWebSite\OverriddenServerWebSite.csproj", "{FC2A97F8-A749-4C04-97D1-97500066A820}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CommonLibTests", "test\CommonLibTests\CommonLibTests.vcxproj", "{1EAC8125-1765-4E2D-8CBE-56DC98A1C8C1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AspNetCoreModuleV2", "AspNetCoreModuleV2", "{06CA2C2B-83B0-4D83-905A-E0C74790009E}" @@ -103,8 +101,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InProcessRequestHandler", " EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OutOfProcessRequestHandler", "src\AspNetCoreModuleV2\OutOfProcessRequestHandler\OutOfProcessRequestHandler.vcxproj", "{7F87406C-A3C8-4139-A68D-E4C344294A67}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartupExceptionWebSite", "test\WebSites\StartupExceptionWebSite\StartupExceptionWebSite.csproj", "{340C59FC-C682-4CBA-81F8-791821EC8EDE}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "test\gtest\gtest.vcxproj", "{CAC1267B-8778-4257-AAC6-CAF481723B01}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RequestHandlerLib", "src\AspNetCoreModuleV2\RequestHandlerLib\RequestHandlerLib.vcxproj", "{1533E271-F61B-441B-8B74-59FB61DF0552}" @@ -235,18 +231,6 @@ Global {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x64.Build.0 = Release|Any CPU {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x86.ActiveCfg = Release|Any CPU {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x86.Build.0 = Release|Any CPU - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|Any CPU.ActiveCfg = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|Any CPU.Build.0 = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x64.ActiveCfg = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x64.Build.0 = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x86.ActiveCfg = Debug|x86 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x86.Build.0 = Debug|x86 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|Any CPU.ActiveCfg = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|Any CPU.Build.0 = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x64.ActiveCfg = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x64.Build.0 = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x86.ActiveCfg = Release|x86 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x86.Build.0 = Release|x86 {1EAC8125-1765-4E2D-8CBE-56DC98A1C8C1}.Debug|Any CPU.ActiveCfg = Debug|Win32 {1EAC8125-1765-4E2D-8CBE-56DC98A1C8C1}.Debug|x64.ActiveCfg = Debug|x64 {1EAC8125-1765-4E2D-8CBE-56DC98A1C8C1}.Debug|x64.Build.0 = Debug|x64 @@ -331,16 +315,6 @@ Global {7F87406C-A3C8-4139-A68D-E4C344294A67}.Release|x64.Build.0 = Release|x64 {7F87406C-A3C8-4139-A68D-E4C344294A67}.Release|x86.ActiveCfg = Release|Win32 {7F87406C-A3C8-4139-A68D-E4C344294A67}.Release|x86.Build.0 = Release|Win32 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Debug|Any CPU.ActiveCfg = Debug|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Debug|x64.ActiveCfg = Debug|x64 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Debug|x64.Build.0 = Debug|x64 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Debug|x86.ActiveCfg = Debug|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Debug|x86.Build.0 = Debug|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Release|Any CPU.ActiveCfg = Release|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Release|x64.ActiveCfg = Release|x64 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Release|x64.Build.0 = Release|x64 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Release|x86.ActiveCfg = Release|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Release|x86.Build.0 = Release|x86 {CAC1267B-8778-4257-AAC6-CAF481723B01}.Debug|Any CPU.ActiveCfg = Debug|Win32 {CAC1267B-8778-4257-AAC6-CAF481723B01}.Debug|x64.ActiveCfg = Debug|x64 {CAC1267B-8778-4257-AAC6-CAF481723B01}.Debug|x64.Build.0 = Debug|x64 @@ -424,7 +398,6 @@ Global {13FD8F12-FFBE-4D01-B4AC-444F2994B04F} = {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} {064D860B-4D7C-4B1D-918F-E020F1B99E2A} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} = {EF30B533-D715-421A-92B7-92FEF460AC9C} - {FC2A97F8-A749-4C04-97D1-97500066A820} = {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} {1EAC8125-1765-4E2D-8CBE-56DC98A1C8C1} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {06CA2C2B-83B0-4D83-905A-E0C74790009E} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} {EC82302F-D2F0-4727-99D1-EABC0DD9DC3B} = {06CA2C2B-83B0-4D83-905A-E0C74790009E} @@ -434,7 +407,6 @@ Global {48F46909-E76A-4788-BCE1-E543C0E140FE} = {622D35C9-627B-466E-8D15-752968CC79AF} {D57EA297-6DC2-4BC0-8C91-334863327863} = {06CA2C2B-83B0-4D83-905A-E0C74790009E} {7F87406C-A3C8-4139-A68D-E4C344294A67} = {06CA2C2B-83B0-4D83-905A-E0C74790009E} - {340C59FC-C682-4CBA-81F8-791821EC8EDE} = {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} {CAC1267B-8778-4257-AAC6-CAF481723B01} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {1533E271-F61B-441B-8B74-59FB61DF0552} = {06CA2C2B-83B0-4D83-905A-E0C74790009E} {D182103F-8405-4647-B158-C36F598657EF} = {EF30B533-D715-421A-92B7-92FEF460AC9C} diff --git a/IISIntegration.sln b/IISIntegration.sln index b47fed50fa..34a5050f7e 100644 --- a/IISIntegration.sln +++ b/IISIntegration.sln @@ -77,8 +77,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestTasks", "test\TestTasks EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebSites", "WebSites", "{744ACDC6-F6A0-4FF9-9421-F25C5F2DC520}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OverriddenServerWebSite", "test\WebSites\OverriddenServerWebSite\OverriddenServerWebSite.csproj", "{FC2A97F8-A749-4C04-97D1-97500066A820}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CommonLibTests", "test\CommonLibTests\CommonLibTests.vcxproj", "{1EAC8125-1765-4E2D-8CBE-56DC98A1C8C1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AspNetCoreModuleV1", "AspNetCoreModuleV1", "{16E521CE-77F1-4B1C-A183-520A41C4F372}" @@ -111,8 +109,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InProcessRequestHandler", " EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OutOfProcessRequestHandler", "src\AspNetCoreModuleV2\OutOfProcessRequestHandler\OutOfProcessRequestHandler.vcxproj", "{7F87406C-A3C8-4139-A68D-E4C344294A67}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StartupExceptionWebSite", "test\WebSites\StartupExceptionWebSite\StartupExceptionWebSite.csproj", "{340C59FC-C682-4CBA-81F8-791821EC8EDE}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "test\gtest\gtest.vcxproj", "{CAC1267B-8778-4257-AAC6-CAF481723B01}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RequestHandlerLib", "src\AspNetCoreModuleV2\RequestHandlerLib\RequestHandlerLib.vcxproj", "{1533E271-F61B-441B-8B74-59FB61DF0552}" @@ -321,26 +317,6 @@ Global {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x64.Build.0 = Release|Any CPU {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x86.ActiveCfg = Release|Any CPU {064D860B-4D7C-4B1D-918F-E020F1B99E2A}.Release|x86.Build.0 = Release|Any CPU - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|Any CPU.ActiveCfg = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|Any CPU.Build.0 = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x64.ActiveCfg = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x64.Build.0 = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x86.ActiveCfg = Debug|x86 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Debug|x86.Build.0 = Debug|x86 - {FC2A97F8-A749-4C04-97D1-97500066A820}.NativeDebug|Any CPU.ActiveCfg = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.NativeDebug|Any CPU.Build.0 = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.NativeDebug|x64.ActiveCfg = Debug|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.NativeDebug|x86.ActiveCfg = Debug|x86 - {FC2A97F8-A749-4C04-97D1-97500066A820}.NativeRelease|Any CPU.ActiveCfg = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.NativeRelease|Any CPU.Build.0 = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.NativeRelease|x64.ActiveCfg = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.NativeRelease|x86.ActiveCfg = Release|x86 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|Any CPU.ActiveCfg = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|Any CPU.Build.0 = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x64.ActiveCfg = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x64.Build.0 = Release|x64 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x86.ActiveCfg = Release|x86 - {FC2A97F8-A749-4C04-97D1-97500066A820}.Release|x86.Build.0 = Release|x86 {1EAC8125-1765-4E2D-8CBE-56DC98A1C8C1}.Debug|Any CPU.ActiveCfg = Debug|Win32 {1EAC8125-1765-4E2D-8CBE-56DC98A1C8C1}.Debug|x64.ActiveCfg = Debug|x64 {1EAC8125-1765-4E2D-8CBE-56DC98A1C8C1}.Debug|x64.Build.0 = Debug|x64 @@ -541,22 +517,6 @@ Global {7F87406C-A3C8-4139-A68D-E4C344294A67}.Release|x64.Build.0 = Release|x64 {7F87406C-A3C8-4139-A68D-E4C344294A67}.Release|x86.ActiveCfg = Release|Win32 {7F87406C-A3C8-4139-A68D-E4C344294A67}.Release|x86.Build.0 = Release|Win32 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Debug|Any CPU.ActiveCfg = Debug|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Debug|x64.ActiveCfg = Debug|x64 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Debug|x64.Build.0 = Debug|x64 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Debug|x86.ActiveCfg = Debug|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Debug|x86.Build.0 = Debug|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.NativeDebug|Any CPU.ActiveCfg = Debug|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.NativeDebug|x64.ActiveCfg = Debug|x64 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.NativeDebug|x86.ActiveCfg = Debug|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.NativeRelease|Any CPU.ActiveCfg = Release|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.NativeRelease|x64.ActiveCfg = Release|x64 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.NativeRelease|x86.ActiveCfg = Release|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Release|Any CPU.ActiveCfg = Release|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Release|x64.ActiveCfg = Release|x64 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Release|x64.Build.0 = Release|x64 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Release|x86.ActiveCfg = Release|x86 - {340C59FC-C682-4CBA-81F8-791821EC8EDE}.Release|x86.Build.0 = Release|x86 {CAC1267B-8778-4257-AAC6-CAF481723B01}.Debug|Any CPU.ActiveCfg = Debug|Win32 {CAC1267B-8778-4257-AAC6-CAF481723B01}.Debug|x64.ActiveCfg = Debug|x64 {CAC1267B-8778-4257-AAC6-CAF481723B01}.Debug|x64.Build.0 = Debug|x64 @@ -692,7 +652,6 @@ Global {13FD8F12-FFBE-4D01-B4AC-444F2994B04F} = {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} {064D860B-4D7C-4B1D-918F-E020F1B99E2A} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} = {EF30B533-D715-421A-92B7-92FEF460AC9C} - {FC2A97F8-A749-4C04-97D1-97500066A820} = {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} {1EAC8125-1765-4E2D-8CBE-56DC98A1C8C1} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {16E521CE-77F1-4B1C-A183-520A41C4F372} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} {06CA2C2B-83B0-4D83-905A-E0C74790009E} = {04B1EDB6-E967-4D25-89B9-E6F8304038CD} @@ -705,7 +664,6 @@ Global {48F46909-E76A-4788-BCE1-E543C0E140FE} = {622D35C9-627B-466E-8D15-752968CC79AF} {D57EA297-6DC2-4BC0-8C91-334863327863} = {06CA2C2B-83B0-4D83-905A-E0C74790009E} {7F87406C-A3C8-4139-A68D-E4C344294A67} = {06CA2C2B-83B0-4D83-905A-E0C74790009E} - {340C59FC-C682-4CBA-81F8-791821EC8EDE} = {744ACDC6-F6A0-4FF9-9421-F25C5F2DC520} {CAC1267B-8778-4257-AAC6-CAF481723B01} = {EF30B533-D715-421A-92B7-92FEF460AC9C} {1533E271-F61B-441B-8B74-59FB61DF0552} = {06CA2C2B-83B0-4D83-905A-E0C74790009E} {1F0C8D9B-F47B-41F3-9FC9-6954B6DC7712} = {EF30B533-D715-421A-92B7-92FEF460AC9C} diff --git a/benchmarks/IIS.Performance/IIS.Performance.csproj b/benchmarks/IIS.Performance/IIS.Performance.csproj index b7aa1dc3ac..6373cfdfa7 100644 --- a/benchmarks/IIS.Performance/IIS.Performance.csproj +++ b/benchmarks/IIS.Performance/IIS.Performance.csproj @@ -26,7 +26,13 @@ - + + False + + + False + + False diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs index b1394bccb5..5a8519926c 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs @@ -115,6 +115,10 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS protected override IEnumerable> GetWebConfigActions() { + yield return WebConfigHelpers.AddOrModifyAspNetCoreSection( + key: "hostingModel", + value: DeploymentParameters.HostingModel.ToString()); + if (DeploymentParameters.ApplicationType == ApplicationType.Portable) { yield return WebConfigHelpers.AddOrModifyAspNetCoreSection( @@ -126,15 +130,12 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS key: "modules", value: DeploymentParameters.AncmVersion.ToString()); - foreach (var action in base.GetWebConfigActions()) { yield return action; } } - - private void GetLogsFromFile() { try diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISExpressDeployer.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISExpressDeployer.cs index 56d4afb46b..8139a0f6b9 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISExpressDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISExpressDeployer.cs @@ -342,7 +342,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS // For published apps, prefer the content in the web.config, but update it. yield return WebConfigHelpers.AddOrModifyAspNetCoreSection( key: "hostingModel", - value: DeploymentParameters.HostingModel == HostingModel.InProcess ? "inprocess" : ""); + value: DeploymentParameters.HostingModel.ToString()); yield return WebConfigHelpers.AddOrModifyHandlerSection( key: "modules", diff --git a/test/Common.FunctionalTests/Inprocess/LogPipeTests.cs b/test/Common.FunctionalTests/Inprocess/LogPipeTests.cs new file mode 100644 index 0000000000..ed48204385 --- /dev/null +++ b/test/Common.FunctionalTests/Inprocess/LogPipeTests.cs @@ -0,0 +1,85 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using System.Net; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities; +using Microsoft.AspNetCore.Server.IntegrationTesting; +using Microsoft.AspNetCore.Server.IntegrationTesting.IIS; +using Microsoft.AspNetCore.Testing.xunit; +using Xunit; + +namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests +{ + [Collection(PublishedSitesCollection.Name)] + public class LogPipeTests : IISFunctionalTestBase + { + private readonly PublishedSitesFixture _fixture; + + public LogPipeTests(PublishedSitesFixture fixture) + { + _fixture = fixture; + } + + [ConditionalTheory] + [InlineData("ConsoleErrorWrite")] + [InlineData("ConsoleWrite")] + public async Task CheckStdoutLoggingToPipe_DoesNotCrashProcess(string path) + { + var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); + var deploymentResult = await DeployAsync(deploymentParameters); + + await Helpers.AssertStarts(deploymentResult, path); + + StopServer(); + + if (deploymentParameters.ServerType == ServerType.IISExpress) + { + Assert.Contains(TestSink.Writes, context => context.Message.Contains("TEST MESSAGE")); + } + } + + [ConditionalTheory] + [InlineData("ConsoleErrorWrite")] + [InlineData("ConsoleWrite")] + public async Task CheckStdoutLoggingToPipeWithFirstWrite(string path) + { + var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); + + var firstWriteString = path + path; + + deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_INITIAL_WRITE"] = firstWriteString; + + var deploymentResult = await DeployAsync(deploymentParameters); + + await Helpers.AssertStarts(deploymentResult, path); + + StopServer(); + + if (deploymentParameters.ServerType == ServerType.IISExpress) + { + // We can't read stdout logs from IIS as they aren't redirected. + Assert.Contains(TestSink.Writes, context => context.Message.Contains(firstWriteString)); + Assert.Contains(TestSink.Writes, context => context.Message.Contains("TEST MESSAGE")); + } + } + + [ConditionalFact] + public async Task CheckUnicodePipe() + { + var path = "CheckConsoleFunctions"; + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); + deploymentParameters.TransformArguments((a, _) => $"{a} {path}"); + + var deploymentResult = await DeployAsync(deploymentParameters); + + var response = await deploymentResult.HttpClient.GetAsync(path); + + Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); + + StopServer(); + EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", "(.*)彡⾔(.*)")); + } + } +} diff --git a/test/Common.FunctionalTests/Inprocess/StartupExceptionTests.cs b/test/Common.FunctionalTests/Inprocess/StartupExceptionTests.cs index ef5b6a3a2c..0c69f10c03 100644 --- a/test/Common.FunctionalTests/Inprocess/StartupExceptionTests.cs +++ b/test/Common.FunctionalTests/Inprocess/StartupExceptionTests.cs @@ -22,11 +22,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests } [ConditionalTheory] - [InlineData("CheckLogFile")] - [InlineData("CheckErrLogFile")] + [InlineData("ConsoleWrite")] + [InlineData("ConsoleErrorWrite")] public async Task CheckStdoutWithRandomNumber(string mode) { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); var randomNumberString = new Random(Guid.NewGuid().GetHashCode()).Next(10000000).ToString(); deploymentParameters.TransformArguments((a, _) => $"{a} {mode} {randomNumberString}"); @@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [InlineData("CheckOversizedStdOutWrites")] public async Task CheckStdoutWithLargeWrites(string mode) { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); deploymentParameters.TransformArguments((a, _) => $"{a} {mode}"); await AssertFailsToStart(deploymentParameters); @@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [ConditionalFact] public async Task CheckValidConsoleFunctions() { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); deploymentParameters.TransformArguments((a, _) => $"{a} CheckConsoleFunctions"); await AssertFailsToStart(deploymentParameters); @@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests Assert.Contains(TestSink.Writes, context => context.Message.Contains("Is Console redirection: True")); } - private async Task AssertFailsToStart(IntegrationTesting.IIS.IISDeploymentParameters deploymentParameters) + private async Task AssertFailsToStart(IISDeploymentParameters deploymentParameters) { var deploymentResult = await DeployAsync(deploymentParameters); @@ -76,17 +76,17 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [ConditionalFact] public async Task Gets500_30_ErrorPage() { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); + deploymentParameters.TransformArguments((a, _) => $"{a} EarlyReturn"); var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.HttpClient.GetAsync("/"); + var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld"); Assert.False(response.IsSuccessStatusCode); Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); var responseText = await response.Content.ReadAsStringAsync(); Assert.Contains("500.30 - ANCM In-Process Start Failure", responseText); } - } } diff --git a/test/Common.FunctionalTests/Inprocess/LoggingTests.cs b/test/Common.FunctionalTests/LogFileTests.cs similarity index 61% rename from test/Common.FunctionalTests/Inprocess/LoggingTests.cs rename to test/Common.FunctionalTests/LogFileTests.cs index d26088b018..be8d8e700c 100644 --- a/test/Common.FunctionalTests/Inprocess/LoggingTests.cs +++ b/test/Common.FunctionalTests/LogFileTests.cs @@ -3,7 +3,6 @@ using System; using System.IO; -using System.Linq; using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities; @@ -35,31 +34,49 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests } } - [ConditionalTheory] - [InlineData("CheckErrLogFile")] - [InlineData("CheckLogFile")] - public async Task CheckStdoutLoggingToFile(string path) - { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); + public static TestMatrix TestVariants + => TestMatrix.ForServers(DeployerSelector.ServerType) + .WithTfms(Tfm.NetCoreApp22) + .WithAllApplicationTypes() + .WithAncmVersions(AncmVersion.AspNetCoreModuleV2) + .WithAllHostingModels(); + [ConditionalTheory] + [MemberData(nameof(TestVariants))] + public async Task CheckStdoutLoggingToFile(TestVariant variant) + { + await CheckStdoutToFile(variant, "ConsoleWrite"); + } + + [ConditionalTheory] + [MemberData(nameof(TestVariants))] + public async Task CheckStdoutErrLoggingToFile(TestVariant variant) + { + await CheckStdoutToFile(variant, "ConsoleErrorWrite"); + } + + private async Task CheckStdoutToFile(TestVariant variant, string path) + { + var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true); deploymentParameters.EnableLogging(_logFolderPath); var deploymentResult = await DeployAsync(deploymentParameters); - - await Helpers.AssertStarts(deploymentResult, path); + await Helpers.AssertStarts(deploymentResult, path); + StopServer(); var contents = File.ReadAllText(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath)); - Assert.NotNull(contents); Assert.Contains("TEST MESSAGE", contents); } - [ConditionalFact] - public async Task InvalidFilePathForLogs_ServerStillRuns() + // Move to separate file + [ConditionalTheory] + [MemberData(nameof(TestVariants))] + public async Task InvalidFilePathForLogs_ServerStillRuns(TestVariant variant) { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true); deploymentParameters.WebConfigActionList.Add( WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogEnabled", "true")); @@ -71,29 +88,18 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests await Helpers.AssertStarts(deploymentResult, "HelloWorld"); StopServer(); - 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"); + 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"); + } } - [ConditionalFact] - public async Task OnlyOneFileCreatedWithProcessStartTime() + [ConditionalTheory] + [MemberData(nameof(TestVariants))] + public async Task StartupMessagesAreLoggedIntoDebugLogFile(TestVariant variant) { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); - - deploymentParameters.EnableLogging(_logFolderPath); - - var deploymentResult = await DeployAsync(deploymentParameters); - await Helpers.AssertStarts(deploymentResult, "CheckLogFile"); - - StopServer(); - - Assert.Single(Directory.GetFiles(_logFolderPath), Helpers.GetExpectedLogName(deploymentResult, _logFolderPath)); - } - - [ConditionalFact] - public async Task StartupMessagesAreLoggedIntoDebugLogFile() - { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true); deploymentParameters.HandlerSettings["debugLevel"] = "file"; deploymentParameters.HandlerSettings["debugFile"] = "debug.txt"; @@ -104,10 +110,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests AssertLogs(Path.Combine(deploymentResult.ContentRoot, "debug.txt")); } - [ConditionalFact] - public async Task StartupMessagesAreLoggedIntoDefaultDebugLogFile() + [ConditionalTheory] + [MemberData(nameof(TestVariants))] + public async Task StartupMessagesAreLoggedIntoDefaultDebugLogFile(TestVariant variant) { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true); deploymentParameters.HandlerSettings["debugLevel"] = "file"; var deploymentResult = await DeployAsync(deploymentParameters); @@ -117,11 +124,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests AssertLogs(Path.Combine(deploymentResult.ContentRoot, "aspnetcore-debug.log")); } - [ConditionalFact] + [ConditionalTheory] [RequiresIIS(IISCapability.PoolEnvironmentVariables)] - public async Task StartupMessagesAreLoggedIntoDefaultDebugLogFileWhenEnabledWithEnvVar() + [MemberData(nameof(TestVariants))] + public async Task StartupMessagesAreLoggedIntoDefaultDebugLogFileWhenEnabledWithEnvVar(TestVariant variant) { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true); deploymentParameters.EnvironmentVariables["ASPNETCORE_MODULE_DEBUG"] = "file"; // Add empty debugFile handler setting to prevent IIS deployer from overriding debug settings deploymentParameters.HandlerSettings["debugFile"] = ""; @@ -133,58 +141,16 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests } [ConditionalTheory] - [InlineData("CheckErrLogFile")] - [InlineData("CheckLogFile")] - public async Task CheckStdoutLoggingToPipe_DoesNotCrashProcess(string path) - { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); - var deploymentResult = await DeployAsync(deploymentParameters); - - await Helpers.AssertStarts(deploymentResult, path); - - StopServer(); - - if (deploymentParameters.ServerType == ServerType.IISExpress) - { - Assert.Contains(TestSink.Writes, context => context.Message.Contains("TEST MESSAGE")); - } - } - - [ConditionalTheory] - [InlineData("CheckErrLogFile")] - [InlineData("CheckLogFile")] - public async Task CheckStdoutLoggingToPipeWithFirstWrite(string path) - { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); - - var firstWriteString = path + path; - - deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_INITIAL_WRITE"] = firstWriteString; - - var deploymentResult = await DeployAsync(deploymentParameters); - - await Helpers.AssertStarts(deploymentResult, path); - - StopServer(); - - if (deploymentParameters.ServerType == ServerType.IISExpress) - { - // We can't read stdout logs from IIS as they aren't redirected. - Assert.Contains(TestSink.Writes, context => context.Message.Contains(firstWriteString)); - Assert.Contains(TestSink.Writes, context => context.Message.Contains("TEST MESSAGE")); - } - } - - [ConditionalFact] [RequiresIIS(IISCapability.PoolEnvironmentVariables)] - public async Task StartupMessagesLogFileSwitchedWhenLogFilePresentInWebConfig() + [MemberData(nameof(TestVariants))] + public async Task StartupMessagesLogFileSwitchedWhenLogFilePresentInWebConfig(TestVariant variant) { var firstTempFile = Path.GetTempFileName(); var secondTempFile = Path.GetTempFileName(); try { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true); deploymentParameters.EnvironmentVariables["ASPNETCORE_MODULE_DEBUG_FILE"] = firstTempFile; deploymentParameters.AddDebugLogToWebConfig(secondTempFile); @@ -205,68 +171,65 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests } } - [ConditionalFact] - public async Task DebugLogsAreWrittenToEventLog() + [ConditionalTheory] + [MemberData(nameof(TestVariants))] + + public async Task DebugLogsAreWrittenToEventLog(TestVariant variant) { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true); deploymentParameters.HandlerSettings["debugLevel"] = "file,eventlog"; var deploymentResult = await StartAsync(deploymentParameters); StopServer(); EventLogHelpers.VerifyEventLogEvent(deploymentResult, @"\[aspnetcorev2.dll\] Initializing logs for .*?Description: IIS ASP.NET Core Module V2"); } - [ConditionalFact] - public async Task OutOfProcessReadsLogConfiguration() - { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel:HostingModel.OutOfProcess, publish: true); - deploymentParameters.HandlerSettings["debugLevel"] = "file,trace"; - deploymentParameters.HandlerSettings["debugFile"] = ""; - var deploymentResult = await StartAsync(deploymentParameters); - - var logContents = ReadLogs(Path.Combine(deploymentResult.ContentRoot, "aspnetcore-debug.log")); - Assert.Contains("FORWARDING_HANDLER::", logContents); - } - - [ConditionalFact] - public async Task CheckUnicodePipe() + [ConditionalTheory] + [MemberData(nameof(TestVariants))] + public async Task CheckUTF8File(TestVariant variant) { var path = "CheckConsoleFunctions"; - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); - deploymentParameters.TransformArguments((a, _) => $"{a} {path}"); + + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, variant.HostingModel, publish: true); + deploymentParameters.TransformArguments((a, _) => $"{a} {path}"); // For standalone this will need to remove space + + var logFolderPath = _logFolderPath + "\\彡⾔"; + deploymentParameters.EnableLogging(logFolderPath); var deploymentResult = await DeployAsync(deploymentParameters); var response = await deploymentResult.HttpClient.GetAsync(path); - Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); + Assert.False(response.IsSuccessStatusCode); StopServer(); - EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", "(.*)彡⾔(.*)")); + + var contents = File.ReadAllText(Helpers.GetExpectedLogName(deploymentResult, logFolderPath)); + Assert.Contains("彡⾔", contents); + + if (variant.HostingModel == HostingModel.InProcess) + { + EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", "(.*)彡⾔(.*)")); + } + else + { + EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.OutOfProcessFailedToStart(deploymentResult)); + } } - [ConditionalFact] - public async Task CheckUTF8File() + [ConditionalTheory] + [MemberData(nameof(TestVariants))] + public async Task OnlyOneFileCreatedWithProcessStartTime(TestVariant variant) { - var path = "CheckConsoleFunctions"; - - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); - deploymentParameters.TransformArguments((a, _) => $"{a} {path}"); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true); deploymentParameters.EnableLogging(_logFolderPath); var deploymentResult = await DeployAsync(deploymentParameters); - - var response = await deploymentResult.HttpClient.GetAsync(path); - - Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); + await Helpers.AssertStarts(deploymentResult, "ConsoleWrite"); StopServer(); - var contents = File.ReadAllText(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath)); - - Assert.Contains("彡⾔", contents); - - EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.InProcessThreadExitStdOut(deploymentResult, "12", "(.*)彡⾔(.*)")); + Assert.Single(Directory.GetFiles(_logFolderPath), Helpers.GetExpectedLogName(deploymentResult, _logFolderPath)); } private static string ReadLogs(string logPath) @@ -282,7 +245,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests { var logContents = ReadLogs(logPath); Assert.Contains("[aspnetcorev2.dll]", logContents); - Assert.Contains("[aspnetcorev2_inprocess.dll]", logContents); + Assert.True(logContents.Contains("[aspnetcorev2_inprocess.dll]") || logContents.Contains("[aspnetcorev2_outofprocess.dll]")); Assert.Contains("Description: IIS ASP.NET Core Module V2. Commit:", logContents); Assert.Contains("Description: IIS ASP.NET Core Module V2 Request Handler. Commit:", logContents); } diff --git a/test/Common.FunctionalTests/PublishedSitesFixture.cs b/test/Common.FunctionalTests/PublishedSitesFixture.cs index 64e39e68df..1ebfdab38e 100644 --- a/test/Common.FunctionalTests/PublishedSitesFixture.cs +++ b/test/Common.FunctionalTests/PublishedSitesFixture.cs @@ -21,15 +21,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests { public CachingApplicationPublisher InProcessTestSite { get; } = new CachingApplicationPublisher(Helpers.GetInProcessTestSitesPath()); public CachingApplicationPublisher OutOfProcessTestSite { get; } = new CachingApplicationPublisher(Helpers.GetOutOfProcessTestSitesPath()); - public CachingApplicationPublisher StartupExceptionWebsite { get; } = new CachingApplicationPublisher(Helpers.GetTestWebSitePath("StartupExceptionWebsite")); - public CachingApplicationPublisher OverriddenServerWebSite { get; } = new CachingApplicationPublisher(Helpers.GetTestWebSitePath("OverriddenServerWebSite")); public void Dispose() { InProcessTestSite.Dispose(); OutOfProcessTestSite.Dispose(); - StartupExceptionWebsite.Dispose(); - OverriddenServerWebSite.Dispose(); } public IISDeploymentParameters GetBaseDeploymentParameters(HostingModel hostingModel = HostingModel.InProcess, bool publish = false) diff --git a/test/Common.FunctionalTests/Utilities/EventLogHelpers.cs b/test/Common.FunctionalTests/Utilities/EventLogHelpers.cs index e385f281d8..aa3453fe9b 100644 --- a/test/Common.FunctionalTests/Utilities/EventLogHelpers.cs +++ b/test/Common.FunctionalTests/Utilities/EventLogHelpers.cs @@ -136,6 +136,13 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests return $"Configuration load error. {reason}"; } + public static string OutOfProcessFailedToStart(IISDeploymentResult deploymentResult) + { + return $"Application '/LM/W3SVC/1/ROOT' with physical root '{EscapedContentRoot(deploymentResult)}' failed to start process with " + + $"commandline '(.*)' with multiple retries. " + + $"The last try of listening port is '(.*)'. See previous warnings for details."; + } + private static string EscapedContentRoot(IISDeploymentResult deploymentResult) { var contentRoot = deploymentResult.ContentRoot; diff --git a/test/Common.FunctionalTests/Utilities/Helpers.cs b/test/Common.FunctionalTests/Utilities/Helpers.cs index 27155effcc..ccaecbceff 100644 --- a/test/Common.FunctionalTests/Utilities/Helpers.cs +++ b/test/Common.FunctionalTests/Utilities/Helpers.cs @@ -146,10 +146,18 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests public static string GetExpectedLogName(IISDeploymentResult deploymentResult, string logFolderPath) { var startTime = deploymentResult.HostProcess.StartTime.ToUniversalTime(); - return Path.Combine(logFolderPath, $"std_{startTime.Year}{startTime.Month:D2}" + + + if (deploymentResult.DeploymentParameters.HostingModel == HostingModel.InProcess) + { + return Path.Combine(logFolderPath, $"std_{startTime.Year}{startTime.Month:D2}" + $"{startTime.Day:D2}{startTime.Hour:D2}" + $"{startTime.Minute:D2}{startTime.Second:D2}_" + $"{deploymentResult.HostProcess.Id}.log"); + } + else + { + return Directory.GetFiles(logFolderPath).Single(); + } } } } diff --git a/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj b/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj index 723433b707..0114f027ca 100644 --- a/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj +++ b/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj @@ -13,7 +13,13 @@ - + + False + + + False + + False diff --git a/test/IIS.FunctionalTests/Inprocess/StdOutRedirectionTests.cs b/test/IIS.FunctionalTests/Inprocess/StdOutRedirectionTests.cs index fea6d3b5fb..1098384c9b 100644 --- a/test/IIS.FunctionalTests/Inprocess/StdOutRedirectionTests.cs +++ b/test/IIS.FunctionalTests/Inprocess/StdOutRedirectionTests.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IIS.FunctionalTests.Utilities; using Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests; -using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting.IIS; using Microsoft.AspNetCore.Testing.xunit; using Newtonsoft.Json; @@ -40,13 +39,13 @@ namespace IIS.FunctionalTests.Inprocess [SkipIfDebug] public async Task FrameworkNotFoundExceptionLogged_Pipe() { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); var deploymentResult = await DeployAsync(deploymentParameters); InvalidateRuntimeConfig(deploymentResult); - var response = await deploymentResult.HttpClient.GetAsync("/"); + var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld"); Assert.False(response.IsSuccessStatusCode); StopServer(); @@ -60,7 +59,7 @@ namespace IIS.FunctionalTests.Inprocess public async Task FrameworkNotFoundExceptionLogged_File() { var deploymentParameters = - _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); deploymentParameters.EnableLogging(_logFolderPath); @@ -68,7 +67,7 @@ namespace IIS.FunctionalTests.Inprocess InvalidateRuntimeConfig(deploymentResult); - var response = await deploymentResult.HttpClient.GetAsync("/"); + var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld"); Assert.False(response.IsSuccessStatusCode); StopServer(); @@ -85,14 +84,16 @@ namespace IIS.FunctionalTests.Inprocess public async Task EnableCoreHostTraceLogging_TwoLogFilesCreated() { var deploymentParameters = - _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); + deploymentParameters.TransformArguments((a, _) => $"{a} CheckLargeStdOutWrites"); + deploymentParameters.EnvironmentVariables["COREHOST_TRACE"] = "1"; deploymentParameters.EnableLogging(_logFolderPath); var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.HttpClient.GetAsync("/"); + var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld"); Assert.False(response.IsSuccessStatusCode); StopServer(); @@ -112,13 +113,13 @@ namespace IIS.FunctionalTests.Inprocess [InlineData("CheckOversizedStdOutWrites")] public async Task EnableCoreHostTraceLogging_PipeCaptureNativeLogs(string path) { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); deploymentParameters.EnvironmentVariables["COREHOST_TRACE"] = "1"; - deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path; + deploymentParameters.TransformArguments((a, _) => $"{a} {path}"); var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.HttpClient.GetAsync("/"); + var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld"); Assert.False(response.IsSuccessStatusCode); @@ -137,15 +138,15 @@ namespace IIS.FunctionalTests.Inprocess public async Task EnableCoreHostTraceLogging_FileCaptureNativeLogs(string path) { var deploymentParameters = - _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); deploymentParameters.EnvironmentVariables["COREHOST_TRACE"] = "1"; - deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_STARTUP_VALUE"] = path; + deploymentParameters.TransformArguments((a, _) => $"{a} {path}"); deploymentParameters.EnableLogging(_logFolderPath); var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.HttpClient.GetAsync("/"); + var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld"); Assert.False(response.IsSuccessStatusCode); StopServer(); @@ -159,7 +160,7 @@ namespace IIS.FunctionalTests.Inprocess private static void InvalidateRuntimeConfig(IISDeploymentResult deploymentResult) { - var path = Path.Combine(deploymentResult.ContentRoot, "StartupExceptionWebSite.runtimeconfig.json"); + var path = Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.runtimeconfig.json"); dynamic depsFileContent = JsonConvert.DeserializeObject(File.ReadAllText(path)); depsFileContent["runtimeOptions"]["framework"]["version"] = "2.9.9"; var output = JsonConvert.SerializeObject(depsFileContent); diff --git a/test/IISExpress.FunctionalTests/InProcess/StartupTests.cs b/test/IISExpress.FunctionalTests/InProcess/StartupTests.cs index 0dc4e1acd6..9f115e324f 100644 --- a/test/IISExpress.FunctionalTests/InProcess/StartupTests.cs +++ b/test/IISExpress.FunctionalTests/InProcess/StartupTests.cs @@ -133,9 +133,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests } [ConditionalFact] - public async Task DetectsOveriddenServer() + public async Task DetectsOverriddenServer() { - var deploymentResult = await DeployAsync(_fixture.GetBaseDeploymentParameters(_fixture.OverriddenServerWebSite, publish: true)); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); + deploymentParameters.TransformArguments((a, _) => $"{a} OverriddenServer"); + + var deploymentResult = await DeployAsync(deploymentParameters); var response = await deploymentResult.HttpClient.GetAsync("/"); Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); @@ -149,7 +152,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [ConditionalFact] public async Task LogsStartupExceptionExitError() { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); deploymentParameters.TransformArguments((a, _) => $"{a} Throw"); var deploymentResult = await DeployAsync(deploymentParameters); @@ -167,9 +170,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [ConditionalFact] public async Task LogsUnexpectedThreadExitError() { - var deploymentResult = await DeployAsync(_fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true)); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); + deploymentParameters.TransformArguments((a, _) => $"{a} EarlyReturn"); + var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.HttpClient.GetAsync("/"); + var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld"); Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); StopServer(); @@ -182,7 +187,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [ConditionalFact] public async Task StartupTimeoutIsApplied() { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); deploymentParameters.TransformArguments((a, _) => $"{a} Hang"); deploymentParameters.WebConfigActionList.Add( WebConfigHelpers.AddOrModifyAspNetCoreSection("startupTimeLimit", "1")); @@ -202,14 +207,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests [ConditionalFact] public async Task ShutdownTimeoutIsApplied() { - var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.StartupExceptionWebsite, publish: true); + var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true); deploymentParameters.TransformArguments((a, _) => $"{a} HangOnStop"); deploymentParameters.WebConfigActionList.Add( WebConfigHelpers.AddOrModifyAspNetCoreSection("shutdownTimeLimit", "1")); var deploymentResult = await DeployAsync(deploymentParameters); - Assert.Equal("OK", await deploymentResult.HttpClient.GetStringAsync("/")); + Assert.Equal("Hello World", await deploymentResult.HttpClient.GetStringAsync("/HelloWorld")); StopServer(); diff --git a/test/WebSites/OverriddenServerWebSite/Program.cs b/test/WebSites/InProcessWebSite/DummyServer.cs similarity index 53% rename from test/WebSites/OverriddenServerWebSite/Program.cs rename to test/WebSites/InProcessWebSite/DummyServer.cs index 2b68c93af4..d122f05776 100644 --- a/test/WebSites/OverriddenServerWebSite/Program.cs +++ b/test/WebSites/InProcessWebSite/DummyServer.cs @@ -4,30 +4,12 @@ using System; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; -using Microsoft.Extensions.DependencyInjection; -namespace IISTestSite +namespace TestSite { - public static class Program - { - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseIIS() - .ConfigureServices(services => services.AddSingleton()) - .Configure(builder => builder.Run(async context => { await context.Response.WriteAsync("I shouldn't work"); })) - .Build(); - - host.Run(); - } - } - - public class DummyServer: IServer + public class DummyServer : IServer { public void Dispose() { diff --git a/test/WebSites/InProcessWebSite/Program.cs b/test/WebSites/InProcessWebSite/Program.cs index ec9ed04f87..f7abe535ae 100644 --- a/test/WebSites/InProcessWebSite/Program.cs +++ b/test/WebSites/InProcessWebSite/Program.cs @@ -2,33 +2,108 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Linq; +using System.Text; +using System.Threading; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Hosting.Server; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace IISTestSite +namespace TestSite { public static class Program { - public static void Main(string[] args) + public static int Main(string[] args) { - var envVariable = Environment.GetEnvironmentVariable("ASPNETCORE_INPROCESS_INITIAL_WRITE"); - if (!string.IsNullOrEmpty(envVariable)) + var mode = args.FirstOrDefault(); + switch (mode) { - Console.WriteLine(envVariable); - Console.Error.WriteLine(envVariable); + // Semicolons are appended to env variables; removing them. + case "CheckLargeStdOutWrites": + Console.WriteLine(new string('a', 30000)); + break; + case "CheckLargeStdErrWrites": + Console.Error.WriteLine(new string('a', 30000)); + Console.Error.Flush(); + break; + case "ConsoleWrite": + Console.WriteLine($"Random number: {args[1]}"); + break; + case "ConsoleErrorWrite": + Console.Error.WriteLine($"Random number: {args[1]}"); + Console.Error.Flush(); + break; + case "CheckOversizedStdErrWrites": + Console.WriteLine(new string('a', 31000)); + break; + case "CheckOversizedStdOutWrites": + Console.Error.WriteLine(new string('a', 31000)); + Console.Error.Flush(); + break; + case "Hang": + Thread.Sleep(Timeout.Infinite); + break; + case "Throw": + throw new InvalidOperationException("Program.Main exception"); + case "EarlyReturn": + return 12; + case "HangOnStop": + { + var host = new WebHostBuilder() + .UseIIS() + .UseStartup() + .Build(); + host.Run(); + + Thread.Sleep(Timeout.Infinite); + } + break; + case "CheckConsoleFunctions": + // Call a bunch of console functions and make sure none return invalid handle. + Console.OutputEncoding = Encoding.UTF8; + Console.Title = "Test"; + Console.WriteLine($"Is Console redirection: {Console.IsOutputRedirected}"); + Console.BackgroundColor = ConsoleColor.Blue; + Console.WriteLine("彡⾔"); + break; + case "OverriddenServer": + { + var host = new WebHostBuilder() + .UseIIS() + .ConfigureServices(services => services.AddSingleton()) + .Configure(builder => builder.Run(async context => { await context.Response.WriteAsync("I shouldn't work"); })) + .Build(); + host.Run(); + } + break; + default: + { + + var envVariable = Environment.GetEnvironmentVariable("ASPNETCORE_INPROCESS_INITIAL_WRITE"); + if (!string.IsNullOrEmpty(envVariable)) + { + Console.WriteLine(envVariable); + Console.Error.WriteLine(envVariable); + } + + var host = new WebHostBuilder() + .ConfigureLogging((_, factory) => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) + .UseIIS() + .UseStartup() + .Build(); + + host.Run(); + return 0; + } } - - var host = new WebHostBuilder() - .ConfigureLogging((_, factory) => - { - factory.AddConsole(); - factory.AddFilter("Console", level => level >= LogLevel.Information); - }) - .UseIIS() - .UseStartup() - .Build(); - - host.Run(); + return 12; } } } diff --git a/test/WebSites/InProcessWebSite/Startup.WebSockets.cs b/test/WebSites/InProcessWebSite/Startup.WebSockets.cs index e83ae2a72f..d658ebd03f 100644 --- a/test/WebSites/InProcessWebSite/Startup.WebSockets.cs +++ b/test/WebSites/InProcessWebSite/Startup.WebSockets.cs @@ -16,7 +16,7 @@ using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.DependencyInjection; using Xunit; -namespace IISTestSite +namespace TestSite { public partial class Startup { diff --git a/test/WebSites/InProcessWebSite/Startup.cs b/test/WebSites/InProcessWebSite/Startup.cs index 08837417bf..7bd530a9f9 100644 --- a/test/WebSites/InProcessWebSite/Startup.cs +++ b/test/WebSites/InProcessWebSite/Startup.cs @@ -18,7 +18,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Primitives; using Xunit; -namespace IISTestSite +namespace TestSite { public partial class Startup { @@ -27,746 +27,622 @@ namespace IISTestSite TestStartup.Register(app, this); } - private void ServerVariable(IApplicationBuilder app) + private async Task ServerVariable(HttpContext ctx) { - app.Run(async ctx => + var varName = ctx.Request.Query["q"]; + await ctx.Response.WriteAsync($"{varName}: {ctx.GetIISServerVariable(varName) ?? "(null)"}"); + } + + private async Task AuthenticationAnonymous(HttpContext ctx) + { + await ctx.Response.WriteAsync("Anonymous?" + !ctx.User.Identity.IsAuthenticated); + } + + private async Task AuthenticationRestricted(HttpContext ctx) + { + if (ctx.User.Identity.IsAuthenticated) { - var varName = ctx.Request.Query["q"]; - await ctx.Response.WriteAsync($"{varName}: {ctx.GetIISServerVariable(varName) ?? "(null)"}"); - }); - } - - public void AuthenticationAnonymous(IApplicationBuilder app) - { - app.Run(async ctx => + await ctx.Response.WriteAsync(ctx.User.Identity.AuthenticationType); + } + else { - await ctx.Response.WriteAsync("Anonymous?" + !ctx.User.Identity.IsAuthenticated); - }); - } - - private async Task HostingEnvironment(HttpContext context) - { - var hostingEnv = context.RequestServices.GetService(); - - await context.Response.WriteAsync("ContentRootPath "+hostingEnv.ContentRootPath + Environment.NewLine); - await context.Response.WriteAsync("WebRootPath "+hostingEnv.WebRootPath + Environment.NewLine); - await context.Response.WriteAsync("CurrentDirectory "+Environment.CurrentDirectory); - } - - private void AuthenticationRestricted(IApplicationBuilder app) - { - app.Run(async ctx => - { - if (ctx.User.Identity.IsAuthenticated) - { - await ctx.Response.WriteAsync(ctx.User.Identity.AuthenticationType); - } - else - { - await ctx.ChallengeAsync(IISServerDefaults.AuthenticationScheme); - } - }); - } - - public void AuthenticationForbidden(IApplicationBuilder app) - { - app.Run(async ctx => - { - await ctx.ForbidAsync(IISServerDefaults.AuthenticationScheme); - }); - } - - public void AuthenticationRestrictedNTLM(IApplicationBuilder app) - { - app.Run(async ctx => - { - if (string.Equals("NTLM", ctx.User.Identity.AuthenticationType, StringComparison.Ordinal)) - { - await ctx.Response.WriteAsync("NTLM"); - } - else - { - await ctx.ChallengeAsync(IISServerDefaults.AuthenticationScheme); - } - }); - } - - private void FeatureCollectionSetRequestFeatures(IApplicationBuilder app) - { - app.Run(async context => - { - try - { - Assert.Equal("GET", context.Request.Method); - context.Request.Method = "test"; - Assert.Equal("test", context.Request.Method); - - Assert.Equal("http", context.Request.Scheme); - context.Request.Scheme = "test"; - Assert.Equal("test", context.Request.Scheme); - - Assert.Equal("/FeatureCollectionSetRequestFeatures", context.Request.PathBase); - context.Request.PathBase = "/base"; - Assert.Equal("/base", context.Request.PathBase); - - Assert.Equal("/path", context.Request.Path); - context.Request.Path = "/path"; - Assert.Equal("/path", context.Request.Path); - - Assert.Equal("?query", context.Request.QueryString.Value); - context.Request.QueryString = QueryString.Empty; - Assert.Equal("", context.Request.QueryString.Value); - - Assert.Equal("HTTP/1.1", context.Request.Protocol); - context.Request.Protocol = "HTTP/1.0"; - Assert.Equal("HTTP/1.0", context.Request.Protocol); - - Assert.NotNull(context.Request.Headers); - var headers = new HeaderDictionary(); - context.Features.Get().Headers = headers; - Assert.Same(headers, context.Features.Get().Headers); - - Assert.NotNull(context.Request.Body); - var body = new MemoryStream(); - context.Request.Body = body; - Assert.Same(body, context.Request.Body); - - //Assert.NotNull(context.Features.Get().TraceIdentifier); - //Assert.NotEqual(CancellationToken.None, context.RequestAborted); - //var token = new CancellationTokenSource().Token; - //context.RequestAborted = token; - //Assert.Equal(token, context.RequestAborted); - - await context.Response.WriteAsync("Success"); - return; - } - catch (Exception exception) - { - context.Response.StatusCode = 500; - await context.Response.WriteAsync(exception.ToString()); - } - await context.Response.WriteAsync("_Failure"); - }); - } - - private void FeatureCollectionSetResponseFeatures(IApplicationBuilder app) - { - app.Run(async context => - { - try - { - Assert.Equal(200, context.Response.StatusCode); - context.Response.StatusCode = 404; - Assert.Equal(404, context.Response.StatusCode); - context.Response.StatusCode = 200; - - Assert.Null(context.Features.Get().ReasonPhrase); - context.Features.Get().ReasonPhrase = "Set Response"; - Assert.Equal("Set Response", context.Features.Get().ReasonPhrase); - - Assert.NotNull(context.Response.Headers); - var headers = new HeaderDictionary(); - context.Features.Get().Headers = headers; - Assert.Same(headers, context.Features.Get().Headers); - - var originalBody = context.Response.Body; - Assert.NotNull(originalBody); - var body = new MemoryStream(); - context.Response.Body = body; - Assert.Same(body, context.Response.Body); - context.Response.Body = originalBody; - - await context.Response.WriteAsync("Success"); - return; - } - catch (Exception exception) - { - context.Response.StatusCode = 500; - await context.Response.WriteAsync(exception.ToString()); - } - await context.Response.WriteAsync("_Failure"); - }); - } - - private void FeatureCollectionSetConnectionFeatures(IApplicationBuilder app) - { - app.Run(async context => - { - try - { - Assert.True(IPAddress.IsLoopback(context.Connection.LocalIpAddress)); - context.Connection.LocalIpAddress = IPAddress.IPv6Any; - Assert.Equal(IPAddress.IPv6Any, context.Connection.LocalIpAddress); - - Assert.True(IPAddress.IsLoopback(context.Connection.RemoteIpAddress)); - context.Connection.RemoteIpAddress = IPAddress.IPv6Any; - Assert.Equal(IPAddress.IPv6Any, context.Connection.RemoteIpAddress); - await context.Response.WriteAsync("Success"); - return; - } - catch (Exception exception) - { - context.Response.StatusCode = 500; - await context.Response.WriteAsync(exception.ToString()); - } - await context.Response.WriteAsync("_Failure"); - }); - } - - private void Throw(IApplicationBuilder app) - { - app.Run(ctx => { throw new Exception(); }); - } - - private void SetCustomErorCode(IApplicationBuilder app) - { - app.Run(async ctx => { - var feature = ctx.Features.Get(); - feature.ReasonPhrase = ctx.Request.Query["reason"]; - feature.StatusCode = int.Parse(ctx.Request.Query["code"]); - if (ctx.Request.Query["writeBody"] == "True") - { - await ctx.Response.WriteAsync(ctx.Request.Query["body"]); - } - }); - } - - private void HelloWorld(IApplicationBuilder app) - { - app.Run(async ctx => - { - if (ctx.Request.Path.Value.StartsWith("/Path")) - { - await ctx.Response.WriteAsync(ctx.Request.Path.Value); - return; - } - if (ctx.Request.Path.Value.StartsWith("/Query")) - { - await ctx.Response.WriteAsync(ctx.Request.QueryString.Value); - return; - } - - await ctx.Response.WriteAsync("Hello World"); - }); - } - - private void LargeResponseBody(IApplicationBuilder app) - { - app.Run(async context => - { - if (int.TryParse(context.Request.Query["length"], out var length)) - { - await context.Response.WriteAsync(new string('a', length)); - } - }); - } - - private void ResponseHeaders(IApplicationBuilder app) - { - app.Run(async context => - { - context.Response.Headers["UnknownHeader"] = "test123=foo"; - context.Response.ContentType = "text/plain"; - context.Response.Headers["MultiHeader"] = new StringValues(new string[] { "1", "2" }); - await context.Response.WriteAsync("Request Complete"); - }); - } - - private void ResponseInvalidOrdering(IApplicationBuilder app) - { - app.Run(async context => - { - if (context.Request.Path.Equals("/SetStatusCodeAfterWrite")) - { - await context.Response.WriteAsync("Started_"); - try - { - context.Response.StatusCode = 200; - } - catch (InvalidOperationException) - { - await context.Response.WriteAsync("SetStatusCodeAfterWriteThrew_"); - } - await context.Response.WriteAsync("Finished"); - return; - } - else if (context.Request.Path.Equals("/SetHeaderAfterWrite")) - { - await context.Response.WriteAsync("Started_"); - try - { - context.Response.Headers["This will fail"] = "some value"; - } - catch (InvalidOperationException) - { - await context.Response.WriteAsync("SetHeaderAfterWriteThrew_"); - } - await context.Response.WriteAsync("Finished"); - return; - } - }); - } - - private void CheckEnvironmentVariable(IApplicationBuilder app) - { - app.Run(async context => - { - var variable = Environment.GetEnvironmentVariable("ASPNETCORE_INPROCESS_TESTING_VALUE"); - await context.Response.WriteAsync(variable); - }); - } - - private void CheckEnvironmentLongValueVariable(IApplicationBuilder app) - { - app.Run(async context => - { - var variable = Environment.GetEnvironmentVariable("ASPNETCORE_INPROCESS_TESTING_LONG_VALUE"); - await context.Response.WriteAsync(variable); - }); - } - - private void CheckAppendedEnvironmentVariable(IApplicationBuilder app) - { - app.Run(async context => - { - var variable = Environment.GetEnvironmentVariable("ProgramFiles"); - await context.Response.WriteAsync(variable); - }); - } - - private void CheckRemoveAuthEnvironmentVariable(IApplicationBuilder app) - { - app.Run(async context => - { - var variable = Environment.GetEnvironmentVariable("ASPNETCORE_IIS_HTTPAUTH"); - await context.Response.WriteAsync(variable); - }); - } - private void ReadAndWriteSynchronously(IApplicationBuilder app) - { - app.Run(async context => - { - var t2 = Task.Run(() => WriteManyTimesToResponseBody(context)); - var t1 = Task.Run(() => ReadRequestBody(context)); - await Task.WhenAll(t1, t2); - }); - } - - private async Task ReadRequestBody(HttpContext context) - { - var readBuffer = new byte[1]; - var result = await context.Request.Body.ReadAsync(readBuffer, 0, 1); - while (result != 0) - { - result = await context.Request.Body.ReadAsync(readBuffer, 0, 1); + await ctx.ChallengeAsync(IISServerDefaults.AuthenticationScheme); } } - private async Task WriteManyTimesToResponseBody(HttpContext context) + private async Task AuthenticationForbidden(HttpContext ctx) + { + await ctx.ForbidAsync(IISServerDefaults.AuthenticationScheme); + } + + private async Task AuthenticationRestrictedNTLM(HttpContext ctx) + { + if (string.Equals("NTLM", ctx.User.Identity.AuthenticationType, StringComparison.Ordinal)) + { + await ctx.Response.WriteAsync("NTLM"); + } + else + { + await ctx.ChallengeAsync(IISServerDefaults.AuthenticationScheme); + } + } + + private async Task FeatureCollectionSetRequestFeatures(HttpContext ctx) + { + try + { + Assert.Equal("GET", ctx.Request.Method); + ctx.Request.Method = "test"; + Assert.Equal("test", ctx.Request.Method); + + Assert.Equal("http", ctx.Request.Scheme); + ctx.Request.Scheme = "test"; + Assert.Equal("test", ctx.Request.Scheme); + + Assert.Equal("/FeatureCollectionSetRequestFeatures", ctx.Request.PathBase); + ctx.Request.PathBase = "/base"; + Assert.Equal("/base", ctx.Request.PathBase); + + Assert.Equal("/path", ctx.Request.Path); + ctx.Request.Path = "/path"; + Assert.Equal("/path", ctx.Request.Path); + + Assert.Equal("?query", ctx.Request.QueryString.Value); + ctx.Request.QueryString = QueryString.Empty; + Assert.Equal("", ctx.Request.QueryString.Value); + + Assert.Equal("HTTP/1.1", ctx.Request.Protocol); + ctx.Request.Protocol = "HTTP/1.0"; + Assert.Equal("HTTP/1.0", ctx.Request.Protocol); + + Assert.NotNull(ctx.Request.Headers); + var headers = new HeaderDictionary(); + ctx.Features.Get().Headers = headers; + Assert.Same(headers, ctx.Features.Get().Headers); + + Assert.NotNull(ctx.Request.Body); + var body = new MemoryStream(); + ctx.Request.Body = body; + Assert.Same(body, ctx.Request.Body); + + //Assert.NotNull(ctx.Features.Get().TraceIdentifier); + //Assert.NotEqual(CancellationToken.None, ctx.RequestAborted); + //var token = new CancellationTokenSource().Token; + //ctx.RequestAborted = token; + //Assert.Equal(token, ctx.RequestAborted); + + await ctx.Response.WriteAsync("Success"); + return; + } + catch (Exception exception) + { + ctx.Response.StatusCode = 500; + await ctx.Response.WriteAsync(exception.ToString()); + } + await ctx.Response.WriteAsync("_Failure"); + } + + private async Task FeatureCollectionSetResponseFeatures(HttpContext ctx) + { + try + { + Assert.Equal(200, ctx.Response.StatusCode); + ctx.Response.StatusCode = 404; + Assert.Equal(404, ctx.Response.StatusCode); + ctx.Response.StatusCode = 200; + + Assert.Null(ctx.Features.Get().ReasonPhrase); + ctx.Features.Get().ReasonPhrase = "Set Response"; + Assert.Equal("Set Response", ctx.Features.Get().ReasonPhrase); + + Assert.NotNull(ctx.Response.Headers); + var headers = new HeaderDictionary(); + ctx.Features.Get().Headers = headers; + Assert.Same(headers, ctx.Features.Get().Headers); + + var originalBody = ctx.Response.Body; + Assert.NotNull(originalBody); + var body = new MemoryStream(); + ctx.Response.Body = body; + Assert.Same(body, ctx.Response.Body); + ctx.Response.Body = originalBody; + + await ctx.Response.WriteAsync("Success"); + return; + } + catch (Exception exception) + { + ctx.Response.StatusCode = 500; + await ctx.Response.WriteAsync(exception.ToString()); + } + await ctx.Response.WriteAsync("_Failure"); + } + + private async Task FeatureCollectionSetConnectionFeatures(HttpContext ctx) + { + try + { + Assert.True(IPAddress.IsLoopback(ctx.Connection.LocalIpAddress)); + ctx.Connection.LocalIpAddress = IPAddress.IPv6Any; + Assert.Equal(IPAddress.IPv6Any, ctx.Connection.LocalIpAddress); + + Assert.True(IPAddress.IsLoopback(ctx.Connection.RemoteIpAddress)); + ctx.Connection.RemoteIpAddress = IPAddress.IPv6Any; + Assert.Equal(IPAddress.IPv6Any, ctx.Connection.RemoteIpAddress); + await ctx.Response.WriteAsync("Success"); + return; + } + catch (Exception exception) + { + ctx.Response.StatusCode = 500; + await ctx.Response.WriteAsync(exception.ToString()); + } + await ctx.Response.WriteAsync("_Failure"); + } + + private void Throw(HttpContext ctx) + { + throw new Exception(); + } + + private async Task SetCustomErorCode(HttpContext ctx) + { + var feature = ctx.Features.Get(); + feature.ReasonPhrase = ctx.Request.Query["reason"]; + feature.StatusCode = int.Parse(ctx.Request.Query["code"]); + if (ctx.Request.Query["writeBody"] == "True") + { + await ctx.Response.WriteAsync(ctx.Request.Query["body"]); + } + } + + private async Task HelloWorld(HttpContext ctx) + { + if (ctx.Request.Path.Value.StartsWith("/Path")) + { + await ctx.Response.WriteAsync(ctx.Request.Path.Value); + return; + } + if (ctx.Request.Path.Value.StartsWith("/Query")) + { + await ctx.Response.WriteAsync(ctx.Request.QueryString.Value); + return; + } + + await ctx.Response.WriteAsync("Hello World"); + } + + private async Task LargeResponseBody(HttpContext ctx) + { + if (int.TryParse(ctx.Request.Query["length"], out var length)) + { + await ctx.Response.WriteAsync(new string('a', length)); + } + } + + private async Task ResponseHeaders(HttpContext ctx) + { + ctx.Response.Headers["UnknownHeader"] = "test123=foo"; + ctx.Response.ContentType = "text/plain"; + ctx.Response.Headers["MultiHeader"] = new StringValues(new string[] { "1", "2" }); + await ctx.Response.WriteAsync("Request Complete"); + } + + private async Task ResponseInvalidOrdering(HttpContext ctx) + { + if (ctx.Request.Path.Equals("/SetStatusCodeAfterWrite")) + { + await ctx.Response.WriteAsync("Started_"); + try + { + ctx.Response.StatusCode = 200; + } + catch (InvalidOperationException) + { + await ctx.Response.WriteAsync("SetStatusCodeAfterWriteThrew_"); + } + await ctx.Response.WriteAsync("Finished"); + return; + } + else if (ctx.Request.Path.Equals("/SetHeaderAfterWrite")) + { + await ctx.Response.WriteAsync("Started_"); + try + { + ctx.Response.Headers["This will fail"] = "some value"; + } + catch (InvalidOperationException) + { + await ctx.Response.WriteAsync("SetHeaderAfterWriteThrew_"); + } + await ctx.Response.WriteAsync("Finished"); + return; + } + } + + private async Task CheckEnvironmentVariable(HttpContext ctx) + { + var variable = Environment.GetEnvironmentVariable("ASPNETCORE_INPROCESS_TESTING_VALUE"); + await ctx.Response.WriteAsync(variable); + } + + private async Task CheckEnvironmentLongValueVariable(HttpContext ctx) + { + var variable = Environment.GetEnvironmentVariable("ASPNETCORE_INPROCESS_TESTING_LONG_VALUE"); + await ctx.Response.WriteAsync(variable); + } + + private async Task CheckAppendedEnvironmentVariable(HttpContext ctx) + { + var variable = Environment.GetEnvironmentVariable("ProgramFiles"); + await ctx.Response.WriteAsync(variable); + } + + private async Task CheckRemoveAuthEnvironmentVariable(HttpContext ctx) + { + var variable = Environment.GetEnvironmentVariable("ASPNETCORE_IIS_HTTPAUTH"); + await ctx.Response.WriteAsync(variable); + } + private async Task ReadAndWriteSynchronously(HttpContext ctx) + { + var t2 = Task.Run(() => WriteManyTimesToResponseBody(ctx)); + var t1 = Task.Run(() => ReadRequestBody(ctx)); + await Task.WhenAll(t1, t2); + } + + private async Task ReadRequestBody(HttpContext ctx) + { + var readBuffer = new byte[1]; + var result = await ctx.Request.Body.ReadAsync(readBuffer, 0, 1); + while (result != 0) + { + result = await ctx.Request.Body.ReadAsync(readBuffer, 0, 1); + } + } + + private async Task WriteManyTimesToResponseBody(HttpContext ctx) { for (var i = 0; i < 10000; i++) { - await context.Response.WriteAsync("hello world"); + await ctx.Response.WriteAsync("hello world"); } } - private void ReadAndWriteEcho(IApplicationBuilder app) + private async Task ReadAndWriteEcho(HttpContext ctx) { - app.Run(async context => { - var readBuffer = new byte[4096]; - var result = await context.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); - while (result != 0) - { - await context.Response.WriteAsync(Encoding.UTF8.GetString(readBuffer, 0, result)); - result = await context.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); - } - }); - } - - private void ReadAndWriteEchoLines(IApplicationBuilder app) - { - app.Run(async context => { - //Send headers - await context.Response.Body.FlushAsync(); - - var reader = new StreamReader(context.Request.Body); - while (!reader.EndOfStream) - { - var line = await reader.ReadLineAsync(); - if (line == "") - { - return; - } - await context.Response.WriteAsync(line + Environment.NewLine); - await context.Response.Body.FlushAsync(); - } - }); - } - - private void ReadPartialBody(IApplicationBuilder app) - { - app.Run(async context => { - var data = new byte[5]; - var count = 0; - do - { - count += await context.Request.Body.ReadAsync(data, count, data.Length - count); - } while (count != data.Length); - await context.Response.Body.WriteAsync(data, 0, data.Length); - }); - } - - private void SetHeaderFromBody(IApplicationBuilder app) - { - app.Run(async context => { - using (var reader = new StreamReader(context.Request.Body)) - { - var value = await reader.ReadToEndAsync(); - context.Response.Headers["BodyAsString"] = value; - await context.Response.WriteAsync(value); - } - }); - } - - private void ReadAndWriteEchoTwice(IApplicationBuilder app) - { - app.Run(async context => + var readBuffer = new byte[4096]; + var result = await ctx.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); + while (result != 0) { - var readBuffer = new byte[4096]; - var result = await context.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); - while (result != 0) - { - await context.Response.WriteAsync(Encoding.UTF8.GetString(readBuffer, 0, result)); - await context.Response.Body.FlushAsync(); - await context.Response.WriteAsync(Encoding.UTF8.GetString(readBuffer, 0, result)); - await context.Response.Body.FlushAsync(); - result = await context.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); - } - }); + await ctx.Response.WriteAsync(Encoding.UTF8.GetString(readBuffer, 0, result)); + result = await ctx.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); + } } - private void ReadAndWriteSlowConnection(IApplicationBuilder app) + private async Task ReadAndWriteEchoLines(HttpContext ctx) { - app.Run(async context => + //Send headers + await ctx.Response.Body.FlushAsync(); + + var reader = new StreamReader(ctx.Request.Body); + while (!reader.EndOfStream) { - var t2 = Task.Run(() => WriteResponseBodyAFewTimes(context)); - var t1 = Task.Run(() => ReadRequestBody(context)); - await Task.WhenAll(t1, t2); - }); + var line = await reader.ReadLineAsync(); + if (line == "") + { + return; + } + await ctx.Response.WriteAsync(line + Environment.NewLine); + await ctx.Response.Body.FlushAsync(); + } } - private async Task WriteResponseBodyAFewTimes(HttpContext context) + private async Task ReadPartialBody(HttpContext ctx) + { + var data = new byte[5]; + var count = 0; + do + { + count += await ctx.Request.Body.ReadAsync(data, count, data.Length - count); + } while (count != data.Length); + await ctx.Response.Body.WriteAsync(data, 0, data.Length); + } + + private async Task SetHeaderFromBody(HttpContext ctx) + { + using (var reader = new StreamReader(ctx.Request.Body)) + { + var value = await reader.ReadToEndAsync(); + ctx.Response.Headers["BodyAsString"] = value; + await ctx.Response.WriteAsync(value); + } + } + + private async Task ReadAndWriteEchoTwice(HttpContext ctx) + { + var readBuffer = new byte[4096]; + var result = await ctx.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); + while (result != 0) + { + await ctx.Response.WriteAsync(Encoding.UTF8.GetString(readBuffer, 0, result)); + await ctx.Response.Body.FlushAsync(); + await ctx.Response.WriteAsync(Encoding.UTF8.GetString(readBuffer, 0, result)); + await ctx.Response.Body.FlushAsync(); + result = await ctx.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); + } + } + + private async Task ReadAndWriteSlowConnection(HttpContext ctx) + { + var t2 = Task.Run(() => WriteResponseBodyAFewTimes(ctx)); + var t1 = Task.Run(() => ReadRequestBody(ctx)); + await Task.WhenAll(t1, t2); + } + + private async Task WriteResponseBodyAFewTimes(HttpContext ctx) { for (var i = 0; i < 100; i++) { - await context.Response.WriteAsync("hello world"); + await ctx.Response.WriteAsync("hello world"); } } - private void ReadAndWriteCopyToAsync(IApplicationBuilder app) + private async Task ReadAndWriteCopyToAsync(HttpContext ctx) { - app.Run(async context => - { - await context.Request.Body.CopyToAsync(context.Response.Body); - }); + await ctx.Request.Body.CopyToAsync(ctx.Response.Body); } - private void UpgradeFeatureDetection(IApplicationBuilder app) + private async Task UpgradeFeatureDetection(HttpContext ctx) { - app.Run(async ctx => + if (ctx.Features.Get() != null) { - if (ctx.Features.Get() != null) - { - await ctx.Response.WriteAsync("Enabled"); - } - else - { - await ctx.Response.WriteAsync("Disabled"); - } - }); + await ctx.Response.WriteAsync("Enabled"); + } + else + { + await ctx.Response.WriteAsync("Disabled"); + } } - private void TestReadOffsetWorks(IApplicationBuilder app) + private async Task TestReadOffsetWorks(HttpContext ctx) { - app.Run(async ctx => - { - var buffer = new byte[11]; - ctx.Request.Body.Read(buffer, 0, 6); - ctx.Request.Body.Read(buffer, 6, 5); + var buffer = new byte[11]; + ctx.Request.Body.Read(buffer, 0, 6); + ctx.Request.Body.Read(buffer, 6, 5); - await ctx.Response.WriteAsync(Encoding.UTF8.GetString(buffer)); - }); + await ctx.Response.WriteAsync(Encoding.UTF8.GetString(buffer)); } - private void TestInvalidReadOperations(IApplicationBuilder app) + private async Task TestInvalidReadOperations(HttpContext ctx) { - app.Run(async context => + var success = false; + if (ctx.Request.Path.StartsWithSegments("/NullBuffer")) { - var success = false; - if (context.Request.Path.StartsWithSegments("/NullBuffer")) - { - try - { - await context.Request.Body.ReadAsync(null, 0, 0); - } - catch (Exception) - { - success = true; - } - } - else if (context.Request.Path.StartsWithSegments("/InvalidOffsetSmall")) - { - try - { - await context.Request.Body.ReadAsync(new byte[1], -1, 0); - } - catch (ArgumentOutOfRangeException) - { - success = true; - } - } - else if (context.Request.Path.StartsWithSegments("/InvalidOffsetLarge")) - { - try - { - await context.Request.Body.ReadAsync(new byte[1], 2, 0); - } - catch (ArgumentOutOfRangeException) - { - success = true; - } - } - else if (context.Request.Path.StartsWithSegments("/InvalidCountSmall")) - { - try - { - await context.Request.Body.ReadAsync(new byte[1], 0, -1); - } - catch (ArgumentOutOfRangeException) - { - success = true; - } - } - else if (context.Request.Path.StartsWithSegments("/InvalidCountLarge")) - { - try - { - await context.Request.Body.ReadAsync(new byte[1], 0, -1); - } - catch (ArgumentOutOfRangeException) - { - success = true; - } - } - else if (context.Request.Path.StartsWithSegments("/InvalidCountWithOffset")) - { - try - { - await context.Request.Body.ReadAsync(new byte[3], 1, 3); - } - catch (ArgumentOutOfRangeException) - { - success = true; - } - } - - - await context.Response.WriteAsync(success ? "Success" : "Failure"); - }); - } - - private void TestValidReadOperations(IApplicationBuilder app) - { - app.Run(async context => - { - var count = -1; - - if (context.Request.Path.StartsWithSegments("/NullBuffer")) - { - count = await context.Request.Body.ReadAsync(null, 0, 0); - } - else if (context.Request.Path.StartsWithSegments("/NullBufferPost")) - { - count = await context.Request.Body.ReadAsync(null, 0, 0); - } - else if (context.Request.Path.StartsWithSegments("/InvalidCountZeroRead")) - { - count = await context.Request.Body.ReadAsync(new byte[1], 0, 0); - } - else if (context.Request.Path.StartsWithSegments("/InvalidCountZeroReadPost")) - { - count = await context.Request.Body.ReadAsync(new byte[1], 0, 0); - } - - await context.Response.WriteAsync(count == 0 ? "Success" : "Failure"); - }); - } - - private void TestInvalidWriteOperations(IApplicationBuilder app) - { - app.Run(async context => - { - var success = false; - - if (context.Request.Path.StartsWithSegments("/InvalidOffsetSmall")) - { - try - { - await context.Response.Body.WriteAsync(new byte[1], -1, 0); - } - catch (ArgumentOutOfRangeException) - { - success = true; - } - } - else if (context.Request.Path.StartsWithSegments("/InvalidOffsetLarge")) - { - try - { - await context.Response.Body.WriteAsync(new byte[1], 2, 0); - } - catch (ArgumentOutOfRangeException) - { - success = true; - } - } - else if (context.Request.Path.StartsWithSegments("/InvalidCountSmall")) - { - try - { - await context.Response.Body.WriteAsync(new byte[1], 0, -1); - } - catch (ArgumentOutOfRangeException) - { - success = true; - } - } - else if (context.Request.Path.StartsWithSegments("/InvalidCountLarge")) - { - try - { - await context.Response.Body.WriteAsync(new byte[1], 0, -1); - } - catch (ArgumentOutOfRangeException) - { - success = true; - } - } - else if (context.Request.Path.StartsWithSegments("/InvalidCountWithOffset")) - { - try - { - await context.Response.Body.WriteAsync(new byte[3], 1, 3); - } - catch (ArgumentOutOfRangeException) - { - success = true; - } - } - - await context.Response.WriteAsync(success ? "Success" : "Failure"); - }); - } - - private void TestValidWriteOperations(IApplicationBuilder app) - { - app.Run(async context => - { - if (context.Request.Path.StartsWithSegments("/NullBuffer")) - { - await context.Response.Body.WriteAsync(null, 0, 0); - } - else if (context.Request.Path.StartsWithSegments("/NullBufferPost")) - { - await context.Response.Body.WriteAsync(null, 0, 0); - } - - await context.Response.WriteAsync("Success"); - }); - } - - private void LargeResponseFile(IApplicationBuilder app) - { - app.Run(async ctx => - { - var tempFile = Path.GetTempFileName(); - var fileContent = new string('a', 200000); - var fileStream = File.OpenWrite(tempFile); - - for (var i = 0; i < 1000; i++) - { - await fileStream.WriteAsync(Encoding.UTF8.GetBytes(fileContent), 0, fileContent.Length); - } - fileStream.Close(); - - await ctx.Response.SendFileAsync(tempFile, 0, null); - - // Try to delete the file from the temp directory. If it fails, don't report an error - // to the application. File should eventually be cleaned up from the temp directory - // by OS. try { - File.Delete(tempFile); + await ctx.Request.Body.ReadAsync(null, 0, 0); } catch (Exception) { + success = true; } - }); - } - - private void BasePath(IApplicationBuilder app) - { - app.Run(async ctx => { await ctx.Response.WriteAsync(AppDomain.CurrentDomain.BaseDirectory); }); - } - - private void CheckLogFile(IApplicationBuilder app) - { - app.Run(async ctx => + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidOffsetSmall")) { - Console.WriteLine("TEST MESSAGE"); - - await ctx.Response.WriteAsync("Hello World"); - }); - } - - private void CheckErrLogFile(IApplicationBuilder app) - { - app.Run(async ctx => + try + { + await ctx.Request.Body.ReadAsync(new byte[1], -1, 0); + } + catch (ArgumentOutOfRangeException) + { + success = true; + } + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidOffsetLarge")) { - Console.Error.WriteLine("TEST MESSAGE"); - Console.Error.Flush(); - - await ctx.Response.WriteAsync("Hello World"); - }); - } - - private void Shutdown(IApplicationBuilder app) - { - app.Run(async ctx => + try + { + await ctx.Request.Body.ReadAsync(new byte[1], 2, 0); + } + catch (ArgumentOutOfRangeException) + { + success = true; + } + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidCountSmall")) { - await ctx.Response.WriteAsync("Shutting down"); - ctx.RequestServices.GetService().StopApplication(); - }); + try + { + await ctx.Request.Body.ReadAsync(new byte[1], 0, -1); + } + catch (ArgumentOutOfRangeException) + { + success = true; + } + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidCountLarge")) + { + try + { + await ctx.Request.Body.ReadAsync(new byte[1], 0, -1); + } + catch (ArgumentOutOfRangeException) + { + success = true; + } + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidCountWithOffset")) + { + try + { + await ctx.Request.Body.ReadAsync(new byte[3], 1, 3); + } + catch (ArgumentOutOfRangeException) + { + success = true; + } + } + + + await ctx.Response.WriteAsync(success ? "Success" : "Failure"); } - private async Task GetServerVariableStress(HttpContext context) + private async Task TestValidReadOperations(HttpContext ctx) + { + var count = -1; + + if (ctx.Request.Path.StartsWithSegments("/NullBuffer")) + { + count = await ctx.Request.Body.ReadAsync(null, 0, 0); + } + else if (ctx.Request.Path.StartsWithSegments("/NullBufferPost")) + { + count = await ctx.Request.Body.ReadAsync(null, 0, 0); + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidCountZeroRead")) + { + count = await ctx.Request.Body.ReadAsync(new byte[1], 0, 0); + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidCountZeroReadPost")) + { + count = await ctx.Request.Body.ReadAsync(new byte[1], 0, 0); + } + + await ctx.Response.WriteAsync(count == 0 ? "Success" : "Failure"); + } + + private async Task TestInvalidWriteOperations(HttpContext ctx) + { + var success = false; + + if (ctx.Request.Path.StartsWithSegments("/InvalidOffsetSmall")) + { + try + { + await ctx.Response.Body.WriteAsync(new byte[1], -1, 0); + } + catch (ArgumentOutOfRangeException) + { + success = true; + } + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidOffsetLarge")) + { + try + { + await ctx.Response.Body.WriteAsync(new byte[1], 2, 0); + } + catch (ArgumentOutOfRangeException) + { + success = true; + } + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidCountSmall")) + { + try + { + await ctx.Response.Body.WriteAsync(new byte[1], 0, -1); + } + catch (ArgumentOutOfRangeException) + { + success = true; + } + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidCountLarge")) + { + try + { + await ctx.Response.Body.WriteAsync(new byte[1], 0, -1); + } + catch (ArgumentOutOfRangeException) + { + success = true; + } + } + else if (ctx.Request.Path.StartsWithSegments("/InvalidCountWithOffset")) + { + try + { + await ctx.Response.Body.WriteAsync(new byte[3], 1, 3); + } + catch (ArgumentOutOfRangeException) + { + success = true; + } + } + + await ctx.Response.WriteAsync(success ? "Success" : "Failure"); + } + + private async Task TestValidWriteOperations(HttpContext ctx) + { + if (ctx.Request.Path.StartsWithSegments("/NullBuffer")) + { + await ctx.Response.Body.WriteAsync(null, 0, 0); + } + else if (ctx.Request.Path.StartsWithSegments("/NullBufferPost")) + { + await ctx.Response.Body.WriteAsync(null, 0, 0); + } + + await ctx.Response.WriteAsync("Success"); + } + + private async Task LargeResponseFile(HttpContext ctx) + { + var tempFile = Path.GetTempFileName(); + var fileContent = new string('a', 200000); + var fileStream = File.OpenWrite(tempFile); + + for (var i = 0; i < 1000; i++) + { + await fileStream.WriteAsync(Encoding.UTF8.GetBytes(fileContent), 0, fileContent.Length); + } + fileStream.Close(); + + await ctx.Response.SendFileAsync(tempFile, 0, null); + + // Try to delete the file from the temp directory. If it fails, don't report an error + // to the application. File should eventually be cleaned up from the temp directory + // by OS. + try + { + File.Delete(tempFile); + } + catch (Exception) + { + } + } + + private async Task BasePath(HttpContext ctx) + { + await ctx.Response.WriteAsync(AppDomain.CurrentDomain.BaseDirectory); + } + + private async Task Shutdown(HttpContext ctx) + { + await ctx.Response.WriteAsync("Shutting down"); + ctx.RequestServices.GetService().StopApplication(); + } + + private async Task GetServerVariableStress(HttpContext ctx) { // This test simulates the scenario where native Flush call is being // executed on background thread while request thread calls GetServerVariable // concurrent native calls may cause native object corruption - await context.Response.WriteAsync("Response Begin"); + await ctx.Response.WriteAsync("Response Begin"); for (int i = 0; i < 1000; i++) { - await context.Response.WriteAsync(context.GetIISServerVariable("REMOTE_PORT")); - await context.Response.Body.FlushAsync(); + await ctx.Response.WriteAsync(ctx.GetIISServerVariable("REMOTE_PORT")); + await ctx.Response.Body.FlushAsync(); } - await context.Response.WriteAsync("Response End"); + await ctx.Response.WriteAsync("Response End"); } - private async Task CommandLineArgs(HttpContext context) + private async Task CommandLineArgs(HttpContext ctx) { - await context.Response.WriteAsync(string.Join("|", Environment.GetCommandLineArgs().Skip(1))); + await ctx.Response.WriteAsync(string.Join("|", Environment.GetCommandLineArgs().Skip(1))); } } } diff --git a/test/WebSites/OutOfProcessWebSite/Program.cs b/test/WebSites/OutOfProcessWebSite/Program.cs index a5943f5f00..e5ce65cba1 100644 --- a/test/WebSites/OutOfProcessWebSite/Program.cs +++ b/test/WebSites/OutOfProcessWebSite/Program.cs @@ -5,7 +5,7 @@ using System.IO; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Logging; -namespace TestSites +namespace TestSite { public static class Program { diff --git a/test/WebSites/OutOfProcessWebSite/Startup.cs b/test/WebSites/OutOfProcessWebSite/Startup.cs index 8a8358d364..2547eb5735 100644 --- a/test/WebSites/OutOfProcessWebSite/Startup.cs +++ b/test/WebSites/OutOfProcessWebSite/Startup.cs @@ -5,12 +5,10 @@ using System; using System.Diagnostics; using System.IO; using System.Linq; -using System.Runtime.InteropServices; using System.Security.Principal; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server.Features; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; @@ -19,9 +17,9 @@ using Microsoft.AspNetCore.Server.IISIntegration; using Microsoft.Extensions.DependencyInjection; using Xunit; -namespace TestSites +namespace TestSite { - public class Startup + public partial class Startup { private IServerAddressesFeature _serverAddresses; @@ -112,15 +110,6 @@ namespace TestSites return context.Response.WriteAsync(context.Request.Headers["ANCMRHPath"]); } - private async Task HostingEnvironment(HttpContext context) - { - var hostingEnv = context.RequestServices.GetService(); - - await context.Response.WriteAsync("ContentRootPath "+hostingEnv.ContentRootPath + Environment.NewLine); - await context.Response.WriteAsync("WebRootPath "+hostingEnv.WebRootPath + Environment.NewLine); - await context.Response.WriteAsync("CurrentDirectory "+Environment.CurrentDirectory); - } - private async Task ProcessId(HttpContext context) { await context.Response.WriteAsync(Process.GetCurrentProcess().Id.ToString()); diff --git a/test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj b/test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj deleted file mode 100644 index f7108dadc4..0000000000 --- a/test/WebSites/OverriddenServerWebSite/OverriddenServerWebSite.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - netcoreapp2.2 - true - - - - - - - - - - - - - diff --git a/test/WebSites/OverriddenServerWebSite/Properties/launchSettings.json b/test/WebSites/OverriddenServerWebSite/Properties/launchSettings.json deleted file mode 100644 index 9c963c0100..0000000000 --- a/test/WebSites/OverriddenServerWebSite/Properties/launchSettings.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": true, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:5762/", - "sslPort": 0 - } - }, - "profiles": { - "ANCM IIS Express": { - "commandName": "Executable", - "executablePath": "$(IISExpressPath)", - "commandLineArgs": "$(IISExpressArguments)", - "nativeDebugging": true, - "environmentVariables": { - "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", - "ANCM_PATH": "$(TargetDir)\\$(AncmPath)", - "ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)", - "LAUNCHER_ARGS": "$(TargetPath)", - "ASPNETCORE_ENVIRONMENT": "Development", - "LAUNCHER_PATH": "$(DotNetPath)", - "ASPNETCORE_MODULE_DEBUG": "console" - } - }, - "ANCM IIS": { - "commandName": "Executable", - "executablePath": "$(IISPath)", - "commandLineArgs": "$(IISArguments)", - "environmentVariables": { - "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", - "ANCM_PATH": "$(AncmPath)", - "ANCMV2_PATH": "$(AncmV2Path)", - "LAUNCHER_ARGS": "$(TargetPath)", - "ASPNETCORE_ENVIRONMENT": "Development", - "LAUNCHER_PATH": "$(DotNetPath)", - "ASPNETCORE_MODULE_DEBUG": "console" - } - } - } -} diff --git a/test/WebSites/StartupExceptionWebSite/Program.cs b/test/WebSites/StartupExceptionWebSite/Program.cs deleted file mode 100644 index 95bac44503..0000000000 --- a/test/WebSites/StartupExceptionWebSite/Program.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Linq; -using System.Text; -using System.Threading; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; - -namespace IISTestSite -{ - public static class Program - { - public static int Main(string[] args) - { - var mode = args.FirstOrDefault(); - - switch (mode) - { - // Semicolons are appended to env variables; removing them. - case "CheckLargeStdOutWrites": - Console.WriteLine(new string('a', 30000)); - break; - case "CheckLargeStdErrWrites": - Console.Error.WriteLine(new string('a', 30000)); - Console.Error.Flush(); - break; - case "CheckLogFile": - Console.WriteLine($"Random number: {args[1]}"); - break; - case "CheckErrLogFile": - Console.Error.WriteLine($"Random number: {args[1]}"); - Console.Error.Flush(); - break; - case "CheckOversizedStdErrWrites": - Console.WriteLine(new string('a', 31000)); - break; - case "CheckOversizedStdOutWrites": - Console.Error.WriteLine(new string('a', 31000)); - Console.Error.Flush(); - break; - case "Hang": - Thread.Sleep(Timeout.Infinite); - break; - case "Throw": - throw new InvalidOperationException("Program.Main exception"); - case "HangOnStop": - var host = new WebHostBuilder() - .UseIIS() - .UseStartup() - .Build(); - host.Run(); - - Thread.Sleep(Timeout.Infinite); - break; - case "CheckConsoleFunctions": - // Call a bunch of console functions and make sure none return invalid handle. - Console.OutputEncoding = Encoding.UTF8; - Console.Title = "Test"; - Console.WriteLine($"Is Console redirection: {Console.IsOutputRedirected}"); - Console.BackgroundColor = ConsoleColor.Blue; - Console.WriteLine("彡⾔"); - break; - } - - return 12; - } - - public partial class Startup - { - public void Configure(IApplicationBuilder app) - { - app.Run(async context => await context.Response.WriteAsync("OK")); - } - } - } -} diff --git a/test/WebSites/StartupExceptionWebSite/Properties/launchSettings.json b/test/WebSites/StartupExceptionWebSite/Properties/launchSettings.json deleted file mode 100644 index 9c963c0100..0000000000 --- a/test/WebSites/StartupExceptionWebSite/Properties/launchSettings.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": true, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:5762/", - "sslPort": 0 - } - }, - "profiles": { - "ANCM IIS Express": { - "commandName": "Executable", - "executablePath": "$(IISExpressPath)", - "commandLineArgs": "$(IISExpressArguments)", - "nativeDebugging": true, - "environmentVariables": { - "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", - "ANCM_PATH": "$(TargetDir)\\$(AncmPath)", - "ANCMV2_PATH": "$(TargetDir)\\$(AncmV2Path)", - "LAUNCHER_ARGS": "$(TargetPath)", - "ASPNETCORE_ENVIRONMENT": "Development", - "LAUNCHER_PATH": "$(DotNetPath)", - "ASPNETCORE_MODULE_DEBUG": "console" - } - }, - "ANCM IIS": { - "commandName": "Executable", - "executablePath": "$(IISPath)", - "commandLineArgs": "$(IISArguments)", - "environmentVariables": { - "IIS_SITE_PATH": "$(MSBuildThisFileDirectory)", - "ANCM_PATH": "$(AncmPath)", - "ANCMV2_PATH": "$(AncmV2Path)", - "LAUNCHER_ARGS": "$(TargetPath)", - "ASPNETCORE_ENVIRONMENT": "Development", - "LAUNCHER_PATH": "$(DotNetPath)", - "ASPNETCORE_MODULE_DEBUG": "console" - } - } - } -} diff --git a/test/WebSites/StartupExceptionWebSite/StartupExceptionWebSite.csproj b/test/WebSites/StartupExceptionWebSite/StartupExceptionWebSite.csproj deleted file mode 100644 index 922196815f..0000000000 --- a/test/WebSites/StartupExceptionWebSite/StartupExceptionWebSite.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - netcoreapp2.2 - true - - - - - - - - - - - - - diff --git a/test/WebSites/StartupExceptionWebSite/web.config b/test/WebSites/StartupExceptionWebSite/web.config deleted file mode 100644 index 0c7405e4d1..0000000000 --- a/test/WebSites/StartupExceptionWebSite/web.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/test/WebSites/shared/SharedStartup/Startup.shared.cs b/test/WebSites/shared/SharedStartup/Startup.shared.cs new file mode 100644 index 0000000000..eef8f8bf7e --- /dev/null +++ b/test/WebSites/shared/SharedStartup/Startup.shared.cs @@ -0,0 +1,37 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; + +namespace TestSite +{ + public partial class Startup + { + private async Task HostingEnvironment(HttpContext ctx) + { + var hostingEnv = ctx.RequestServices.GetService(); + + await ctx.Response.WriteAsync("ContentRootPath " + hostingEnv.ContentRootPath + Environment.NewLine); + await ctx.Response.WriteAsync("WebRootPath " + hostingEnv.WebRootPath + Environment.NewLine); + await ctx.Response.WriteAsync("CurrentDirectory " + Environment.CurrentDirectory); + } + + private async Task ConsoleWrite(HttpContext ctx) + { + Console.WriteLine("TEST MESSAGE"); + + await ctx.Response.WriteAsync("Hello World"); + } + + private async Task ConsoleErrorWrite(HttpContext ctx) + { + Console.Error.WriteLine("TEST MESSAGE"); + + await ctx.Response.WriteAsync("Hello World"); + } + } +} From 1a0f98806442471f13574a8333d177c6427a1571 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 13 Sep 2018 11:22:11 -0700 Subject: [PATCH 3/4] Skip AppOfflineDroppedWhileSiteFailedToStartInRequestHandler_SiteStops_InProcess (#1396) --- test/Common.FunctionalTests/AppOfflineTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Common.FunctionalTests/AppOfflineTests.cs b/test/Common.FunctionalTests/AppOfflineTests.cs index 41bf8874d9..53afd34504 100644 --- a/test/Common.FunctionalTests/AppOfflineTests.cs +++ b/test/Common.FunctionalTests/AppOfflineTests.cs @@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests DeletePublishOutput(deploymentResult); } - [ConditionalFact] + [ConditionalFact(Skip = "https://github.com/aspnet/IISIntegration/issues/933")] public async Task AppOfflineDroppedWhileSiteFailedToStartInRequestHandler_SiteStops_InProcess() { var deploymentResult = await DeployApp(HostingModel.InProcess); From c93c974dbcee18c49d9127674a1e12fd0febd2a8 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 13 Sep 2018 12:15:38 -0700 Subject: [PATCH 4/4] Update certs on Jenkins (#1397) --- build/buildpipeline/windows.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/buildpipeline/windows.groovy b/build/buildpipeline/windows.groovy index 3aa3d99283..eb1a95bca3 100644 --- a/build/buildpipeline/windows.groovy +++ b/build/buildpipeline/windows.groovy @@ -10,6 +10,6 @@ simpleNode('Windows.10.Amd64.EnterpriseRS3.ASPNET.Open') { stage ('Build') { def logFolder = getLogFolder() def environment = "\$env:ASPNETCORE_TEST_LOG_DIR='${WORKSPACE}\\${logFolder}'" - bat "powershell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command \"&.\\tools\\update_schema.ps1;${environment};&.\\run.cmd -CI default-build /p:Configuration=${params.Configuration}\"" + bat "powershell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command \"&.\\tools\\update_schema.ps1;&.\\tools\\UpdateIISExpressCertificate.ps1;${environment};&.\\run.cmd -CI default-build /p:Configuration=${params.Configuration}\"" } }