small fixes (#20)

* small fixes

* adjustments

* xfail test
This commit is contained in:
Florin Barbu 2024-03-07 14:36:53 +02:00 committed by GitHub
parent 7df4741a36
commit dd140dcb74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 12 deletions

View File

@ -19,6 +19,10 @@ class REST(BaseClient):
info_response = self.rest_call("get", "debug/v1/info")
return info_response.json()
def get_peers(self):
info_response = self.rest_call("get", "admin/v1/peers")
return info_response.json()
def set_relay_subscriptions(self, pubsub_topics):
return self.rest_call("post", "relay/v1/subscriptions", json.dumps(pubsub_topics))

View File

@ -209,6 +209,9 @@ class WakuNode:
def info(self):
return self._api.info()
def get_peers(self):
return self._api.get_peers()
def set_relay_subscriptions(self, pubsub_topics):
return self._api.set_relay_subscriptions(pubsub_topics)

View File

@ -71,7 +71,7 @@ class StepsFilter:
else:
pytest.skip("ADDITIONAL_NODES/node_list is empty, cannot run test")
for index, node in enumerate(nodes):
node = WakuNode(node, f"additional_node{index + 1}_{self.test_id}")
node = WakuNode(node, f"node{index + 3}_{self.test_id}")
node.start(relay="false", filter="true", discv5_bootstrap_node=self.enr_uri, filternode=self.multiaddr_with_id)
self.optional_nodes.append(node)
@ -91,9 +91,9 @@ class StepsFilter:
sender.send_relay_message(message, pubsub_topic)
delay(message_propagation_delay)
for index, peer in enumerate(peer_list):
logger.debug(f"Checking that peer NODE_{index + 1}:{peer.image} can find the published message")
logger.debug(f"Checking that peer NODE_{index + 2}:{peer.image} can find the published message")
get_messages_response = self.get_filter_messages(message["contentTopic"], pubsub_topic=pubsub_topic, node=peer)
assert get_messages_response, f"Peer NODE_{index + 1}:{peer.image} couldn't find any messages"
assert get_messages_response, f"Peer NODE_{index + 2}:{peer.image} couldn't find any messages"
assert len(get_messages_response) == 1, f"Expected 1 message but got {len(get_messages_response)}"
waku_message = WakuMessage(get_messages_response)
waku_message.assert_received_message(message)
@ -107,11 +107,13 @@ class StepsFilter:
assert "Bad Request" in str(ex) or "Not Found" in str(ex) or "couldn't find any messages" in str(ex)
@allure.step
def wait_for_published_message_to_reach_filter_peer(self, timeout_duration=120, time_between_retries=1, pubsub_topic=None, peer_list=None):
def wait_for_published_message_to_reach_filter_peer(
self, timeout_duration=120, time_between_retries=1, pubsub_topic=None, sender=None, peer_list=None
):
@retry(stop=stop_after_delay(timeout_duration), wait=wait_fixed(time_between_retries), reraise=True)
def publish_and_check_filter_peer():
message = {"payload": to_base64(self.test_payload), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)}
self.check_publish_without_filter_subscription(message, pubsub_topic=pubsub_topic, peer_list=peer_list)
self.check_published_message_reaches_filter_peer(message, pubsub_topic=pubsub_topic, sender=sender, peer_list=peer_list)
publish_and_check_filter_peer()

View File

@ -57,10 +57,12 @@ class StepsRelay:
def setup_main_rln_relay_nodes(self, request):
logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}")
self.node1 = WakuNode(DEFAULT_NWAKU, f"node1_{request.cls.test_id}")
self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1")
self.node1.start(relay="true", nodekey=NODEKEY, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="1", rln_relay_membership_index="1")
self.enr_uri = self.node1.get_enr_uri()
self.node2 = WakuNode(DEFAULT_NWAKU, f"node2_{request.cls.test_id}")
self.node2.start(relay="true", discv5_bootstrap_node=self.enr_uri, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2")
self.node2.start(
relay="true", discv5_bootstrap_node=self.enr_uri, rln_creds_source=RLN_CREDENTIALS, rln_creds_id="2", rln_relay_membership_index="1"
)
self.main_nodes.extend([self.node1, self.node2])
@pytest.fixture(scope="function")
@ -71,7 +73,7 @@ class StepsRelay:
else:
pytest.skip("ADDITIONAL_NODES is empty, cannot run test")
for index, node in enumerate(nodes):
node = WakuNode(node, f"additional_node{index}_{request.cls.test_id}")
node = WakuNode(node, f"node{index + 3}_{request.cls.test_id}")
node.start(relay="true", discv5_bootstrap_node=self.enr_uri)
self.optional_nodes.append(node)
@ -109,9 +111,9 @@ class StepsRelay:
sender.send_relay_message(message, pubsub_topic)
delay(message_propagation_delay)
for index, peer in enumerate(peer_list):
logger.debug(f"Checking that peer NODE_{index + 1}:{peer.image} can find the published message")
logger.debug(f"Checking that peer NODE_{index + 2}:{peer.image} can find the published message")
get_messages_response = peer.get_relay_messages(pubsub_topic)
assert get_messages_response, f"Peer NODE_{index + 1}:{peer.image} couldn't find any messages"
assert get_messages_response, f"Peer NODE_{index + 2}:{peer.image} couldn't find any messages"
assert len(get_messages_response) == 1, f"Expected 1 message but got {len(get_messages_response)}"
waku_message = WakuMessage(get_messages_response)
waku_message.assert_received_message(message)

View File

@ -1,5 +1,5 @@
import pytest
from src.env_vars import NODE_1
from src.env_vars import NODE_1, NODE_2
from src.libs.common import delay
from src.libs.custom_logger import get_custom_logger
from src.steps.filter import StepsFilter
@ -9,11 +9,12 @@ logger = get_custom_logger(__name__)
@pytest.mark.usefixtures("setup_main_relay_node", "setup_main_filter_node")
class TestFilterMultipleNodes(StepsFilter):
@pytest.mark.xfail("nwaku" in NODE_2, reason="Bug reported: https://github.com/waku-org/nwaku/issues/2512")
def test_all_nodes_subscribed_to_the_topic(self):
self.setup_optional_filter_nodes()
self.wait_for_subscriptions_on_main_nodes([self.test_content_topic])
self.subscribe_optional_filter_nodes([self.test_content_topic])
self.wait_for_published_message_to_reach_filter_peer()
self.check_published_message_reaches_filter_peer()
def test_optional_nodes_not_subscribed_to_same_topic(self):
self.setup_optional_filter_nodes()