btest/cluster/websocket: Harden multi-client tests

These test were very sensible to the speed at which ZeroMQ distributes
subscriptions in the cluster and showed to be unreliably when testing with
zeek/btest#113.

The main fix here is to have individual WebSocket clients subscribe to unique
topics, e.g /test/client-0 and /test/client-1, instead of just a shared topic.

This ensures the WebSocket handshake completes only when they observed their
own subscriptions and not prematurely when observing the shared topic.

This seems mainly relevant for tests: In the real world one shouldn't
rely on subscription visibility - you miss messages if you're too late
to the party.
This commit is contained in:
Arne Welzel 2025-03-14 11:43:12 +01:00
parent 3885871e7d
commit 888af244b2
6 changed files with 131 additions and 89 deletions

View file

@ -1,23 +0,0 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
Cluster::websocket_client_added, 1, [/test/clients]
Cluster::websocket_client_added, 2, [/test/clients]
Cluster::websocket_client_added, 3, [/test/clients]
got ping: ws1, 0
got ping: ws2, 1
got ping: ws3, 2
got ping: ws1, 3
got ping: ws2, 4
got ping: ws3, 5
got ping: ws1, 6
got ping: ws2, 7
got ping: ws3, 8
got ping: ws1, 9
got ping: ws2, 10
got ping: ws3, 11
got ping: ws1, 12
got ping: ws2, 13
got ping: ws3, 14
got ping: ws1, 15
Cluster::websocket_client_lost, 1
Cluster::websocket_client_lost, 2
Cluster::websocket_client_lost, 3

View file

@ -0,0 +1,28 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
A subscription, /test/client-0
A subscription, /test/client-1
A subscription, /test/client-2
A subscription, /test/clients
A subscription, /test/manager
B Cluster::websocket_client_added, [/test/client-0, /test/clients]
B Cluster::websocket_client_added, [/test/client-1, /test/clients]
B Cluster::websocket_client_added, [/test/client-2, /test/clients]
C got ping: ws1, 0
C got ping: ws1, 12
C got ping: ws1, 15
C got ping: ws1, 3
C got ping: ws1, 6
C got ping: ws1, 9
C got ping: ws2, 1
C got ping: ws2, 10
C got ping: ws2, 13
C got ping: ws2, 4
C got ping: ws2, 7
C got ping: ws3, 11
C got ping: ws3, 14
C got ping: ws3, 2
C got ping: ws3, 5
C got ping: ws3, 8
D Cluster::websocket_client_lost, 1
D Cluster::websocket_client_lost, 2
D Cluster::websocket_client_lost, 3