22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
44using System ;
5+ using System . Reflection ;
56using System . Runtime . InteropServices ;
67using System . Threading . Tasks ;
78using Microsoft . AspNetCore . Testing ;
@@ -24,11 +25,16 @@ public GrpcTemplateTest(ProjectFactoryFixture projectFactory, ITestOutputHelper
2425 public ProjectFactoryFixture ProjectFactory { get ; }
2526 public ITestOutputHelper Output { get ; }
2627
27- [ ConditionalFact ( Skip = "This test run for over an hour" ) ]
28+ [ ConditionalFact ]
2829 [ SkipOnHelix ( "Not supported queues" , Queues = "Windows.7.Amd64;Windows.7.Amd64.Open;OSX.1014.Amd64;OSX.1014.Amd64.Open" ) ]
2930 [ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/19716" ) ]
3031 public async Task GrpcTemplate ( )
3132 {
33+ // Setup AssemblyTestLog
34+ var assemblyLog = AssemblyTestLog . Create ( Assembly . GetExecutingAssembly ( ) , baseDirectory : Project . ArtifactsLogDir ) ;
35+ using var testLog = assemblyLog . StartTestLog ( Output , nameof ( GrpcTemplateTest ) , out var loggerFactory ) ;
36+ var logger = loggerFactory . CreateLogger ( "TestLogger" ) ;
37+
3238 Project = await ProjectFactory . GetOrCreateProject ( "grpc" , Output ) ;
3339
3440 var createResult = await Project . RunDotNetNewAsync ( "grpc" ) ;
@@ -40,18 +46,24 @@ public async Task GrpcTemplate()
4046 var buildResult = await Project . RunDotNetBuildAsync ( ) ;
4147 Assert . True ( 0 == buildResult . ExitCode , ErrorMessages . GetFailedProcessMessage ( "build" , Project , buildResult ) ) ;
4248
43- using ( var serverProcess = Project . StartBuiltProjectAsync ( ) )
49+ var isOsx = RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ;
50+ var isWindowsOld = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) && Environment . OSVersion . Version < new Version ( 6 , 2 ) ;
51+ var unsupported = isOsx || isWindowsOld ;
52+
53+ using ( var serverProcess = Project . StartBuiltProjectAsync ( hasListeningUri : ! unsupported , logger : logger ) )
4454 {
4555 // These templates are HTTPS + HTTP/2 only which is not supported on Mac due to missing ALPN support.
4656 // https://github.com/dotnet/aspnetcore/issues/11061
47- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
57+ if ( isOsx )
4858 {
59+ serverProcess . Process . WaitForExit ( assertSuccess : false ) ;
4960 Assert . True ( serverProcess . Process . HasExited , "built" ) ;
5061 Assert . Contains ( "System.NotSupportedException: HTTP/2 over TLS is not supported on macOS due to missing ALPN support." ,
5162 ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run built service" , Project , serverProcess . Process ) ) ;
5263 }
53- else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) && Environment . OSVersion . Version < new Version ( 6 , 2 ) )
64+ else if ( isWindowsOld )
5465 {
66+ serverProcess . Process . WaitForExit ( assertSuccess : false ) ;
5567 Assert . True ( serverProcess . Process . HasExited , "built" ) ;
5668 Assert . Contains ( "System.NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support." ,
5769 ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run built service" , Project , serverProcess . Process ) ) ;
@@ -64,18 +76,20 @@ public async Task GrpcTemplate()
6476 }
6577 }
6678
67- using ( var aspNetProcess = Project . StartPublishedProjectAsync ( ) )
79+ using ( var aspNetProcess = Project . StartPublishedProjectAsync ( hasListeningUri : ! unsupported ) )
6880 {
6981 // These templates are HTTPS + HTTP/2 only which is not supported on Mac due to missing ALPN support.
7082 // https://github.com/dotnet/aspnetcore/issues/11061
71- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
83+ if ( isOsx )
7284 {
85+ aspNetProcess . Process . WaitForExit ( assertSuccess : false ) ;
7386 Assert . True ( aspNetProcess . Process . HasExited , "published" ) ;
7487 Assert . Contains ( "System.NotSupportedException: HTTP/2 over TLS is not supported on macOS due to missing ALPN support." ,
7588 ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run published service" , Project , aspNetProcess . Process ) ) ;
7689 }
77- else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) && Environment . OSVersion . Version < new Version ( 6 , 2 ) )
90+ else if ( isWindowsOld )
7891 {
92+ aspNetProcess . Process . WaitForExit ( assertSuccess : false ) ;
7993 Assert . True ( aspNetProcess . Process . HasExited , "published" ) ;
8094 Assert . Contains ( "System.NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support." ,
8195 ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run published service" , Project , aspNetProcess . Process ) ) ;
0 commit comments