mirror of
https://github.com/logos-messaging/logos-messaging-interop-tests.git
synced 2026-01-07 00:13:06 +00:00
add more tests
This commit is contained in:
parent
37c0cbb94b
commit
5b803ba0c3
@ -18,13 +18,13 @@ class BaseClient(ABC):
|
||||
try:
|
||||
response.raise_for_status()
|
||||
except requests.HTTPError as http_err:
|
||||
logger.error("HTTP error occurred: %s", http_err)
|
||||
logger.error("HTTP error occurred: %s. Response content: %s", http_err, response.content)
|
||||
raise
|
||||
except Exception as err:
|
||||
logger.error("An error occurred: %s", err)
|
||||
logger.error("An error occurred: %s. Response content: %s", err, response.content)
|
||||
raise
|
||||
else:
|
||||
logger.info("Response status code: %s", response.status_code)
|
||||
logger.info("Response status code: %s. Response content: %s", response.status_code, response.content)
|
||||
return response
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@ -44,6 +44,7 @@ class WakuNode:
|
||||
"rest-admin": "true",
|
||||
"websocket-support": "true",
|
||||
"log-level": "TRACE",
|
||||
"rest-relay-cache-capacity": "100",
|
||||
"websocket-port": str(self._ports[3]),
|
||||
"rpc-port": self._rpc_port,
|
||||
"rest-port": self._rest_port,
|
||||
|
||||
@ -52,12 +52,8 @@ class StepsRelay:
|
||||
def assert_fail_message(field_name):
|
||||
return f"Incorrect field: {field_name}. Published: {sent_message[field_name]} Received: {getattr(received_message, field_name)}"
|
||||
|
||||
assert (
|
||||
received_message.payload == sent_message["payload"]
|
||||
), f'Incorrect payload. Published {sent_message["payload"]} Received {received_message.payload}'
|
||||
assert (
|
||||
received_message.contentTopic == sent_message["contentTopic"]
|
||||
), f'Incorrect contentTopic. Published {sent_message["contentTopic"]} Received {received_message.contentTopic}'
|
||||
assert received_message.payload == sent_message["payload"], assert_fail_message("payload")
|
||||
assert received_message.contentTopic == sent_message["contentTopic"], assert_fail_message("contentTopic")
|
||||
if "timestamp" in sent_message and sent_message["timestamp"]:
|
||||
if isinstance(sent_message["timestamp"], float):
|
||||
assert math.isclose(float(received_message.timestamp), sent_message["timestamp"], rel_tol=1e-9), assert_fail_message("timestamp")
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
from time import time
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from src.env_vars import DEFAULT_PUBSUBTOPIC
|
||||
|
||||
NOW = datetime.now()
|
||||
|
||||
SAMPLE_INPUTS = [
|
||||
@ -63,6 +65,18 @@ INVALID_CONTENT_TOPICS = [
|
||||
{"description": "A bool", "value": True},
|
||||
]
|
||||
|
||||
VALID_PUBSUB_TOPICS = [
|
||||
DEFAULT_PUBSUBTOPIC,
|
||||
"/waku/2/rs/18/1",
|
||||
"/test/2/rs/18/1",
|
||||
"/waku/3/rs/18/1",
|
||||
"/waku/2/test/18/1",
|
||||
"/waku/2/rs/66/1",
|
||||
"/waku/2/rs/18/50",
|
||||
"/waku/18/50",
|
||||
"test",
|
||||
]
|
||||
|
||||
|
||||
SAMPLE_TIMESTAMPS = [
|
||||
{"description": "Now", "value": int(time() * 1e9), "valid_for": ["nwaku", "gowaku"]},
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
from src.libs.custom_logger import get_custom_logger
|
||||
from time import time
|
||||
from src.libs.common import to_base64
|
||||
from src.libs.common import delay, to_base64
|
||||
from src.steps.relay import StepsRelay
|
||||
from src.test_data import INVALID_CONTENT_TOPICS, INVALID_PAYLOADS, SAMPLE_INPUTS, SAMPLE_TIMESTAMPS
|
||||
from src.test_data import INVALID_CONTENT_TOPICS, INVALID_PAYLOADS, SAMPLE_INPUTS, SAMPLE_TIMESTAMPS, VALID_PUBSUB_TOPICS
|
||||
|
||||
logger = get_custom_logger(__name__)
|
||||
|
||||
@ -89,6 +89,20 @@ class TestRelayPublish(StepsRelay):
|
||||
except Exception as ex:
|
||||
assert "Bad Request" in str(ex) or "Internal Server Error" in str(ex)
|
||||
|
||||
def test_publish_on_multiple_pubsub_topics(self):
|
||||
self.node1.set_subscriptions(VALID_PUBSUB_TOPICS)
|
||||
self.node2.set_subscriptions(VALID_PUBSUB_TOPICS)
|
||||
failed_pubsub_topics = []
|
||||
for pubsub_topic in VALID_PUBSUB_TOPICS:
|
||||
logger.debug("Running test with pubsub topic %s", pubsub_topic)
|
||||
first_message = {"payload": to_base64("M1"), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)}
|
||||
try:
|
||||
self.check_published_message_reaches_peer(first_message, pubsub_topic=pubsub_topic)
|
||||
except Exception as e:
|
||||
logger.error("PubusubTopic %s failed: %s", pubsub_topic, str(e))
|
||||
failed_pubsub_topics.append(pubsub_topic)
|
||||
assert not failed_pubsub_topics, f"PubusubTopic failed: {failed_pubsub_topics}"
|
||||
|
||||
def test_publish_on_unsubscribed_pubsub_topic(self):
|
||||
try:
|
||||
self.check_published_message_reaches_peer(self.test_message, pubsub_topic="/waku/2/rs/19/1")
|
||||
@ -206,3 +220,16 @@ class TestRelayPublish(StepsRelay):
|
||||
self.node1.set_subscriptions([self.test_pubsub_topic])
|
||||
self.node2.set_subscriptions([self.test_pubsub_topic])
|
||||
self.wait_for_published_message_to_reach_peer(20)
|
||||
|
||||
def test_publish_and_retrieve_100_messages(self):
|
||||
num_messages = 100 # if increase this number make sure to also increase rest-relay-cache-capacity flag
|
||||
for index in range(num_messages):
|
||||
message = {"payload": to_base64(f"M_{index}"), "contentTopic": self.test_content_topic, "timestamp": int(time() * 1e9)}
|
||||
self.node1.send_message(message, self.test_pubsub_topic)
|
||||
delay(1)
|
||||
messages = self.node2.get_messages(self.test_pubsub_topic)
|
||||
assert len(messages) == num_messages
|
||||
for index, message in enumerate(messages):
|
||||
assert message["payload"] == to_base64(
|
||||
f"M_{index}"
|
||||
), f'Incorrect payload at index: {index}. Published {to_base64(f"M_{index}")} Received {message["payload"]}'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user