mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
btest/websocket/terminate-while-queueing: Use ZeroMQ
This adds a helper script to start the XPUB/XSUB proxy using the XPUB_PORT and XSUB_PORT environment variables. The crux here is that WebSocket clients go through the central XPUB/XSUB proxy. This is different from Broker where WebSocket clients attach via local hubs to the endpoint which doesn't require additional configuration.
This commit is contained in:
parent
8d3a62edc1
commit
2730a0dd61
2 changed files with 30 additions and 0 deletions
24
testing/btest/Files/zeromq/single-node.zeek
Normal file
24
testing/btest/Files/zeromq/single-node.zeek
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Helper script expecting XPUB_PORT / XSUB_PORT environments
|
||||||
|
# and redefining the ZeroMQ options accordingly and starting
|
||||||
|
# the zmq_proxy_thread.
|
||||||
|
#
|
||||||
|
# This is primarily useful for testing of WebSocket functionality
|
||||||
|
# while the ZeroMQ backend is enabled.
|
||||||
|
@load base/utils/numbers
|
||||||
|
|
||||||
|
@load frameworks/cluster/backend/zeromq
|
||||||
|
|
||||||
|
const local_addr_str = "127.0.0.1" &redef;
|
||||||
|
redef Cluster::Backend::ZeroMQ::listen_xpub_endpoint = fmt("tcp://%s:%s", local_addr_str, port_to_count(to_port(getenv("XPUB_PORT"))));
|
||||||
|
redef Cluster::Backend::ZeroMQ::listen_xsub_endpoint = fmt("tcp://%s:%s", local_addr_str, port_to_count(to_port(getenv("XSUB_PORT"))));
|
||||||
|
redef Cluster::Backend::ZeroMQ::connect_xpub_endpoint = fmt("tcp://%s:%s", local_addr_str, port_to_count(to_port(getenv("XSUB_PORT"))));
|
||||||
|
redef Cluster::Backend::ZeroMQ::connect_xsub_endpoint = fmt("tcp://%s:%s", local_addr_str, port_to_count(to_port(getenv("XPUB_PORT"))));
|
||||||
|
|
||||||
|
event zeek_init() &priority=100
|
||||||
|
{
|
||||||
|
if ( ! Cluster::Backend::ZeroMQ::spawn_zmq_proxy_thread() )
|
||||||
|
Reporter::fatal("Failed to spawn ZeroMQ proxy thread");
|
||||||
|
|
||||||
|
if ( ! Cluster::init() )
|
||||||
|
Reporter::fatal("Failed to initialize ZeroMQ backend");
|
||||||
|
}
|
|
@ -2,9 +2,13 @@
|
||||||
#
|
#
|
||||||
# @TEST-REQUIRES: python3 -c 'import websockets.sync'
|
# @TEST-REQUIRES: python3 -c 'import websockets.sync'
|
||||||
#
|
#
|
||||||
|
# @TEST-PORT: XPUB_PORT
|
||||||
|
# @TEST-PORT: XSUB_PORT
|
||||||
# @TEST-PORT: WEBSOCKET_PORT
|
# @TEST-PORT: WEBSOCKET_PORT
|
||||||
#
|
#
|
||||||
|
# @TEST-EXEC: cp $FILES/zeromq/single-node.zeek zeromq-single-node.zeek
|
||||||
# @TEST-EXEC: cp $FILES/ws/wstest.py .
|
# @TEST-EXEC: cp $FILES/ws/wstest.py .
|
||||||
|
#
|
||||||
# @TEST-EXEC: zeek -b --parse-only manager.zeek
|
# @TEST-EXEC: zeek -b --parse-only manager.zeek
|
||||||
# @TEST-EXEC: python3 -m py_compile client.py
|
# @TEST-EXEC: python3 -m py_compile client.py
|
||||||
#
|
#
|
||||||
|
@ -19,6 +23,8 @@
|
||||||
# @TEST-EXEC: btest-diff ./client/.stderr
|
# @TEST-EXEC: btest-diff ./client/.stderr
|
||||||
|
|
||||||
# @TEST-START-FILE manager.zeek
|
# @TEST-START-FILE manager.zeek
|
||||||
|
@load zeromq-single-node
|
||||||
|
|
||||||
redef exit_only_after_terminate = T;
|
redef exit_only_after_terminate = T;
|
||||||
|
|
||||||
# Force dispatcher queue being full quickly!
|
# Force dispatcher queue being full quickly!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue