@@ -88,6 +88,22 @@ def test_service_registration(self):
8888 self .assertIn ('test-service' , self .consul .agent .services ())
8989 self .consul .agent .service .deregister ('test-service' )
9090
91+ def test_service_maintenance (self ):
92+ self .consul .agent .service .register (
93+ 'test-service' , address = '10.0.0.1' , port = 5672 , tags = ['foo' , 'bar' ])
94+ self .assertIn ('test-service' , self .consul .agent .services ())
95+ reason = 'Down for Acceptance'
96+ self .consul .agent .service .maintenance ('test-service' , reason = reason )
97+ node_in_maintenance = self .consul .catalog .nodes ()[0 ]['Node' ]
98+ health_check = self .consul .health .node (node_in_maintenance )
99+ self .assertEqual (len (health_check ), 2 )
100+ self .assertIn (reason , [check ['Notes' ] for check in health_check ])
101+ self .consul .agent .service .maintenance ('test-service' , enable = False )
102+ health_check = self .consul .health .node (node_in_maintenance )
103+ self .assertEqual (len (health_check ), 1 )
104+ self .assertNotEqual (reason , health_check [0 ]['Notes' ])
105+ self .consul .agent .service .deregister ('test-service' )
106+
91107 def test_token (self ):
92108 self .assertTrue (
93109 self .consul .agent .token ('acl_replication_token' , 'foo' ))
0 commit comments