Misc. unit test improvements

This commit is contained in:
Jon Siwek 2018-08-10 16:58:27 -05:00
parent ff22230a73
commit 9f12b56105
11 changed files with 38 additions and 17 deletions

View file

@ -1,3 +1,3 @@
Ok error Ok error
171249.90868 167377.950902
Ok error Ok error

View file

@ -2,4 +2,10 @@ Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
got fully_connected event from, worker-1
Connected to a peer Connected to a peer
got fully_connected event from, proxy-1
got fully_connected event from, proxy-2
got fully_connected event from, manager-1
got fully_connected event from, worker-2
termination condition met: shutting down

View file

@ -3,3 +3,4 @@ Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
sent fully_connected event

View file

@ -2,3 +2,4 @@ Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
sent fully_connected event

View file

@ -2,3 +2,4 @@ Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
sent fully_connected event

View file

@ -2,3 +2,4 @@ Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
sent fully_connected event

View file

@ -2,3 +2,4 @@ Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
Connected to a peer Connected to a peer
sent fully_connected event

View file

@ -8,7 +8,7 @@
event bro_init() event bro_init()
{ {
local cp: opaque of cardinality = hll_cardinality_init(0.1, 0.99); local cp: opaque of cardinality = hll_cardinality_init(0.1, 1.0);
local base: count = 2130706432; # 127.0.0.0 local base: count = 2130706432; # 127.0.0.0
local i: count = 0; local i: count = 0;
while ( ++i < 170000 ) while ( ++i < 170000 )

View file

@ -1,13 +1,13 @@
# @TEST-SERIALIZE: comm # @TEST-SERIALIZE: comm
# #
# @TEST-EXEC: btest-bg-run logger-1 CLUSTER_NODE=logger-1 BROPATH=$BROPATH:.. bro %INPUT # @TEST-EXEC: btest-bg-run logger-1 CLUSTER_NODE=logger-1 BROPATH=$BROPATH:.. bro %INPUT
# @TEST-EXEC: btest-bg-run manager-1 CLUSTER_NODE=manager-1 BROPATH=$BROPATH:.. bro %INPUT # @TEST-EXEC: btest-bg-run manager-1 CLUSTER_NODE=manager-1 BROPATH=$BROPATH:.. bro %INPUT
# @TEST-EXEC: btest-bg-run proxy-1 CLUSTER_NODE=proxy-1 BROPATH=$BROPATH:.. bro %INPUT # @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: btest-bg-run proxy-2 CLUSTER_NODE=proxy-2 BROPATH=$BROPATH:.. bro %INPUT
# @TEST-EXEC: btest-bg-run worker-1 CLUSTER_NODE=worker-1 BROPATH=$BROPATH:.. bro %INPUT # @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-run worker-2 CLUSTER_NODE=worker-2 BROPATH=$BROPATH:.. bro %INPUT
# @TEST-EXEC: btest-bg-wait 30 # @TEST-EXEC: btest-bg-wait 30
# @TEST-EXEC: btest-diff logger-1/.stdout # @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff logger-1/.stdout
# @TEST-EXEC: btest-diff manager-1/.stdout # @TEST-EXEC: btest-diff manager-1/.stdout
# @TEST-EXEC: btest-diff proxy-1/.stdout # @TEST-EXEC: btest-diff proxy-1/.stdout
# @TEST-EXEC: btest-diff proxy-2/.stdout # @TEST-EXEC: btest-diff proxy-2/.stdout
@ -30,20 +30,27 @@ redef Cluster::retry_interval = 1sec;
redef Broker::default_listen_retry = 1sec; redef Broker::default_listen_retry = 1sec;
redef Broker::default_connect_retry = 1sec; redef Broker::default_connect_retry = 1sec;
global fully_connected: event();
global peer_count = 0; global peer_count = 0;
global fully_connected_nodes = 0; global fully_connected_nodes = 0;
event fully_connected() event fully_connected(n: string)
{ {
++fully_connected_nodes; ++fully_connected_nodes;
if ( Cluster::node == "logger-1" ) if ( Cluster::node == "logger-1" )
{ {
print "got fully_connected event from", n;
if ( peer_count == 5 && fully_connected_nodes == 5 ) if ( peer_count == 5 && fully_connected_nodes == 5 )
{
print "termination condition met: shutting down";
terminate(); terminate();
}
}
else
{
print "sent fully_connected event";
} }
} }
@ -60,17 +67,20 @@ event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
if ( Cluster::node == "logger-1" ) if ( Cluster::node == "logger-1" )
{ {
if ( peer_count == 5 && fully_connected_nodes == 5 ) if ( peer_count == 5 && fully_connected_nodes == 5 )
{
print "termination condition met: shutting down";
terminate(); terminate();
}
} }
else if ( Cluster::node == "manager-1" ) else if ( Cluster::node == "manager-1" )
{ {
if ( peer_count == 5 ) if ( peer_count == 5 )
event fully_connected(); event fully_connected(Cluster::node);
} }
else else
{ {
if ( peer_count == 4 ) if ( peer_count == 4 )
event fully_connected(); event fully_connected(Cluster::node);
} }
} }

View file

@ -1,11 +1,11 @@
# @TEST-EXEC: btest-bg-run bro bro -b %INPUT # @TEST-EXEC: btest-bg-run bro bro -b %INPUT
# @TEST-EXEC: $SCRIPTS/wait-for-file bro/got1 5 || (btest-bg-wait -k 1 && false) # @TEST-EXEC: $SCRIPTS/wait-for-file bro/got1 10 || (btest-bg-wait -k 1 && false)
# @TEST-EXEC: mv configfile2 configfile # @TEST-EXEC: mv configfile2 configfile
# @TEST-EXEC: touch configfile # @TEST-EXEC: touch configfile
# @TEST-EXEC: $SCRIPTS/wait-for-file bro/got2 5 || (btest-bg-wait -k 1 && false) # @TEST-EXEC: $SCRIPTS/wait-for-file bro/got2 10 || (btest-bg-wait -k 1 && false)
# @TEST-EXEC: mv configfile3 configfile # @TEST-EXEC: mv configfile3 configfile
# @TEST-EXEC: touch configfile # @TEST-EXEC: touch configfile
# @TEST-EXEC: $SCRIPTS/wait-for-file bro/got3 5 || (btest-bg-wait -k 1 && false) # @TEST-EXEC: $SCRIPTS/wait-for-file bro/got3 10 || (btest-bg-wait -k 1 && false)
# @TEST-EXEC: mv configfile4 configfile # @TEST-EXEC: mv configfile4 configfile
# @TEST-EXEC: touch configfile # @TEST-EXEC: touch configfile
# @TEST-EXEC: btest-bg-wait 10 # @TEST-EXEC: btest-bg-wait 10

View file

@ -22,7 +22,7 @@ files_cwd=`ls $@`
files_baseline=`cd $TEST_BASELINE && ls $@` files_baseline=`cd $TEST_BASELINE && ls $@`
for i in `echo $files_cwd $files_baseline | sort | uniq`; do for i in `echo $files_cwd $files_baseline | sort | uniq`; do
if [[ "$i" != "loaded_scripts.log" && "$i" != "prof.log" && "$i" != "debug.log" && "$i" != "stats.log" ]]; then if [[ "$i" != "loaded_scripts.log" && "$i" != "prof.log" && "$i" != "debug.log" && "$i" != "stats.log" && "$i" != broker_*.log ]]; then
if [[ "$i" == "reporter.log" ]]; then if [[ "$i" == "reporter.log" ]]; then
# Do not diff the reporter.log if it only complains about missing # Do not diff the reporter.log if it only complains about missing