@@ -19,13 +19,10 @@ public async Task AppHostRunsCleanly(string appHostPath)
19
19
var appHost = await DistributedApplicationTestFactory . CreateAsync ( appHostPath , testOutput ) ;
20
20
await using var app = await appHost . BuildAsync ( ) ;
21
21
22
- var appHostLogs = app . GetAppHostLogs ( ) ;
23
- var resourceLogs = app . GetResourceLogs ( ) ;
22
+ await app . StartAsync ( ) ;
23
+ await app . WaitForResources ( ) . WaitAsync ( TimeSpan . FromSeconds ( 30 ) ) ;
24
24
25
- await app . StartAsync ( waitForResourcesToStart : true ) ;
26
-
27
- EnsureNoErrors ( appHostLogs , appHostPath ) ;
28
- resourceLogs . EnsureNoErrors ( ShouldAssertErrorsForResource ) ;
25
+ app . EnsureNoErrorsLogged ( ) ;
29
26
30
27
await app . StopAsync ( ) ;
31
28
}
@@ -42,18 +39,16 @@ public async Task TestEndpointsReturnOk(TestEndpoints testEndpoints)
42
39
var projects = appHost . Resources . OfType < ProjectResource > ( ) ;
43
40
await using var app = await appHost . BuildAsync ( ) ;
44
41
45
- var appHostLogs = app . GetAppHostLogs ( ) ;
46
- var resourceLogs = app . GetResourceLogs ( ) ;
47
-
48
- await app . StartAsync ( waitForResourcesToStart : true ) ;
42
+ await app . StartAsync ( ) ;
43
+ await app . WaitForResources ( ) . WaitAsync ( TimeSpan . FromSeconds ( 30 ) ) ;
49
44
50
45
if ( testEndpoints . WaitForResources ? . Count > 0 )
51
46
{
52
47
// Wait until each resource transitions to the required state
53
48
var timeout = TimeSpan . FromMinutes ( 5 ) ;
54
49
foreach ( var ( ResourceName , TargetState ) in testEndpoints . WaitForResources )
55
50
{
56
- await app . WaitForResource ( ResourceName , TargetState , new CancellationTokenSource ( timeout ) . Token ) ;
51
+ await app . WaitForResource ( ResourceName , TargetState ) . WaitAsync ( timeout ) ;
57
52
}
58
53
}
59
54
@@ -75,10 +70,10 @@ public async Task TestEndpointsReturnOk(TestEndpoints testEndpoints)
75
70
. ConfigureHttpClient ( client => client . Timeout = Timeout . InfiniteTimeSpan )
76
71
. AddStandardResilienceHandler ( resilience =>
77
72
{
78
- resilience . TotalRequestTimeout . Timeout = TimeSpan . FromSeconds ( 300 ) ;
73
+ resilience . TotalRequestTimeout . Timeout = TimeSpan . FromSeconds ( 120 ) ;
79
74
resilience . AttemptTimeout . Timeout = TimeSpan . FromSeconds ( 60 ) ;
80
75
resilience . Retry . MaxRetryAttempts = 30 ;
81
- resilience . CircuitBreaker . SamplingDuration = TimeSpan . FromSeconds ( 300 ) ;
76
+ resilience . CircuitBreaker . SamplingDuration = resilience . AttemptTimeout . Timeout * 2 ;
82
77
} ) ;
83
78
} ) ;
84
79
@@ -105,37 +100,11 @@ public async Task TestEndpointsReturnOk(TestEndpoints testEndpoints)
105
100
}
106
101
}
107
102
108
- EnsureNoErrors ( appHostLogs , appHostPath ) ;
109
- resourceLogs . EnsureNoErrors ( ShouldAssertErrorsForResource ) ;
103
+ app . EnsureNoErrorsLogged ( ) ;
110
104
111
105
await app . StopAsync ( ) ;
112
106
}
113
107
114
- private static bool ShouldAssertErrorsForResource ( IResource resource )
115
- {
116
- return resource
117
- is
118
- // Container resources tend to write to stderr for various reasons so only assert projects and executables
119
- ( ProjectResource or ExecutableResource )
120
- // Node resources tend to have npm modules that write to stderr so ignore them
121
- and not NodeAppResource
122
- // Dapr resources write to stderr about deprecated --components-path flag
123
- && ! resource . Name . EndsWith ( "-dapr-cli" ) ;
124
- }
125
-
126
- private static void EnsureNoErrors ( LoggerLogStore appHostLogs , string appHostPath )
127
- {
128
- var appHostName = Path . GetFileNameWithoutExtension ( appHostPath ) ;
129
-
130
- // Container resources tend to write to stderr for various reasons.
131
- // Only assert errors for the app host and skip resources. Resources will be checked separately
132
- // in the resourceLogs above.
133
- // See also https://github.com/dotnet/aspire/issues/5094
134
-
135
- appHostLogs . EnsureNoErrors ( categoryName
136
- => ! categoryName . StartsWith ( $ "{ appHostName } .Resources.", StringComparison . Ordinal ) ) ;
137
- }
138
-
139
108
public static TheoryData < string > AppHostAssemblies ( )
140
109
{
141
110
var appHostAssemblies = GetSamplesAppHostAssemblyPaths ( ) ;
@@ -169,14 +138,17 @@ public static TheoryData<TestEndpoints> TestEndpoints() =>
169
138
new TestEndpoints ( "ClientAppsIntegration.AppHost" , new ( ) {
170
139
{ "apiservice" , [ "/alive" , "/health" , "/weatherforecast" ] }
171
140
} ) ,
141
+ new TestEndpoints ( "ContainerBuild.AppHost" , new ( ) {
142
+ { "ginapp" , [ "/" ] }
143
+ } ) ,
172
144
new TestEndpoints ( "DatabaseContainers.AppHost" , new ( ) {
173
145
{ "apiservice" , [ "/alive" , "/health" , "/todos" , "/todos/1" , "/catalog" , "/catalog/1" , "/addressbook" , "/addressbook/1" ] }
174
146
} ) ,
175
147
new TestEndpoints ( "DatabaseMigrations.AppHost" , new ( ) {
176
148
{ "api" , [ "/alive" , "/health" , "/" ] }
177
149
} )
178
150
{
179
- WaitForResources = [ new ( "migration" , " Finished" ) ]
151
+ WaitForResources = [ new ( "migration" , KnownResourceStates . Finished ) ]
180
152
} ,
181
153
new TestEndpoints ( "HealthChecksUI.AppHost" , new ( ) {
182
154
{ "apiservice" , [ "/alive" , "/health" , "/weatherforecast" ] } ,
0 commit comments