test: health endpoint response parsing

This commit is contained in:
Roman 2024-05-07 19:48:13 +08:00
parent 900e66db36
commit c8731b7364
No known key found for this signature in database
GPG Key ID: B8FE070B54E11B75
3 changed files with 14 additions and 8 deletions

View File

@ -25,8 +25,8 @@ class REST(BaseClient):
return info_response.json()
def health(self):
health_response = self.rest_call_text("get", "health")
return health_response.text()
health_response = self.rest_call("get", "health")
return health_response.json()
def get_peers(self):
get_peers_response = self.rest_call("get", "admin/v1/peers")

View File

@ -188,17 +188,24 @@ class WakuNode:
def ensure_ready(self, timeout_duration=10):
@retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(0.1), reraise=True)
def check_healthy(node=self):
self.health_response = node.health()
h = json.loads(self.health_response)
if h["nodeHealth"] and h["nodeHealth"] != "Ready":
raise AssertionError("Waiting for the node health status: Ready")
if h["protocolsHealth"] and h["protocolsHealth"]["Rln Relay"] != "Ready":
raise AssertionError("Waiting for the Rln Relay status: Ready")
logger.info("Node protocols are initialized !!")
@retry(stop=stop_after_delay(5), wait=wait_fixed(0.1), reraise=True)
def check_ready(node=self):
node.info_response = node.info()
logger.info("REST service is ready !!")
check_healthy()
check_ready()
@retry(stop=stop_after_delay(10), wait=wait_fixed(1), reraise=True)
def ensure_healthy(self):
self.health_response = self.health()
logger.info("Node is healthy !!")
def get_enr_uri(self):
try:
return self.info_response["enrUri"]

View File

@ -104,7 +104,6 @@ class TestRelayRLN(StepsRLN, StepsRelay):
failed_payloads.append(payload["description"])
assert not failed_payloads, f"Payloads failed: {failed_payloads}"
@pytest.mark.skip(reason="exceeding timeout, waiting for https://github.com/waku-org/nwaku/pull/2612 to be part of the release")
@pytest.mark.timeout(600)
def test_valid_payloads_dynamic_at_slow_rate(self):
self.setup_main_rln_relay_nodes(rln_relay_dynamic="true", wait_for_node_sec=600)