mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
cluster/serializer/broker: Fix handler lookup
Handler overwrites operator bool, so need to explicitly test for nullptr rather than not having any handlers defined.
This commit is contained in:
parent
24ee115bbc
commit
6d1259423e
6 changed files with 76 additions and 1 deletions
|
@ -76,7 +76,7 @@ std::optional<detail::Event> to_zeek_event(const broker::zeek::Event& ev) {
|
||||||
|
|
||||||
zeek::Args vl;
|
zeek::Args vl;
|
||||||
zeek::EventHandlerPtr handler = zeek::event_registry->Lookup(name);
|
zeek::EventHandlerPtr handler = zeek::event_registry->Lookup(name);
|
||||||
if ( ! handler ) {
|
if ( handler == nullptr ) {
|
||||||
zeek::reporter->Error("Failed to lookup handler for '%s'", std::string(name).c_str());
|
zeek::reporter->Error("Failed to lookup handler for '%s'", std::string(name).c_str());
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
received termination signal
|
|
@ -0,0 +1,3 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
node_up, worker-1
|
||||||
|
node_down, worker-1
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
received termination signal
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
got finish
|
66
testing/btest/cluster/generic/publish-no-handler.zeek
Normal file
66
testing/btest/cluster/generic/publish-no-handler.zeek
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
# @TEST-DOC: A worker receiving an event without a handler implemented would produce a reporter error
|
||||||
|
#
|
||||||
|
# @TEST-REQUIRES: have-zeromq
|
||||||
|
#
|
||||||
|
# @TEST-GROUP: cluster-zeromq
|
||||||
|
#
|
||||||
|
# @TEST-PORT: XPUB_PORT
|
||||||
|
# @TEST-PORT: XSUB_PORT
|
||||||
|
# @TEST-PORT: LOG_PULL_PORT
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: cp $FILES/zeromq/cluster-layout-simple.zeek cluster-layout.zeek
|
||||||
|
# @TEST-EXEC: cp $FILES/zeromq/test-bootstrap.zeek zeromq-test-bootstrap.zeek
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: zeek --parse-only manager.zeek worker.zeek
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: btest-bg-run manager "ZEEKPATH=$ZEEKPATH:.. && CLUSTER_NODE=manager zeek -b ../manager.zeek >out"
|
||||||
|
# @TEST-EXEC: btest-bg-run worker "ZEEKPATH=$ZEEKPATH:.. && CLUSTER_NODE=worker-1 zeek -b ../worker.zeek >out"
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: btest-bg-wait 30
|
||||||
|
# @TEST-EXEC: btest-diff ./manager/out
|
||||||
|
# @TEST-EXEC: btest-diff ./manager/.stderr
|
||||||
|
# @TEST-EXEC: btest-diff ./worker/out
|
||||||
|
# @TEST-EXEC: btest-diff ./worker/.stderr
|
||||||
|
|
||||||
|
|
||||||
|
# @TEST-START-FILE common.zeek
|
||||||
|
@load ./zeromq-test-bootstrap
|
||||||
|
|
||||||
|
|
||||||
|
global hello: event() &is_used;
|
||||||
|
global finish: event() &is_used;
|
||||||
|
# @TEST-END-FILE
|
||||||
|
|
||||||
|
# @TEST-START-FILE manager.zeek
|
||||||
|
@load ./common.zeek
|
||||||
|
event send_finish(id: string)
|
||||||
|
{
|
||||||
|
Cluster::publish(Cluster::nodeid_topic(id), finish);
|
||||||
|
}
|
||||||
|
# If a node comes up that isn't us, send it a hello and
|
||||||
|
# schedule sending a my_finish
|
||||||
|
event Cluster::node_up(name: string, id: string)
|
||||||
|
{
|
||||||
|
print "node_up", name;
|
||||||
|
Cluster::publish(Cluster::nodeid_topic(id), hello);
|
||||||
|
schedule 20msec { send_finish(id) };
|
||||||
|
}
|
||||||
|
|
||||||
|
# If the worker vanishes, finish the test.
|
||||||
|
event Cluster::node_down(name: string, id: string)
|
||||||
|
{
|
||||||
|
print "node_down", name;
|
||||||
|
terminate();
|
||||||
|
}
|
||||||
|
# @TEST-END-FILE
|
||||||
|
|
||||||
|
# @TEST-START-FILE worker.zeek
|
||||||
|
@load ./common.zeek
|
||||||
|
# The worker does not implement hello!
|
||||||
|
|
||||||
|
event finish()
|
||||||
|
{
|
||||||
|
print "got finish";
|
||||||
|
terminate();
|
||||||
|
}
|
||||||
|
# @TEST-END-FILE
|
Loading…
Add table
Add a link
Reference in a new issue