@@ -152,27 +152,18 @@ public async Task RejectsConnectionsWhenLimitReached()
152
152
153
153
var measurements = connectionDuration . GetMeasurementSnapshot ( ) ;
154
154
155
- Assert . Collection ( measurements ,
156
- m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
157
- m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
158
- m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
159
- m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
160
- m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
161
- m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
162
- m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
163
- m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
164
- m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
165
- m => Assert . Equal ( KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) , m . Tags [ KestrelMetrics . ErrorType ] ) ,
166
- m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
167
- m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
168
- m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
169
- m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
170
- m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
171
- m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
172
- m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
173
- m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
174
- m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ,
175
- m => Assert . DoesNotContain ( KestrelMetrics . ErrorType , m . Tags . Keys ) ) ;
155
+ var connectionErrors = measurements
156
+ . GroupBy ( m =>
157
+ {
158
+ m . Tags . TryGetValue ( KestrelMetrics . ErrorType , out var value ) ;
159
+ return value as string ;
160
+ } )
161
+ . ToList ( ) ;
162
+
163
+ // 10 successful connections.
164
+ Assert . Equal ( 10 , connectionErrors . Single ( e => e . Key == null ) . Count ( ) ) ;
165
+ // 10 rejected connecitons.
166
+ Assert . Equal ( 10 , connectionErrors . Single ( e => e . Key == KestrelMetrics . GetErrorType ( ConnectionEndReason . MaxConcurrentConnectionsExceeded ) ) . Count ( ) ) ;
176
167
177
168
static void AssertCounter ( CollectedMeasurement < long > measurement ) => Assert . Equal ( 1 , measurement . Value ) ;
178
169
}
0 commit comments