mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
62 lines
1.7 KiB
Text
62 lines
1.7 KiB
Text
# @TEST-PORT: BROKER_MANAGER_PORT
|
|
# @TEST-PORT: BROKER_PROXY1_PORT
|
|
# @TEST-PORT: BROKER_PROXY2_PORT
|
|
# @TEST-PORT: BROKER_WORKER1_PORT
|
|
# @TEST-PORT: BROKER_WORKER2_PORT
|
|
#
|
|
# @TEST-EXEC: cp $FILES/broker/cluster-layout.zeek .
|
|
#
|
|
# @TEST-EXEC: btest-bg-run manager ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=manager zeek -b %INPUT
|
|
# @TEST-EXEC: btest-bg-run proxy-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=proxy-1 zeek -b %INPUT
|
|
# @TEST-EXEC: btest-bg-run proxy-2 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=proxy-2 zeek -b %INPUT
|
|
# @TEST-EXEC: btest-bg-run worker-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-1 zeek -b %INPUT
|
|
# @TEST-EXEC: btest-bg-run worker-2 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-2 zeek -b %INPUT
|
|
# @TEST-EXEC: btest-bg-wait 40
|
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff manager/.stdout
|
|
# @TEST-EXEC: btest-diff proxy-1/.stdout
|
|
# @TEST-EXEC: btest-diff proxy-2/.stdout
|
|
# @TEST-EXEC: btest-diff worker-1/.stdout
|
|
# @TEST-EXEC: btest-diff worker-2/.stdout
|
|
|
|
@load base/frameworks/cluster
|
|
|
|
global peer_count = 0;
|
|
|
|
global fully_connected_nodes = 0;
|
|
|
|
event fully_connected()
|
|
{
|
|
if ( ! is_remote_event() )
|
|
return;
|
|
|
|
print "Got fully_connected event";
|
|
fully_connected_nodes = fully_connected_nodes + 1;
|
|
|
|
if ( Cluster::node == "manager" )
|
|
{
|
|
if ( peer_count == 4 && fully_connected_nodes == 4 )
|
|
terminate();
|
|
}
|
|
}
|
|
|
|
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|
{
|
|
print "Connected to a peer";
|
|
peer_count = peer_count + 1;
|
|
|
|
if ( Cluster::node == "manager" )
|
|
{
|
|
if ( peer_count == 4 && fully_connected_nodes == 4 )
|
|
terminate();
|
|
}
|
|
else
|
|
{
|
|
if ( peer_count == 3 )
|
|
Broker::publish(Cluster::manager_topic, fully_connected);
|
|
}
|
|
}
|
|
|
|
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
|
{
|
|
terminate();
|
|
}
|