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

Mostly trying to standardize the way tests sleep for arbitrary amounts of time to make it easier to tell at which particular point the unit test actually may need the timeout interval increased (or else debugged further).
75 lines
1.8 KiB
Text
75 lines
1.8 KiB
Text
# @TEST-SERIALIZE: comm
|
|
#
|
|
# @TEST-EXEC: btest-bg-run manager-1 "cp ../cluster-layout.bro . && CLUSTER_NODE=manager-1 bro %INPUT"
|
|
# @TEST-EXEC: btest-bg-run worker-1 "cp ../cluster-layout.bro . && CLUSTER_NODE=worker-1 bro --pseudo-realtime -C -r $TRACES/wikipedia.trace %INPUT"
|
|
# @TEST-EXEC: btest-bg-wait 20
|
|
# @TEST-EXEC: btest-diff manager-1/http.log
|
|
|
|
|
|
@TEST-START-FILE cluster-layout.bro
|
|
redef Cluster::nodes = {
|
|
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=37757/tcp],
|
|
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=37760/tcp, $manager="manager-1", $interface="eth0"],
|
|
};
|
|
@TEST-END-FILE
|
|
|
|
@load base/protocols/conn
|
|
|
|
@if ( Cluster::node == "worker-1" )
|
|
redef exit_only_after_terminate = T;
|
|
@endif
|
|
|
|
redef Cluster::retry_interval = 1sec;
|
|
redef Broker::default_listen_retry = 1sec;
|
|
redef Broker::default_connect_retry = 1sec;
|
|
redef Log::default_rotation_interval = 0secs;
|
|
|
|
redef Log::default_scope_sep="_";
|
|
|
|
type Extension: record {
|
|
write_ts: time &log;
|
|
stream: string &log;
|
|
system_name: string &log;
|
|
};
|
|
|
|
function add_extension(path: string): Extension
|
|
{
|
|
return Extension($write_ts = network_time(),
|
|
$stream = path,
|
|
$system_name = peer_description);
|
|
}
|
|
|
|
redef Log::default_ext_func = add_extension;
|
|
|
|
event die()
|
|
{
|
|
terminate();
|
|
}
|
|
|
|
event slow_death()
|
|
{
|
|
Broker::flush_logs();
|
|
schedule 2sec { die() };
|
|
}
|
|
|
|
event kill_worker()
|
|
{
|
|
Broker::publish("death", slow_death);
|
|
}
|
|
|
|
event bro_init()
|
|
{
|
|
if ( Cluster::node == "worker-1" )
|
|
Broker::subscribe("death");
|
|
}
|
|
|
|
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|
{
|
|
if ( Cluster::node == "manager-1" )
|
|
schedule 2sec { kill_worker() };
|
|
}
|
|
|
|
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
|
{
|
|
schedule 2sec { die() };
|
|
}
|