2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
4
using System ;
5
+ using System . Reflection ;
5
6
using System . Runtime . InteropServices ;
6
7
using System . Threading . Tasks ;
7
8
using Microsoft . AspNetCore . Testing ;
@@ -24,11 +25,16 @@ public GrpcTemplateTest(ProjectFactoryFixture projectFactory, ITestOutputHelper
24
25
public ProjectFactoryFixture ProjectFactory { get ; }
25
26
public ITestOutputHelper Output { get ; }
26
27
27
- [ ConditionalFact ( Skip = "This test run for over an hour" ) ]
28
+ [ ConditionalFact ]
28
29
[ SkipOnHelix ( "Not supported queues" , Queues = "Windows.7.Amd64;Windows.7.Amd64.Open;OSX.1014.Amd64;OSX.1014.Amd64.Open" ) ]
29
30
[ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/19716" ) ]
30
31
public async Task GrpcTemplate ( )
31
32
{
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
+
32
38
Project = await ProjectFactory . GetOrCreateProject ( "grpc" , Output ) ;
33
39
34
40
var createResult = await Project . RunDotNetNewAsync ( "grpc" ) ;
@@ -40,18 +46,24 @@ public async Task GrpcTemplate()
40
46
var buildResult = await Project . RunDotNetBuildAsync ( ) ;
41
47
Assert . True ( 0 == buildResult . ExitCode , ErrorMessages . GetFailedProcessMessage ( "build" , Project , buildResult ) ) ;
42
48
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 ) )
44
54
{
45
55
// These templates are HTTPS + HTTP/2 only which is not supported on Mac due to missing ALPN support.
46
56
// https://github.com/dotnet/aspnetcore/issues/11061
47
- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
57
+ if ( isOsx )
48
58
{
59
+ serverProcess . Process . WaitForExit ( assertSuccess : false ) ;
49
60
Assert . True ( serverProcess . Process . HasExited , "built" ) ;
50
61
Assert . Contains ( "System.NotSupportedException: HTTP/2 over TLS is not supported on macOS due to missing ALPN support." ,
51
62
ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run built service" , Project , serverProcess . Process ) ) ;
52
63
}
53
- else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) && Environment . OSVersion . Version < new Version ( 6 , 2 ) )
64
+ else if ( isWindowsOld )
54
65
{
66
+ serverProcess . Process . WaitForExit ( assertSuccess : false ) ;
55
67
Assert . True ( serverProcess . Process . HasExited , "built" ) ;
56
68
Assert . Contains ( "System.NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support." ,
57
69
ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run built service" , Project , serverProcess . Process ) ) ;
@@ -64,18 +76,20 @@ public async Task GrpcTemplate()
64
76
}
65
77
}
66
78
67
- using ( var aspNetProcess = Project . StartPublishedProjectAsync ( ) )
79
+ using ( var aspNetProcess = Project . StartPublishedProjectAsync ( hasListeningUri : ! unsupported ) )
68
80
{
69
81
// These templates are HTTPS + HTTP/2 only which is not supported on Mac due to missing ALPN support.
70
82
// https://github.com/dotnet/aspnetcore/issues/11061
71
- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
83
+ if ( isOsx )
72
84
{
85
+ aspNetProcess . Process . WaitForExit ( assertSuccess : false ) ;
73
86
Assert . True ( aspNetProcess . Process . HasExited , "published" ) ;
74
87
Assert . Contains ( "System.NotSupportedException: HTTP/2 over TLS is not supported on macOS due to missing ALPN support." ,
75
88
ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run published service" , Project , aspNetProcess . Process ) ) ;
76
89
}
77
- else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) && Environment . OSVersion . Version < new Version ( 6 , 2 ) )
90
+ else if ( isWindowsOld )
78
91
{
92
+ aspNetProcess . Process . WaitForExit ( assertSuccess : false ) ;
79
93
Assert . True ( aspNetProcess . Process . HasExited , "published" ) ;
80
94
Assert . Contains ( "System.NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support." ,
81
95
ErrorMessages . GetFailedProcessMessageOrEmpty ( "Run published service" , Project , aspNetProcess . Process ) ) ;
0 commit comments