mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 11:38:20 +00:00
Adding new leak tests involving remote logging.
This commit is contained in:
parent
bf14bd91d7
commit
83038d78e0
7 changed files with 160 additions and 1 deletions
|
@ -0,0 +1,10 @@
|
||||||
|
#separator \x09
|
||||||
|
#set_separator ,
|
||||||
|
#empty_field (empty)
|
||||||
|
#unset_field -
|
||||||
|
#path metrics
|
||||||
|
#fields ts metric_id filter_name index.host index.str index.network value
|
||||||
|
#types time enum string addr string subnet count
|
||||||
|
1331256494.591966 TEST_METRIC foo-bar 6.5.4.3 - - 4
|
||||||
|
1331256494.591966 TEST_METRIC foo-bar 7.2.1.5 - - 2
|
||||||
|
1331256494.591966 TEST_METRIC foo-bar 1.2.3.4 - - 6
|
|
@ -0,0 +1,10 @@
|
||||||
|
#separator \x09
|
||||||
|
#set_separator ,
|
||||||
|
#empty_field (empty)
|
||||||
|
#unset_field -
|
||||||
|
#path test.failure
|
||||||
|
#fields t id.orig_h id.orig_p id.resp_h id.resp_p status country
|
||||||
|
#types time addr port addr port string string
|
||||||
|
1331256472.375609 1.2.3.4 1234 2.3.4.5 80 failure US
|
||||||
|
1331256472.375609 1.2.3.4 1234 2.3.4.5 80 failure UK
|
||||||
|
1331256472.375609 1.2.3.4 1234 2.3.4.5 80 failure MX
|
12
testing/btest/Baseline/core.leaks.remote/sender.test.log
Normal file
12
testing/btest/Baseline/core.leaks.remote/sender.test.log
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#separator \x09
|
||||||
|
#set_separator ,
|
||||||
|
#empty_field (empty)
|
||||||
|
#unset_field -
|
||||||
|
#path test
|
||||||
|
#fields t id.orig_h id.orig_p id.resp_h id.resp_p status country
|
||||||
|
#types time addr port addr port string string
|
||||||
|
1331256472.375609 1.2.3.4 1234 2.3.4.5 80 success unknown
|
||||||
|
1331256472.375609 1.2.3.4 1234 2.3.4.5 80 failure US
|
||||||
|
1331256472.375609 1.2.3.4 1234 2.3.4.5 80 failure UK
|
||||||
|
1331256472.375609 1.2.3.4 1234 2.3.4.5 80 success BR
|
||||||
|
1331256472.375609 1.2.3.4 1234 2.3.4.5 80 failure MX
|
|
@ -0,0 +1,9 @@
|
||||||
|
#separator \x09
|
||||||
|
#set_separator ,
|
||||||
|
#empty_field (empty)
|
||||||
|
#unset_field -
|
||||||
|
#path test.success
|
||||||
|
#fields t id.orig_h id.orig_p id.resp_h id.resp_p status country
|
||||||
|
#types time addr port addr port string string
|
||||||
|
1331256472.375609 1.2.3.4 1234 2.3.4.5 80 success unknown
|
||||||
|
1331256472.375609 1.2.3.4 1234 2.3.4.5 80 success BR
|
39
testing/btest/core/leaks/basic-cluster.bro
Normal file
39
testing/btest/core/leaks/basic-cluster.bro
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# Needs perftools support.
|
||||||
|
#
|
||||||
|
# @TEST-REQUIRES: bro --help 2>&1 | grep -q mem-leaks
|
||||||
|
# @TEST-EXEC: btest-bg-run manager-1 HEAP_CHECK_DUMP_DIRECTORY=. HEAPCHECK=local BROPATH=$BROPATH:.. CLUSTER_NODE=manager-1 bro -m %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 HEAP_CHECK_DUMP_DIRECTORY=. HEAPCHECK=local BROPATH=$BROPATH:.. CLUSTER_NODE=worker-1 bro -m -r $TRACES/web.trace --pseudo-realtime %INPUT
|
||||||
|
# @TEST-EXEC: btest-bg-run worker-2 HEAP_CHECK_DUMP_DIRECTORY=. HEAPCHECK=local BROPATH=$BROPATH:.. CLUSTER_NODE=worker-2 bro -m -r $TRACES/web.trace --pseudo-realtime %INPUT
|
||||||
|
# @TEST-EXEC: btest-bg-wait -k 30
|
||||||
|
# @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);
|
||||||
|
}
|
||||||
|
}
|
79
testing/btest/core/leaks/remote.bro
Normal file
79
testing/btest/core/leaks/remote.bro
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
# Needs perftools support.
|
||||||
|
#
|
||||||
|
# @TEST-REQUIRES: bro --help 2>&1 | grep -q mem-leaks
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: btest-bg-run sender HEAP_CHECK_DUMP_DIRECTORY=. HEAPCHECK=local bro -m --pseudo-realtime %INPUT ../sender.bro
|
||||||
|
# @TEST-EXEC: sleep 1
|
||||||
|
# @TEST-EXEC: btest-bg-run receiver HEAP_CHECK_DUMP_DIRECTORY=. HEAPCHECK=local bro -m --pseudo-realtime %INPUT ../receiver.bro
|
||||||
|
# @TEST-EXEC: sleep 1
|
||||||
|
# @TEST-EXEC: btest-bg-wait -k 10
|
||||||
|
# @TEST-EXEC: btest-diff sender/test.log
|
||||||
|
# @TEST-EXEC: btest-diff sender/test.failure.log
|
||||||
|
# @TEST-EXEC: btest-diff sender/test.success.log
|
||||||
|
# @TEST-EXEC: cmp receiver/test.log sender/test.log
|
||||||
|
# @TEST-EXEC: cmp receiver/test.failure.log sender/test.failure.log
|
||||||
|
# @TEST-EXEC: cmp receiver/test.success.log sender/test.success.log
|
||||||
|
|
||||||
|
# This is the common part loaded by both sender and receiver.
|
||||||
|
module Test;
|
||||||
|
|
||||||
|
export {
|
||||||
|
# Create a new ID for our log stream
|
||||||
|
redef enum Log::ID += { LOG };
|
||||||
|
|
||||||
|
# Define a record with all the columns the log file can have.
|
||||||
|
# (I'm using a subset of fields from ssh-ext for demonstration.)
|
||||||
|
type Log: record {
|
||||||
|
t: time;
|
||||||
|
id: conn_id; # Will be rolled out into individual columns.
|
||||||
|
status: string &optional;
|
||||||
|
country: string &default="unknown";
|
||||||
|
} &log;
|
||||||
|
}
|
||||||
|
|
||||||
|
event bro_init()
|
||||||
|
{
|
||||||
|
Log::create_stream(Test::LOG, [$columns=Log]);
|
||||||
|
Log::add_filter(Test::LOG, [$name="f1", $path="test.success", $pred=function(rec: Log): bool { return rec$status == "success"; }]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#####
|
||||||
|
|
||||||
|
@TEST-START-FILE sender.bro
|
||||||
|
|
||||||
|
module Test;
|
||||||
|
|
||||||
|
@load frameworks/communication/listen
|
||||||
|
|
||||||
|
function fail(rec: Log): bool
|
||||||
|
{
|
||||||
|
return rec$status != "success";
|
||||||
|
}
|
||||||
|
|
||||||
|
event remote_connection_handshake_done(p: event_peer)
|
||||||
|
{
|
||||||
|
Log::add_filter(Test::LOG, [$name="f2", $path="test.failure", $pred=fail]);
|
||||||
|
|
||||||
|
local cid = [$orig_h=1.2.3.4, $orig_p=1234/tcp, $resp_h=2.3.4.5, $resp_p=80/tcp];
|
||||||
|
|
||||||
|
local r: Log = [$t=network_time(), $id=cid, $status="success"];
|
||||||
|
|
||||||
|
# Log something.
|
||||||
|
Log::write(Test::LOG, r);
|
||||||
|
Log::write(Test::LOG, [$t=network_time(), $id=cid, $status="failure", $country="US"]);
|
||||||
|
Log::write(Test::LOG, [$t=network_time(), $id=cid, $status="failure", $country="UK"]);
|
||||||
|
Log::write(Test::LOG, [$t=network_time(), $id=cid, $status="success", $country="BR"]);
|
||||||
|
Log::write(Test::LOG, [$t=network_time(), $id=cid, $status="failure", $country="MX"]);
|
||||||
|
disconnect(p);
|
||||||
|
}
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
@TEST-START-FILE receiver.bro
|
||||||
|
|
||||||
|
#####
|
||||||
|
|
||||||
|
redef Communication::nodes += {
|
||||||
|
["foo"] = [$host = 127.0.0.1, $connect=T, $request_logs=T]
|
||||||
|
};
|
||||||
|
|
||||||
|
@TEST-END-FILE
|
|
@ -7,4 +7,4 @@
|
||||||
|
|
||||||
cat $1 | sed "s#bro *\"\./#../../../build/src/bro \".tmp/$TEST_NAME/#g" | sed 's/ *--gv//g' >$1.tmp && mv $1.tmp $1
|
cat $1 | sed "s#bro *\"\./#../../../build/src/bro \".tmp/$TEST_NAME/#g" | sed 's/ *--gv//g' >$1.tmp && mv $1.tmp $1
|
||||||
|
|
||||||
grep -q "No leaks found" $1
|
grep -qv "detected leaks of" $1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue