zeek/testing/btest/scripts/base/frameworks/notice/cluster.bro
Jon Siwek 15d74ac081 BIT-1941: improve unit test stability
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).
2018-07-03 15:00:52 -05:00

60 lines
1.5 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: btest-bg-run worker-1 BROPATH=$BROPATH:.. CLUSTER_NODE=worker-1 bro %INPUT
# @TEST-EXEC: btest-bg-wait 20
# @TEST-EXEC: btest-diff manager-1/notice.log
@TEST-START-FILE cluster-layout.bro
redef Cluster::nodes = {
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=27757/tcp],
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=27758/tcp, $manager="manager-1"],
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=27760/tcp, $manager="manager-1", $interface="eth0"],
};
@TEST-END-FILE
redef Cluster::retry_interval = 1sec;
redef Broker::default_listen_retry = 1sec;
redef Broker::default_connect_retry = 1sec;
redef Log::default_rotation_interval = 0secs;
redef enum Notice::Type += {
Test_Notice,
};
event Cluster::node_down(name: string, id: string)
{
terminate();
}
event delayed_notice()
{
if ( Cluster::node == "worker-1" )
NOTICE([$note=Test_Notice, $msg="test notice!"]);
}
event ready()
{
schedule 1secs { delayed_notice() };
}
@if ( Cluster::local_node_type() == Cluster::MANAGER )
global peer_count = 0;
event Cluster::node_up(name: string, id: string)
{
peer_count = peer_count + 1;
if ( peer_count == 2 )
Broker::publish(Cluster::worker_topic, ready);
}
event Notice::log_notice(rec: Notice::Info)
{
terminate();
}
@endif