34
34
35
35
import static org .apache .flink .kubernetes .operator .metrics .FlinkDeploymentMetrics .COUNTER_NAME ;
36
36
import static org .apache .flink .kubernetes .operator .metrics .FlinkDeploymentMetrics .CPU_NAME ;
37
+ import static org .apache .flink .kubernetes .operator .metrics .FlinkDeploymentMetrics .FLINK_MINOR_VERSION_GROUP_NAME ;
37
38
import static org .apache .flink .kubernetes .operator .metrics .FlinkDeploymentMetrics .FLINK_VERSION_GROUP_NAME ;
38
39
import static org .apache .flink .kubernetes .operator .metrics .FlinkDeploymentMetrics .MEMORY_NAME ;
39
40
import static org .apache .flink .kubernetes .operator .metrics .FlinkDeploymentMetrics .RESOURCE_USAGE_GROUP_NAME ;
@@ -226,13 +227,14 @@ public void testMetricsMultiNamespace() {
226
227
public void testFlinkVersionMetrics () {
227
228
Map <String , String > ns1Values = new HashMap <>();
228
229
ns1Values .put ("deployment1" , " " );
229
- ns1Values .put ("deployment2" , "1.14" );
230
- ns1Values .put ("deployment3" , "1.14" );
231
- ns1Values .put ("deployment4" , "1.15" );
232
- ns1Values .put ("deployment5" , "1.15" );
233
- ns1Values .put ("deployment6" , "1.16" );
234
- ns1Values .put ("deployment7" , "1.17" );
235
- ns1Values .put ("deployment8" , "1.14" );
230
+ ns1Values .put ("deployment2" , "1.14.0" );
231
+ ns1Values .put ("deployment3" , "1.14.0" );
232
+ ns1Values .put ("deployment4" , "1.15.1" );
233
+ ns1Values .put ("deployment5" , "1.15.1" );
234
+ ns1Values .put ("deployment6" , "1.16.0" );
235
+ ns1Values .put ("deployment7" , "1.17.1" );
236
+ ns1Values .put ("deployment8" , "1.14.1" );
237
+ ns1Values .put ("deployment9" , "test" );
236
238
237
239
Map <String , String > ns2Values = new HashMap <>();
238
240
ns2Values .put ("deployment1" , "" );
@@ -248,20 +250,41 @@ public void testFlinkVersionMetrics() {
248
250
var namespaceVersions = Map .of ("ns1" , ns1Values , "ns2" , ns2Values );
249
251
var expected =
250
252
Map .of (
251
- "ns1" , Map .of ("UNKNOWN" , 1 , "1.14" , 3 , "1.15" , 2 , "1.16" , 1 , "1.17" , 1 ),
253
+ "ns1" ,
254
+ Map .of (
255
+ "UNKNOWN" , 1 , "1.14.0" , 2 , "1.14.1" , 1 , "1.15.1" , 2 ,
256
+ "1.16.0" , 1 , "1.17.1" , 1 , "test" , 1 ),
252
257
"ns2" , Map .of ("UNKNOWN" , 2 , "1.14" , 2 , "1.15" , 3 , "1.16" , 1 , "1.17" , 1 ));
253
- updateFlinkVersionsAndAssert (namespaceVersions , expected );
258
+ updateFlinkVersionsAndAssert (FLINK_VERSION_GROUP_NAME , namespaceVersions , expected );
254
259
255
- // Remove invalid version and insert 1.14
256
- namespaceVersions .get ("ns1" ).put ("deployment1" , "1.14" );
260
+ var expectedMinors =
261
+ Map .of (
262
+ "ns1" , Map .of ("MALFORMED" , 2 , "1.14" , 3 , "1.15" , 2 , "1.16" , 1 , "1.17" , 1 ),
263
+ "ns2" , Map .of ("MALFORMED" , 2 , "1.14" , 2 , "1.15" , 3 , "1.16" , 1 , "1.17" , 1 ));
264
+ updateFlinkVersionsAndAssert (
265
+ FLINK_MINOR_VERSION_GROUP_NAME , namespaceVersions , expectedMinors );
266
+
267
+ // Remove invalid version and insert 1.14.1
268
+ namespaceVersions .get ("ns1" ).put ("deployment1" , "1.14.1" );
257
269
expected =
258
270
Map .of (
259
- "ns1" , Map .of ("UNKNOWN" , 0 , "1.14" , 4 , "1.15" , 2 , "1.16" , 1 , "1.17" , 1 ),
271
+ "ns1" ,
272
+ Map .of (
273
+ "1.14.0" , 2 , "1.14.1" , 2 , "1.15.1" , 2 , "1.16.0" , 1 ,
274
+ "1.17.1" , 1 , "test" , 1 ),
260
275
"ns2" , Map .of ("UNKNOWN" , 2 , "1.14" , 2 , "1.15" , 3 , "1.16" , 1 , "1.17" , 1 ));
261
- updateFlinkVersionsAndAssert (namespaceVersions , expected );
276
+ updateFlinkVersionsAndAssert (FLINK_VERSION_GROUP_NAME , namespaceVersions , expected );
277
+
278
+ expectedMinors =
279
+ Map .of (
280
+ "ns1" , Map .of ("MALFORMED" , 1 , "1.14" , 4 , "1.15" , 2 , "1.16" , 1 , "1.17" , 1 ),
281
+ "ns2" , Map .of ("MALFORMED" , 2 , "1.14" , 2 , "1.15" , 3 , "1.16" , 1 , "1.17" , 1 ));
282
+ updateFlinkVersionsAndAssert (
283
+ FLINK_MINOR_VERSION_GROUP_NAME , namespaceVersions , expectedMinors );
262
284
}
263
285
264
286
private void updateFlinkVersionsAndAssert (
287
+ String metricGroup ,
265
288
Map <String , Map <String , String >> namespaceVersions ,
266
289
Map <String , Map <String , Integer >> expected ) {
267
290
for (var namespaceEntry : namespaceVersions .entrySet ()) {
@@ -291,7 +314,7 @@ private void updateFlinkVersionsAndAssert(
291
314
listener .getNamespaceMetricId (
292
315
FlinkDeployment .class ,
293
316
namespaceName ,
294
- FLINK_VERSION_GROUP_NAME ,
317
+ metricGroup ,
295
318
version ,
296
319
COUNTER_NAME );
297
320
0 commit comments