mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Add a test for starting a cluster with a logger node
Also modified cluster framework scripts so that any node can raise an event to be handled on the logger node.
This commit is contained in:
parent
88d066e921
commit
59f0ea1a0c
9 changed files with 117 additions and 3 deletions
|
@ -52,12 +52,21 @@ export {
|
||||||
## Events raised by a manager and handled by proxies.
|
## Events raised by a manager and handled by proxies.
|
||||||
const manager2proxy_events = /EMPTY/ &redef;
|
const manager2proxy_events = /EMPTY/ &redef;
|
||||||
|
|
||||||
|
## Events raised by a manager and handled by loggers.
|
||||||
|
const manager2logger_events = /EMPTY/ &redef;
|
||||||
|
|
||||||
|
## Events raised by proxies and handled by loggers.
|
||||||
|
const proxy2logger_events = /EMPTY/ &redef;
|
||||||
|
|
||||||
## Events raised by proxies and handled by a manager.
|
## Events raised by proxies and handled by a manager.
|
||||||
const proxy2manager_events = /EMPTY/ &redef;
|
const proxy2manager_events = /EMPTY/ &redef;
|
||||||
|
|
||||||
## Events raised by proxies and handled by workers.
|
## Events raised by proxies and handled by workers.
|
||||||
const proxy2worker_events = /EMPTY/ &redef;
|
const proxy2worker_events = /EMPTY/ &redef;
|
||||||
|
|
||||||
|
## Events raised by workers and handled by loggers.
|
||||||
|
const worker2logger_events = /EMPTY/ &redef;
|
||||||
|
|
||||||
## Events raised by workers and handled by a manager.
|
## Events raised by workers and handled by a manager.
|
||||||
const worker2manager_events = /(TimeMachine::command|Drop::.*)/ &redef;
|
const worker2manager_events = /(TimeMachine::command|Drop::.*)/ &redef;
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,18 @@ event bro_init() &priority=9
|
||||||
|
|
||||||
if ( me$node_type == LOGGER )
|
if ( me$node_type == LOGGER )
|
||||||
{
|
{
|
||||||
if ( (n$node_type == MANAGER || n$node_type == PROXY ||
|
if ( n$node_type == MANAGER && n$logger == node )
|
||||||
n$node_type == WORKER) && n$logger == node )
|
|
||||||
Communication::nodes[i] =
|
Communication::nodes[i] =
|
||||||
[$host=n$ip, $zone_id=n$zone_id, $connect=F,
|
[$host=n$ip, $zone_id=n$zone_id, $connect=F,
|
||||||
$class=i, $request_logs=T];
|
$class=i, $events=manager2logger_events, $request_logs=T];
|
||||||
|
if ( n$node_type == PROXY && n$logger == node )
|
||||||
|
Communication::nodes[i] =
|
||||||
|
[$host=n$ip, $zone_id=n$zone_id, $connect=F,
|
||||||
|
$class=i, $events=proxy2logger_events, $request_logs=T];
|
||||||
|
if ( n$node_type == WORKER && n$logger == node )
|
||||||
|
Communication::nodes[i] =
|
||||||
|
[$host=n$ip, $zone_id=n$zone_id, $connect=F,
|
||||||
|
$class=i, $events=worker2logger_events, $request_logs=T];
|
||||||
}
|
}
|
||||||
else if ( me$node_type == MANAGER )
|
else if ( me$node_type == MANAGER )
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
|
@ -0,0 +1,5 @@
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
|
@ -0,0 +1,3 @@
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
|
@ -0,0 +1,3 @@
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
|
@ -0,0 +1,3 @@
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
|
@ -0,0 +1,3 @@
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
||||||
|
Connected to a peer
|
|
@ -0,0 +1,76 @@
|
||||||
|
# @TEST-SERIALIZE: comm
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: btest-bg-run logger-1 CLUSTER_NODE=logger-1 BROPATH=$BROPATH:.. bro %INPUT
|
||||||
|
# @TEST-EXEC: sleep 1
|
||||||
|
# @TEST-EXEC: btest-bg-run manager-1 CLUSTER_NODE=manager-1 BROPATH=$BROPATH:.. bro %INPUT
|
||||||
|
# @TEST-EXEC: sleep 1
|
||||||
|
# @TEST-EXEC: btest-bg-run proxy-1 CLUSTER_NODE=proxy-1 BROPATH=$BROPATH:.. bro %INPUT
|
||||||
|
# @TEST-EXEC: btest-bg-run proxy-2 CLUSTER_NODE=proxy-2 BROPATH=$BROPATH:.. bro %INPUT
|
||||||
|
# @TEST-EXEC: sleep 1
|
||||||
|
# @TEST-EXEC: btest-bg-run worker-1 CLUSTER_NODE=worker-1 BROPATH=$BROPATH:.. bro %INPUT
|
||||||
|
# @TEST-EXEC: btest-bg-run worker-2 CLUSTER_NODE=worker-2 BROPATH=$BROPATH:.. bro %INPUT
|
||||||
|
# @TEST-EXEC: btest-bg-wait 30
|
||||||
|
# @TEST-EXEC: btest-diff logger-1/.stdout
|
||||||
|
# @TEST-EXEC: 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
|
||||||
|
|
||||||
|
@TEST-START-FILE cluster-layout.bro
|
||||||
|
redef Cluster::manager_is_logger = F;
|
||||||
|
redef Cluster::nodes = {
|
||||||
|
["logger-1"] = [$node_type=Cluster::LOGGER, $ip=127.0.0.1, $p=37757/tcp],
|
||||||
|
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=37758/tcp, $logger="logger-1", $workers=set("worker-1")],
|
||||||
|
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=37759/tcp, $logger="logger-1", $manager="manager-1", $workers=set("worker-1")],
|
||||||
|
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=37760/tcp, $logger="logger-1", $manager="manager-1", $workers=set("worker-2")],
|
||||||
|
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=37761/tcp, $logger="logger-1", $manager="manager-1", $proxy="proxy-1", $interface="eth0"],
|
||||||
|
["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=37762/tcp, $logger="logger-1", $manager="manager-1", $proxy="proxy-2", $interface="eth1"],
|
||||||
|
};
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
global fully_connected: event();
|
||||||
|
|
||||||
|
global peer_count = 0;
|
||||||
|
|
||||||
|
global fully_connected_nodes = 0;
|
||||||
|
|
||||||
|
event fully_connected()
|
||||||
|
{
|
||||||
|
++fully_connected_nodes;
|
||||||
|
if ( Cluster::node == "logger-1" )
|
||||||
|
{
|
||||||
|
if ( peer_count == 5 && fully_connected_nodes == 5 )
|
||||||
|
terminate_communication();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
redef Cluster::worker2logger_events += /fully_connected/;
|
||||||
|
redef Cluster::proxy2logger_events += /fully_connected/;
|
||||||
|
redef Cluster::manager2logger_events += /fully_connected/;
|
||||||
|
|
||||||
|
event remote_connection_handshake_done(p: event_peer)
|
||||||
|
{
|
||||||
|
print "Connected to a peer";
|
||||||
|
++peer_count;
|
||||||
|
if ( Cluster::node == "logger-1" )
|
||||||
|
{
|
||||||
|
if ( peer_count == 5 && fully_connected_nodes == 5 )
|
||||||
|
terminate_communication();
|
||||||
|
}
|
||||||
|
else if ( Cluster::node == "manager-1" )
|
||||||
|
{
|
||||||
|
if ( peer_count == 5 )
|
||||||
|
event fully_connected();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( peer_count == 3 )
|
||||||
|
event fully_connected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
event remote_connection_closed(p: event_peer)
|
||||||
|
{
|
||||||
|
terminate();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue