mirror of
https://github.com/logos-messaging/logos-messaging-interop-tests.git
synced 2026-04-04 19:03:36 +00:00
timeout ad modification for node health to fix flaky tests
This commit is contained in:
parent
33596417e3
commit
bf76ee6544
@ -5,6 +5,7 @@ import random
|
||||
import re
|
||||
import shutil
|
||||
import string
|
||||
import time
|
||||
import pytest
|
||||
import requests
|
||||
from src.libs.common import delay
|
||||
@ -295,6 +296,30 @@ class WakuNode:
|
||||
check_healthy()
|
||||
check_ready()
|
||||
|
||||
def wait_for_connected(self, timeout=30):
|
||||
deadline = time.time() + timeout
|
||||
|
||||
while time.time() < deadline:
|
||||
try:
|
||||
raw = self.health()
|
||||
health = json.loads(raw) if isinstance(raw, (str, bytes)) else raw
|
||||
status = health.get("connectionStatus", "")
|
||||
|
||||
if status == "Connected":
|
||||
logger.debug("Node reached connectionStatus=Connected")
|
||||
return
|
||||
|
||||
except Exception as exc:
|
||||
logger.debug("Health poll failed ")
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
raise TimeoutError(f"Node did not reach connectionStatus='Connected' within {timeout}s.")
|
||||
|
||||
def get_node_health(self):
|
||||
raw = self.health()
|
||||
return json.loads(raw) if isinstance(raw, (str, bytes)) else raw
|
||||
|
||||
def get_id(self):
|
||||
try:
|
||||
return self.info_response["listenAddresses"][0].split("/")[-1]
|
||||
@ -517,7 +542,6 @@ class WakuNode:
|
||||
return self._container
|
||||
|
||||
def generate_random_nodekey(self):
|
||||
# Define the set of hexadecimal characters
|
||||
hex_chars = string.hexdigits.lower()
|
||||
# Generate a random 64-character string from the hex characters
|
||||
random_key = "".join(random.choice(hex_chars) for _ in range(64))
|
||||
|
||||
@ -22,12 +22,17 @@ class StepsCommon:
|
||||
if not hasattr(self, "test_content_topic"):
|
||||
self.test_content_topic = "/test/1/default/proto"
|
||||
|
||||
@allure.step
|
||||
def wait_for_node_connected(self, node, timeout=30):
|
||||
node.wait_for_connected(timeout=timeout)
|
||||
|
||||
@allure.step
|
||||
@retry(stop=stop_after_delay(20), wait=wait_fixed(0.5), reraise=True)
|
||||
def add_node_peer(self, node, multiaddr_list, shards=[0, 1, 2, 3, 4, 5, 6, 7, 8]):
|
||||
if node.is_nwaku():
|
||||
for multiaddr in multiaddr_list:
|
||||
node.add_peers([multiaddr])
|
||||
self.wait_for_node_connected(node)
|
||||
|
||||
@allure.step
|
||||
@retry(stop=stop_after_delay(70), wait=wait_fixed(1), reraise=True)
|
||||
|
||||
@ -75,9 +75,10 @@ class TestFilterSubscribeCreate(StepsFilter):
|
||||
assert not failed_content_topics, f"ContentTopics failed: {failed_content_topics}"
|
||||
try:
|
||||
self.create_filter_subscription({"requestId": "1", "contentFilters": ["rate limited"], "pubsubTopic": self.test_pubsub_topic})
|
||||
raise AssertionError("The 30th subscribe call was not rate limited!!!")
|
||||
except Exception as ex:
|
||||
assert "subscription failed" in str(ex) or "rate limit exceeded" in str(ex)
|
||||
else:
|
||||
raise AssertionError("Expected extra filter subscription to be rate limited, but it succeeded")
|
||||
|
||||
def test_filter_subscribe_to_101_content_topics(self, subscribe_main_nodes):
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user