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()
136136 ]
137137 } ;
138138
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+ }
140158
141159 Assert . Equal ( 7 , response . Metrics . Count ) ;
142160
143161 foreach ( var metric in response . Metrics )
144162 {
145163 Assert . Equal ( "Test" , metric . Namespace ) ;
146-
164+
147165 switch ( metric . MetricName )
148166 {
149167 case "ColdStart" :
You can’t perform that action at this time.
0 commit comments