fix: check_healthy accepts both text and json response

This commit is contained in:
Roman 2024-05-08 16:24:30 +08:00
parent 13f8e70100
commit 9705029ead
No known key found for this signature in database
GPG Key ID: B8FE070B54E11B75
2 changed files with 10 additions and 1 deletions

View File

@ -26,7 +26,7 @@ class REST(BaseClient):
def health(self):
health_response = self.rest_call("get", "health")
return health_response.json()
return health_response.content
def get_peers(self):
get_peers_response = self.rest_call("get", "admin/v1/peers")

View File

@ -190,6 +190,15 @@ class WakuNode:
@retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(0.1), reraise=True)
def check_healthy(node=self):
self.health_response = node.health()
if self.health_response == b"Node is healthy":
logger.info("Node is healthy !!")
return
else:
try:
self.health_response = json.loads(self.health_response)
except Exception as ex:
raise AttributeError(f"Unknown health response format {ex}")
if self.health_response["nodeHealth"] and self.health_response["nodeHealth"] != "Ready":
raise AssertionError("Waiting for the node health status: Ready")