mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-08-10 22:03:19 +00:00
* test(e2e): port remaining wrapper tests from the interop repo The wrapper suite that moved into tests-e2e (#4027) was a reworked subset of the one still living in logos-delivery-interop-tests. Comparing both sides showed 21 tests here against 46 there, with no overlap in the delta: the 25 missing tests cover scenarios the reworked set never included. Ports those 25 tests, bringing the in-repo suite to the full 46: - 12 send scenarios: s01 (nil/destroyed handle), s03, s04, s05, s11, s13, s16, s18 (both orderings), s25, s29 - 7 channel lifecycle tests (rc01-rc04) - 6 wrapper corner cases: auto port allocation, MyBoundPorts, ENR Supporting changes the ported tests need: - wrapper_helpers: get_node_tcp_port, get_node_bound_ports, enr_udp_port - WrapperManager: channel_create/send/close, destroy_keep_ctx - vendored binding refreshed to the revision exposing the channel API (additive only; cffi resolves symbols lazily, so nothing existing moves) Two Edge senders were fixed while porting. build_node_config defaults relay and store to True, and the flat-JSON config path applies mode=Edge before explicit fields, so those defaults win: the Edge nodes in s11/s16/s25 came up as relay and store servers and exercised the relay path instead of lightpush. They now set relay=False and store=False, matching test_send_e2e_part2. s16 also dropped lightpush=True, which mounts the lightpush server and fails node start once relay is off; the lightpush client mounts unconditionally. Suite goes from 21 to 46 functions (53 collected). The docker subset grows from 3 to 5 as s11 and s25 need a store peer. Local run against a freshly built library: 45 passed, 2 skipped, 1 xfailed. * test(e2e): enable autosharding in the channel lifecycle tests channel_create subscribes to the channel's content topic since #4081, and resolving that topic to a shard needs autosharding. build_node_config leaves numShardsInNetwork at 0 and cluster 198 has no preset, so these nodes came up with static sharding and every channel_create failed with "autosharding is not configured; pass an explicit shard". Adds numShardsInNetwork=1 to the six tests that create a channel, matching what every other wrapper test that touches the send or channel API already does. rc02 is left alone: channel_send rejects on the id lookup before any shard is resolved. Verified locally against a fresh build: the five tests that complete now pass and the error string is gone from the run.
118 lines
5.0 KiB
Python
118 lines
5.0 KiB
Python
from src.steps.common import StepsCommon
|
|
from src.libs.common import to_base64
|
|
from src.node.wrappers_manager import WrapperManager
|
|
from src.node.wrapper_helpers import (
|
|
EventCollector,
|
|
assert_event_invariants,
|
|
create_message_bindings,
|
|
get_node_multiaddr,
|
|
wait_for_connected,
|
|
wait_for_propagated,
|
|
wait_for_error,
|
|
)
|
|
from src.test_data import CONTENT_TOPICS_DIFFERENT_SHARDS
|
|
|
|
|
|
PROPAGATED_TIMEOUT_S = 30.0
|
|
|
|
|
|
class TestS29SendOnTopicsMappingToDifferentShards(StepsCommon):
|
|
"""
|
|
S29 — Send on two different content topics that map to different shards.
|
|
Sender has a relay peer reachable on shard X and shard Y; topic A maps to
|
|
shard X and topic B maps to shard Y. Two independent sends, one per topic.
|
|
Expected: both sends return Ok(RequestId), and each request gets its own
|
|
message_propagated event following the availability of its own shard.
|
|
Purpose: ensures shard derivation and delivery behavior are topic-specific.
|
|
"""
|
|
|
|
# Topic A -> shard 0, Topic B -> shard 1 (per CONTENT_TOPICS_DIFFERENT_SHARDS).
|
|
TOPIC_A = CONTENT_TOPICS_DIFFERENT_SHARDS[0]
|
|
TOPIC_B = CONTENT_TOPICS_DIFFERENT_SHARDS[1]
|
|
|
|
def test_s29_send_on_topics_mapping_to_different_shards(self, node_config):
|
|
sender_collector = EventCollector()
|
|
|
|
# numShardsInNetwork=8 so the two topics resolve to distinct shards
|
|
# (shard 0 and shard 1) instead of being collapsed onto shard 0.
|
|
node_config.update(
|
|
{
|
|
"relay": True,
|
|
"store": False,
|
|
"lightpush": False,
|
|
"filter": False,
|
|
"discv5Discovery": False,
|
|
"numShardsInNetwork": 8,
|
|
"reliabilityEnabled": True,
|
|
}
|
|
)
|
|
|
|
sender_result = WrapperManager.create_and_start(
|
|
config=node_config,
|
|
event_cb=sender_collector.event_callback,
|
|
)
|
|
assert sender_result.is_ok(), f"Failed to start sender: {sender_result.err()}"
|
|
|
|
with sender_result.ok_value as sender:
|
|
peer_config = {
|
|
**node_config,
|
|
"staticnodes": [get_node_multiaddr(sender)],
|
|
"portsShift": 1,
|
|
}
|
|
|
|
peer_result = WrapperManager.create_and_start(config=peer_config)
|
|
assert peer_result.is_ok(), f"Failed to start relay peer: {peer_result.err()}"
|
|
|
|
with peer_result.ok_value:
|
|
assert wait_for_connected(sender_collector) is not None, "Sender did not reach Connected/PartiallyConnected state"
|
|
|
|
message_a = create_message_bindings(
|
|
payload=to_base64("S29 shard X payload"),
|
|
contentTopic=self.TOPIC_A,
|
|
)
|
|
send_a = sender.send_message(message=message_a)
|
|
assert send_a.is_ok(), f"send() on TOPIC_A failed: {send_a.err()}"
|
|
request_id_a = send_a.ok_value
|
|
assert request_id_a, "send() on TOPIC_A returned an empty RequestId"
|
|
|
|
# Send on topic B (shard Y).
|
|
message_b = create_message_bindings(
|
|
payload=to_base64("S29 shard Y payload"),
|
|
contentTopic=self.TOPIC_B,
|
|
)
|
|
send_b = sender.send_message(message=message_b)
|
|
assert send_b.is_ok(), f"send() on TOPIC_B failed: {send_b.err()}"
|
|
request_id_b = send_b.ok_value
|
|
assert request_id_b, "send() on TOPIC_B returned an empty RequestId"
|
|
|
|
assert request_id_a != request_id_b, "Each send must produce a distinct RequestId"
|
|
|
|
# Each request propagates over its own shard's mesh independently.
|
|
propagated_a = wait_for_propagated(
|
|
collector=sender_collector,
|
|
request_id=request_id_a,
|
|
timeout_s=PROPAGATED_TIMEOUT_S,
|
|
)
|
|
assert propagated_a is not None, (
|
|
f"No message_propagated event for TOPIC_A within {PROPAGATED_TIMEOUT_S}s. " f"Collected events: {sender_collector.events}"
|
|
)
|
|
assert propagated_a["requestId"] == request_id_a
|
|
|
|
propagated_b = wait_for_propagated(
|
|
collector=sender_collector,
|
|
request_id=request_id_b,
|
|
timeout_s=PROPAGATED_TIMEOUT_S,
|
|
)
|
|
assert propagated_b is not None, (
|
|
f"No message_propagated event for TOPIC_B within {PROPAGATED_TIMEOUT_S}s. " f"Collected events: {sender_collector.events}"
|
|
)
|
|
assert propagated_b["requestId"] == request_id_b
|
|
|
|
# No cross-talk: neither request should produce an error.
|
|
for request_id in (request_id_a, request_id_b):
|
|
error = wait_for_error(sender_collector, request_id, timeout_s=0)
|
|
assert error is None, f"Unexpected message_error event for {request_id}: {error}"
|
|
|
|
assert_event_invariants(sender_collector, request_id_a)
|
|
assert_event_invariants(sender_collector, request_id_b)
|