@@ -287,6 +287,68 @@ def mock_get_nodes_with_service_critical(self, instance, service):
287
287
}
288
288
]
289
289
290
+ def mock_get_nodes_with_service_critical_in_maitenance (self , instance , service ):
291
+
292
+ return [
293
+ {
294
+ "Checks" : [
295
+ {
296
+ "CheckID" : "_node_maintenance" ,
297
+ "Name" : "Node Maintenance Mode" ,
298
+ "Node" : "node-1" ,
299
+ "Notes" : "" ,
300
+ "Output" : "" ,
301
+ "ServiceID" : service ,
302
+ "ServiceName" : "" ,
303
+ "Status" : "critical" ,
304
+ },
305
+ {
306
+ "CheckID" : "serfHealth" ,
307
+ "Name" : "Serf Health Status" ,
308
+ "Node" : "node-1" ,
309
+ "Notes" : "" ,
310
+ "Output" : "Agent alive and reachable" ,
311
+ "ServiceID" : "" ,
312
+ "ServiceName" : "" ,
313
+ "Status" : "passing"
314
+ },
315
+ {
316
+ "CheckID" : "service:{0}" .format (service ),
317
+ "Name" : "service check {0}" .format (service ),
318
+ "Node" : "node-1" ,
319
+ "Notes" : "" ,
320
+ "Output" : "Service {0} alive" .format (service ),
321
+ "ServiceID" : service ,
322
+ "ServiceName" : "" ,
323
+ "Status" : "warning"
324
+ },
325
+ {
326
+ "CheckID" : "service:{0}" .format (service ),
327
+ "Name" : "service check {0}" .format (service ),
328
+ "Node" : "node-1" ,
329
+ "Notes" : "" ,
330
+ "Output" : "Service {0} alive" .format (service ),
331
+ "ServiceID" : service ,
332
+ "ServiceName" : "" ,
333
+ "Status" : "critical"
334
+ }
335
+ ],
336
+ "Node" : {
337
+ "Address" : _get_random_ip (),
338
+ "Node" : "node-1"
339
+ },
340
+ "Service" : {
341
+ "Address" : "" ,
342
+ "ID" : service ,
343
+ "Port" : 80 ,
344
+ "Service" : service ,
345
+ "Tags" : [
346
+ "az-us-east-1a"
347
+ ]
348
+ }
349
+ }
350
+ ]
351
+
290
352
def mock_get_coord_datacenters (self , instance ):
291
353
return [{
292
354
"Datacenter" : "dc1" ,
@@ -500,6 +562,22 @@ def test_get_nodes_with_service_critical(self):
500
562
self .assertMetric ('consul.catalog.services_warning' , value = 0 , tags = ['consul_datacenter:dc1' , 'consul_node_id:node-1' ])
501
563
self .assertMetric ('consul.catalog.services_critical' , value = 6 , tags = ['consul_datacenter:dc1' , 'consul_node_id:node-1' ])
502
564
565
+ def test_get_nodes_with_service_critical_in_maintenance (self ):
566
+ my_mocks = self ._get_consul_mocks ()
567
+ my_mocks ['get_nodes_with_service' ] = self .mock_get_nodes_with_service_critical_in_maitenance
568
+
569
+ self .run_check (MOCK_CONFIG , mocks = my_mocks )
570
+ self .assertMetric ('consul.catalog.nodes_up' , value = 1 , tags = ['consul_datacenter:dc1' , 'consul_service_id:service-1' , 'consul_service-1_service_tag:az-us-east-1a' ])
571
+ self .assertMetric ('consul.catalog.nodes_passing' , value = 0 , tags = ['consul_datacenter:dc1' , 'consul_service_id:service-1' , 'consul_service-1_service_tag:az-us-east-1a' ])
572
+ self .assertMetric ('consul.catalog.nodes_warning' , value = 0 , tags = ['consul_datacenter:dc1' , 'consul_service_id:service-1' , 'consul_service-1_service_tag:az-us-east-1a' ])
573
+ self .assertMetric ('consul.catalog.nodes_critical' , value = 0 , tags = ['consul_datacenter:dc1' , 'consul_service_id:service-1' , 'consul_service-1_service_tag:az-us-east-1a' ])
574
+ self .assertMetric ('consul.catalog.nodes_maintenance' , value = 1 , tags = ['consul_datacenter:dc1' , 'consul_service_id:service-1' , 'consul_service-1_service_tag:az-us-east-1a' ])
575
+ self .assertMetric ('consul.catalog.services_up' , value = 6 , tags = ['consul_datacenter:dc1' , 'consul_node_id:node-1' ])
576
+ self .assertMetric ('consul.catalog.services_passing' , value = 0 , tags = ['consul_datacenter:dc1' , 'consul_node_id:node-1' ])
577
+ self .assertMetric ('consul.catalog.services_warning' , value = 0 , tags = ['consul_datacenter:dc1' , 'consul_node_id:node-1' ])
578
+ self .assertMetric ('consul.catalog.services_critical' , value = 0 , tags = ['consul_datacenter:dc1' , 'consul_node_id:node-1' ])
579
+ self .assertMetric ('consul.catalog.services_maintenance' , value = 6 , tags = ['consul_datacenter:dc1' , 'consul_node_id:node-1' ])
580
+
503
581
def test_service_checks (self ):
504
582
my_mocks = self ._get_consul_mocks ()
505
583
my_mocks ['consul_request' ] = self .mock_get_health_check
0 commit comments