File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
libraries/tests/e2e/functions/core/metrics/Function/test/Function.Tests Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -136,14 +136,32 @@ private async Task AssertCloudWatch()
136
136
]
137
137
} ;
138
138
139
- var response = await cloudWatchClient . ListMetricsAsync ( request ) ;
139
+ // retry n amount of times to ensure metrics are available
140
+ var response = new ListMetricsResponse ( ) ;
141
+ for ( int i = 0 ; i < 5 ; i ++ )
142
+ {
143
+ try
144
+ {
145
+ response = await cloudWatchClient . ListMetricsAsync ( request ) ;
146
+ if ( response . Metrics . Count > 6 )
147
+ {
148
+ break ;
149
+ }
150
+ }
151
+ catch ( Exception ex )
152
+ {
153
+ _testOutputHelper . WriteLine ( $ "Attempt { i + 1 } : Failed to list metrics: { ex . Message } ") ;
154
+ }
155
+
156
+ await Task . Delay ( 5000 ) ; // wait for 5 seconds before retrying
157
+ }
140
158
141
159
Assert . Equal ( 7 , response . Metrics . Count ) ;
142
160
143
161
foreach ( var metric in response . Metrics )
144
162
{
145
163
Assert . Equal ( "Test" , metric . Namespace ) ;
146
-
164
+
147
165
switch ( metric . MetricName )
148
166
{
149
167
case "ColdStart" :
You can’t perform that action at this time.
0 commit comments