mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00

- Some baselines for tests in "leaks" group were outdated. - Changed a few of the cluster/communication tests to terminate more explicitly instead of relying on btest-bg-wait to kill processes. This makes the tests finish faster in the success case and makes the reason for failing clearer in the that case.
59 lines
1.7 KiB
Text
59 lines
1.7 KiB
Text
# @TEST-SERIALIZE: comm
|
|
#
|
|
# @TEST-EXEC: btest-bg-run manager-1 BROPATH=$BROPATH:.. CLUSTER_NODE=manager-1 bro %INPUT
|
|
# @TEST-EXEC: btest-bg-run proxy-1 BROPATH=$BROPATH:.. CLUSTER_NODE=proxy-1 bro %INPUT
|
|
# @TEST-EXEC: sleep 1
|
|
# @TEST-EXEC: btest-bg-run worker-1 BROPATH=$BROPATH:.. CLUSTER_NODE=worker-1 bro %INPUT
|
|
# @TEST-EXEC: btest-bg-run worker-2 BROPATH=$BROPATH:.. CLUSTER_NODE=worker-2 bro %INPUT
|
|
# @TEST-EXEC: btest-bg-wait 20
|
|
# @TEST-EXEC: btest-diff manager-1/metrics.log
|
|
|
|
@TEST-START-FILE cluster-layout.bro
|
|
redef Cluster::nodes = {
|
|
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=37757/tcp, $workers=set("worker-1")],
|
|
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=37758/tcp, $manager="manager-1", $workers=set("worker-1")],
|
|
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=37760/tcp, $manager="manager-1", $proxy="proxy-1", $interface="eth0"],
|
|
["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=37761/tcp, $manager="manager-1", $proxy="proxy-1", $interface="eth1"],
|
|
};
|
|
@TEST-END-FILE
|
|
|
|
redef Log::default_rotation_interval = 0secs;
|
|
|
|
redef enum Metrics::ID += {
|
|
TEST_METRIC,
|
|
};
|
|
|
|
event bro_init() &priority=5
|
|
{
|
|
Metrics::add_filter(TEST_METRIC,
|
|
[$name="foo-bar",
|
|
$break_interval=3secs]);
|
|
|
|
if ( Cluster::local_node_type() == Cluster::WORKER )
|
|
{
|
|
Metrics::add_data(TEST_METRIC, [$host=1.2.3.4], 3);
|
|
Metrics::add_data(TEST_METRIC, [$host=6.5.4.3], 2);
|
|
Metrics::add_data(TEST_METRIC, [$host=7.2.1.5], 1);
|
|
}
|
|
}
|
|
|
|
event remote_connection_closed(p: event_peer)
|
|
{
|
|
terminate();
|
|
}
|
|
|
|
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
|
|
|
global n = 0;
|
|
|
|
event Metrics::log_metrics(rec: Metrics::Info)
|
|
{
|
|
n = n + 1;
|
|
if ( n == 3 )
|
|
{
|
|
terminate_communication();
|
|
terminate();
|
|
}
|
|
}
|
|
|
|
@endif
|