mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00

This field isn't required by a worker and it's certainly not used by a worker to listen on that specific interface. It also isn't required to be set consistently and its use in-tree limited to the old load-balancing script. There's a bif called packet_source() which on a worker will provide information about the actually used packet source. Relates to zeek/zeek#2877.
77 lines
2.4 KiB
Text
77 lines
2.4 KiB
Text
# @TEST-PORT: BROKER_PORT1
|
|
# @TEST-PORT: BROKER_PORT2
|
|
# @TEST-PORT: BROKER_PORT3
|
|
# @TEST-PORT: BROKER_PORT4
|
|
# @TEST-PORT: BROKER_PORT5
|
|
#
|
|
# @TEST-EXEC: btest-bg-run manager-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=manager-1 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-1/.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
|
|
|
|
@TEST-START-FILE cluster-layout.zeek
|
|
redef Cluster::nodes = {
|
|
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
|
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
|
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
|
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT4")), $manager="manager-1"],
|
|
["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT5")), $manager="manager-1"],
|
|
};
|
|
@TEST-END-FILE
|
|
|
|
global fully_connected: event();
|
|
|
|
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-1" )
|
|
{
|
|
if ( peer_count == 4 && fully_connected_nodes == 4 )
|
|
terminate();
|
|
}
|
|
}
|
|
|
|
event zeek_init()
|
|
{
|
|
Broker::auto_publish(Cluster::manager_topic, fully_connected);
|
|
}
|
|
|
|
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|
{
|
|
print "Connected to a peer";
|
|
peer_count = peer_count + 1;
|
|
|
|
if ( Cluster::node == "manager-1" )
|
|
{
|
|
if ( peer_count == 4 && fully_connected_nodes == 4 )
|
|
terminate();
|
|
}
|
|
else
|
|
{
|
|
if ( peer_count == 3 )
|
|
event fully_connected();
|
|
}
|
|
}
|
|
|
|
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
|
{
|
|
terminate();
|
|
}
|