mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
Merge remote-tracking branch 'origin/topic/awelzel/deprecate-broker-auto-publish'
* origin/topic/awelzel/deprecate-broker-auto-publish: sumstats: Remove copy() for Broker::publish() calls broker/Publish: Use event time instead of network time broker/Eventhandler: Deprecate Broker::auto_publish() for v8.1 btest: Remove Broker::auto_publish() usages frameworks/control: Remove Broker::auto_publish() catch-and-release: Remove Broker::auto_publish() ssl/validate-certs: Remove Broker::auto_publish() sumstats: Remove Broker::auto_publish() cluster_started: No Broker::auto_publish() use openflow: Remove Broker::auto_publish() dhcp: Remove Broker::auto_publish() frameworks/notice: Remove Broker::auto_publish() netcontrol: Replace Broker::auto_publish() intel: Switch to Cluster::publish() broker: Support publish() of unspecified set() / table() types: Fix table() resulting in table_type->IsSet() == true
This commit is contained in:
commit
18bfdb8a2b
47 changed files with 705 additions and 279 deletions
|
@ -0,0 +1,12 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
receiver added peer: endpoint=127.0.0.1 msg=handshake successful
|
||||
ping, my-message-make-event, 0
|
||||
ping, my-message-args, 0
|
||||
ping_set, my-message-make-event, 0
|
||||
ping_set, my-message-args, 0
|
||||
ping, my-message-make-event, 0
|
||||
ping, my-message-args, 0
|
||||
ping_set, my-message-make-event, 0
|
||||
ping_set, my-message-args, 0
|
||||
ping, my-message-make-event, 0
|
||||
ping, my-message-args, 0
|
|
@ -0,0 +1,13 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
sender added peer: endpoint=127.0.0.1 msg=handshake successful
|
||||
pong, my-message-make-event, 0
|
||||
pong, my-message-args, 0
|
||||
pong_set, my-message-make-event, 0
|
||||
pong_set, my-message-args, 0
|
||||
pong, my-message-make-event, 0
|
||||
pong, my-message-args, 0
|
||||
pong_set, my-message-make-event, 0
|
||||
pong_set, my-message-args, 0
|
||||
pong, my-message-make-event, 0
|
||||
pong, my-message-args, 0
|
||||
sender lost peer: endpoint=127.0.0.1 msg=lost connection to remote peer
|
|
@ -0,0 +1,11 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
receiver added peer: endpoint=127.0.0.1 msg=handshake successful
|
||||
receiver got ping: my-message-a intended for 1989-12-12-22:00:00 published at 1989-12-12-22:00:00 stamped to 1989-12-12-22:00:00 (is_remote = T, intended_equals_stamped=T)
|
||||
receiver got ping: my-message-b intended for 1989-12-12-22:15:00 published at 1989-12-12-23:00:00 stamped to 1989-12-12-22:15:00 (is_remote = T, intended_equals_stamped=T)
|
||||
receiver got ping: my-message-c intended for 1989-12-12-22:30:00 published at 1989-12-12-23:00:00 stamped to 1989-12-12-22:30:00 (is_remote = T, intended_equals_stamped=T)
|
||||
receiver got ping: my-message-a intended for 1989-12-12-23:00:00 published at 1989-12-12-23:00:00 stamped to 1989-12-12-23:00:00 (is_remote = T, intended_equals_stamped=T)
|
||||
receiver got ping: my-message-b intended for 1989-12-12-23:15:00 published at 1989-12-13-00:00:00 stamped to 1989-12-12-23:15:00 (is_remote = T, intended_equals_stamped=T)
|
||||
receiver got ping: my-message-c intended for 1989-12-12-23:30:00 published at 1989-12-13-00:00:00 stamped to 1989-12-12-23:30:00 (is_remote = T, intended_equals_stamped=T)
|
||||
receiver got ping: my-message-a intended for 1989-12-13-00:00:00 published at 1989-12-13-00:00:00 stamped to 1989-12-13-00:00:00 (is_remote = T, intended_equals_stamped=T)
|
||||
receiver got ping: my-message-b intended for 1989-12-13-00:15:00 published at 1989-12-13-01:00:00 stamped to 1989-12-13-00:15:00 (is_remote = T, intended_equals_stamped=T)
|
||||
receiver got ping: my-message-c intended for 1989-12-13-00:30:00 published at 1989-12-13-01:00:00 stamped to 1989-12-13-00:30:00 (is_remote = T, intended_equals_stamped=T)
|
|
@ -0,0 +1,43 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
sender added peer: endpoint=127.0.0.1 msg=handshake successful
|
||||
>> Run 1 (1989-12-12-22:00:00)
|
||||
>>> Publish my-message-a intended for 1989-12-12-22:00:00 (current_event_time=1989-12-12-22:00:00, network_time=1989-12-12-22:00:00)
|
||||
>>> Publish my-message-b intended for 1989-12-12-22:15:00 (current_event_time=1989-12-12-22:15:00, network_time=1989-12-12-23:00:00)
|
||||
>>> Publish my-message-c intended for 1989-12-12-22:30:00 (current_event_time=1989-12-12-22:30:00, network_time=1989-12-12-23:00:00)
|
||||
>> Run 2 (1989-12-12-23:00:00)
|
||||
>>> Publish my-message-a intended for 1989-12-12-23:00:00 (current_event_time=1989-12-12-23:00:00, network_time=1989-12-12-23:00:00)
|
||||
>>> Publish my-message-b intended for 1989-12-12-23:15:00 (current_event_time=1989-12-12-23:15:00, network_time=1989-12-13-00:00:00)
|
||||
>>> Publish my-message-c intended for 1989-12-12-23:30:00 (current_event_time=1989-12-12-23:30:00, network_time=1989-12-13-00:00:00)
|
||||
>> Run 3 (1989-12-13-00:00:00)
|
||||
>>> Publish my-message-a intended for 1989-12-13-00:00:00 (current_event_time=1989-12-13-00:00:00, network_time=1989-12-13-00:00:00)
|
||||
>>> Publish my-message-b intended for 1989-12-13-00:15:00 (current_event_time=1989-12-13-00:15:00, network_time=1989-12-13-01:00:00)
|
||||
>>> Publish my-message-c intended for 1989-12-13-00:30:00 (current_event_time=1989-12-13-00:30:00, network_time=1989-12-13-01:00:00)
|
||||
>> Run 4 (1989-12-13-01:00:00)
|
||||
>>> Publish my-message-a intended for 1989-12-13-01:00:00 (current_event_time=1989-12-13-01:00:00, network_time=1989-12-13-01:00:00)
|
||||
>>> Publish my-message-b intended for 1989-12-13-01:15:00 (current_event_time=1989-12-13-01:15:00, network_time=1989-12-13-02:00:00)
|
||||
>>> Publish my-message-c intended for 1989-12-13-01:30:00 (current_event_time=1989-12-13-01:30:00, network_time=1989-12-13-02:00:00)
|
||||
>> Run 5 (1989-12-13-02:00:00)
|
||||
>>> Publish my-message-a intended for 1989-12-13-02:00:00 (current_event_time=1989-12-13-02:00:00, network_time=1989-12-13-02:00:00)
|
||||
>>> Publish my-message-b intended for 1989-12-13-02:15:00 (current_event_time=1989-12-13-02:15:00, network_time=1989-12-13-03:00:00)
|
||||
>>> Publish my-message-c intended for 1989-12-13-02:30:00 (current_event_time=1989-12-13-02:30:00, network_time=1989-12-13-03:00:00)
|
||||
>> Run 6 (1989-12-13-03:00:00)
|
||||
>>> Publish my-message-a intended for 1989-12-13-03:00:00 (current_event_time=1989-12-13-03:00:00, network_time=1989-12-13-03:00:00)
|
||||
>>> Publish my-message-b intended for 1989-12-13-03:15:00 (current_event_time=1989-12-13-03:15:00, network_time=1989-12-13-04:00:00)
|
||||
>>> Publish my-message-c intended for 1989-12-13-03:30:00 (current_event_time=1989-12-13-03:30:00, network_time=1989-12-13-04:00:00)
|
||||
>> Run 7 (1989-12-13-04:00:00)
|
||||
>>> Publish my-message-a intended for 1989-12-13-04:00:00 (current_event_time=1989-12-13-04:00:00, network_time=1989-12-13-04:00:00)
|
||||
>>> Publish my-message-b intended for 1989-12-13-04:15:00 (current_event_time=1989-12-13-04:15:00, network_time=1989-12-13-05:00:00)
|
||||
>>> Publish my-message-c intended for 1989-12-13-04:30:00 (current_event_time=1989-12-13-04:30:00, network_time=1989-12-13-05:00:00)
|
||||
>> Run 8 (1989-12-13-05:00:00)
|
||||
>>> Publish my-message-a intended for 1989-12-13-05:00:00 (current_event_time=1989-12-13-05:00:00, network_time=1989-12-13-05:00:00)
|
||||
>>> Publish my-message-b intended for 1989-12-13-05:15:00 (current_event_time=1989-12-13-05:15:00, network_time=1989-12-13-06:00:00)
|
||||
>>> Publish my-message-c intended for 1989-12-13-05:30:00 (current_event_time=1989-12-13-05:30:00, network_time=1989-12-13-06:00:00)
|
||||
>> Run 9 (1989-12-13-06:00:00)
|
||||
>>> Publish my-message-a intended for 1989-12-13-06:00:00 (current_event_time=1989-12-13-06:00:00, network_time=1989-12-13-06:00:00)
|
||||
>>> Publish my-message-b intended for 1989-12-13-06:15:00 (current_event_time=1989-12-13-06:15:00, network_time=1989-12-13-07:00:00)
|
||||
>>> Publish my-message-c intended for 1989-12-13-06:30:00 (current_event_time=1989-12-13-06:30:00, network_time=1989-12-13-07:00:00)
|
||||
>> Run 10 (1989-12-13-07:00:00)
|
||||
>>> Publish my-message-a intended for 1989-12-13-07:00:00 (current_event_time=1989-12-13-07:00:00, network_time=1989-12-13-07:00:00)
|
||||
sender lost peer: endpoint=127.0.0.1 msg=lost connection to remote peer
|
||||
>>> Publish my-message-b intended for 1989-12-13-07:15:00 (current_event_time=1989-12-13-07:15:00, network_time=1989-12-13-07:00:00)
|
||||
>>> Publish my-message-c intended for 1989-12-13-07:30:00 (current_event_time=1989-12-13-07:30:00, network_time=1989-12-13-07:00:00)
|
4
testing/btest/Baseline/language.unspecified/output
Normal file
4
testing/btest/Baseline/language.unspecified/output
Normal file
|
@ -0,0 +1,4 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
set()
|
||||
table()
|
||||
vector()
|
|
@ -1,4 +1,5 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
option changed, testcount, 1,
|
||||
option changed, testport, 44/tcp,
|
||||
option changed, teststring, b, comment
|
||||
option changed, testcount, 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.
|
||||
DHCP::aggregate_msgs, XXXXXXXXXX.XXXXXX, CHhAvVGS1DHFjwGM9
|
|
@ -0,0 +1,11 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
#separator \x09
|
||||
#set_separator ,
|
||||
#empty_field (empty)
|
||||
#unset_field -
|
||||
#path dhcp
|
||||
#open XXXX-XX-XX-XX-XX-XX
|
||||
#fields ts uids client_addr server_addr mac host_name client_fqdn domain requested_addr assigned_addr lease_time client_message server_message msg_types duration
|
||||
#types time set[string] addr addr string string string string addr addr interval string string vector[string] interval
|
||||
XXXXXXXXXX.XXXXXX CHhAvVGS1DHFjwGM9 192.168.0.10 10.10.0.1 00:0a:28:00:fa:42 - - - - 192.168.0.10 3600.000000 - - ACK 0.000000
|
||||
#close XXXX-XX-XX-XX-XX-XX
|
|
@ -0,0 +1,4 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
node_up, manager-1
|
||||
dhcp_message, CHhAvVGS1DHFjwGM9
|
||||
file_done
|
|
@ -28,11 +28,6 @@ global hll_data: event(data: opaque of cardinality);
|
|||
|
||||
@if ( Cluster::local_node_type() == Cluster::WORKER )
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::auto_publish(Cluster::manager_topic, hll_data);
|
||||
}
|
||||
|
||||
global runnumber: count &redef; # differentiate runs
|
||||
|
||||
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||
|
@ -84,7 +79,7 @@ event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|||
print hll_cardinality_estimate(c);
|
||||
}
|
||||
|
||||
event hll_data(c);
|
||||
Broker::publish(Cluster::manager_topic, hll_data, c);
|
||||
}
|
||||
|
||||
@endif
|
||||
|
|
|
@ -21,13 +21,12 @@ global ping: event(msg: string, c: count);
|
|||
event zeek_init()
|
||||
{
|
||||
Broker::subscribe("zeek/event/my_topic");
|
||||
Broker::auto_publish("zeek/event/my_topic", ping);
|
||||
Broker::peer("127.0.0.1", to_port(getenv("BROKER_PORT")));
|
||||
}
|
||||
|
||||
function send_event()
|
||||
{
|
||||
event ping("my-message", ++event_count);
|
||||
Broker::publish("zeek/event/my_topic", ping, "my-message", ++event_count);
|
||||
}
|
||||
|
||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
|
@ -63,15 +62,14 @@ global auto_handler: event(msg: string, c: count);
|
|||
global pong: event(msg: string, c: count);
|
||||
|
||||
event delayed_listen()
|
||||
{
|
||||
{
|
||||
Broker::listen("127.0.0.1", to_port(getenv("BROKER_PORT")));
|
||||
}
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::subscribe("zeek/event/my_topic");
|
||||
Broker::auto_publish("zeek/event/my_topic", pong);
|
||||
schedule 5secs { delayed_listen() };
|
||||
schedule 5secs { delayed_listen() };
|
||||
}
|
||||
|
||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
|
@ -96,7 +94,7 @@ event ping(msg: string, n: count)
|
|||
return;
|
||||
}
|
||||
|
||||
event pong(msg, n);
|
||||
Broker::publish("zeek/event/my_topic", pong, msg, n);
|
||||
}
|
||||
|
||||
@TEST-END-FILE
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# @TEST-DOC: Disabling an unrelated event group caused auto-publish to break because the remote event had no bodies and got disabled. This is a regression test it's not being done again.
|
||||
#
|
||||
# Remove in v8.1 when auto_publish() is removed.
|
||||
#
|
||||
# @TEST-GROUP: broker
|
||||
#
|
||||
# @TEST-PORT: BROKER_PORT
|
||||
|
|
121
testing/btest/broker/publish_unspecified_table.zeek
Normal file
121
testing/btest/broker/publish_unspecified_table.zeek
Normal file
|
@ -0,0 +1,121 @@
|
|||
# @TEST-DOC: Using table() or set() for a Broker::publish() or Broker::make_event() should do the right thing.
|
||||
#
|
||||
# @TEST-GROUP: broker
|
||||
#
|
||||
# @TEST-PORT: BROKER_PORT
|
||||
#
|
||||
# @TEST-EXEC: btest-bg-run recv "zeek -b ../recv.zeek >recv.out"
|
||||
# @TEST-EXEC: btest-bg-run send "zeek -b ../send.zeek >send.out"
|
||||
#
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: btest-diff recv/recv.out
|
||||
# @TEST-EXEC: btest-diff send/send.out
|
||||
|
||||
@TEST-START-FILE common.zeek
|
||||
type ResultTable: table[string] of count;
|
||||
type ResultSet : set[count];
|
||||
|
||||
global ping: event(msg: string, t: ResultTable) &is_used;
|
||||
global pong: event(msg: string, t: ResultTable) &is_used;
|
||||
|
||||
global ping_set: event(msg: string, s: ResultSet) &is_used;
|
||||
global pong_set: event(msg: string, s: ResultSet) &is_used;
|
||||
@TEST-END-FILE
|
||||
|
||||
@TEST-START-FILE send.zeek
|
||||
@load ./common.zeek
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global event_count = 0;
|
||||
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::subscribe("zeek/event/my_topic");
|
||||
Broker::peer("127.0.0.1", to_port(getenv("BROKER_PORT")));
|
||||
}
|
||||
|
||||
function send_events()
|
||||
{
|
||||
local e = Broker::make_event(ping, "my-message-make-event", table());
|
||||
Broker::publish("zeek/event/my_topic", e);
|
||||
Broker::publish("zeek/event/my_topic", ping, "my-message-args", table());
|
||||
|
||||
local es = Broker::make_event(ping_set, "my-message-make-event", set());
|
||||
Broker::publish("zeek/event/my_topic", es);
|
||||
Broker::publish("zeek/event/my_topic", ping_set, "my-message-args", set());
|
||||
}
|
||||
|
||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print fmt("sender added peer: endpoint=%s msg=%s", endpoint$network$address, msg);
|
||||
send_events();
|
||||
}
|
||||
|
||||
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print fmt("sender lost peer: endpoint=%s msg=%s", endpoint$network$address, msg);
|
||||
terminate();
|
||||
}
|
||||
|
||||
event pong(msg: string, t: ResultTable)
|
||||
{
|
||||
++event_count;
|
||||
print "pong", msg, |t|;
|
||||
}
|
||||
|
||||
event pong_set(msg: string, s: ResultSet)
|
||||
{
|
||||
++event_count;
|
||||
print "pong_set", msg, |s|;
|
||||
if ( event_count % 4 == 0 )
|
||||
send_events();
|
||||
}
|
||||
@TEST-END-FILE
|
||||
|
||||
|
||||
@TEST-START-FILE recv.zeek
|
||||
@load ./common.zeek
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
const events_to_recv = 8;
|
||||
global events_recv = 0;
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::subscribe("zeek/event/my_topic");
|
||||
Broker::listen("127.0.0.1", to_port(getenv("BROKER_PORT")));
|
||||
}
|
||||
|
||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print fmt("receiver added peer: endpoint=%s msg=%s", endpoint$network$address, msg);
|
||||
}
|
||||
|
||||
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print fmt("receiver lost peer: endpoint=%s msg=%s", endpoint$network$address, msg);
|
||||
}
|
||||
|
||||
event ping(msg: string, t: ResultTable)
|
||||
{
|
||||
++events_recv;
|
||||
print "ping", msg, |t|;
|
||||
Broker::publish("zeek/event/my_topic", pong, msg, t);
|
||||
}
|
||||
|
||||
event ping_set(msg: string, s: ResultSet)
|
||||
{
|
||||
++events_recv;
|
||||
if ( events_recv > events_to_recv )
|
||||
{
|
||||
terminate();
|
||||
return;
|
||||
}
|
||||
|
||||
print "ping_set", msg, |s|;
|
||||
Broker::publish("zeek/event/my_topic", pong_set, msg, s);
|
||||
}
|
||||
@TEST-END-FILE
|
|
@ -1,3 +1,5 @@
|
|||
# Remove in v8.1 when auto_publish() is gone.
|
||||
#
|
||||
# @TEST-GROUP: broker
|
||||
#
|
||||
# @TEST-PORT: BROKER_PORT
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Remove in v8.1 when auto_publish() is gone.
|
||||
#
|
||||
# Not compatible with -O C++ testing since includes two distinct scripts.
|
||||
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
|
||||
#
|
||||
|
|
92
testing/btest/broker/remote_event_schedule_ts.zeek
Normal file
92
testing/btest/broker/remote_event_schedule_ts.zeek
Normal file
|
@ -0,0 +1,92 @@
|
|||
# @TEST-DOC: Broker::publish() within a schedule event uses the intended timestamp, not the current network_time()
|
||||
#
|
||||
# Not compatible with -O C++ testing since includes two distinct scripts.
|
||||
# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1"
|
||||
#
|
||||
# @TEST-GROUP: broker
|
||||
#
|
||||
# @TEST-PORT: BROKER_PORT
|
||||
#
|
||||
# @TEST-EXEC: btest-bg-run recv "zeek -b ../recv.zeek >recv.out"
|
||||
# @TEST-EXEC: btest-bg-run send "zeek -b -r $TRACES/ticks-dns-1hr.pcap ../send.zeek >send.out"
|
||||
#
|
||||
# @TEST-EXEC: btest-bg-wait 5
|
||||
# @TEST-EXEC: btest-diff recv/recv.out
|
||||
# @TEST-EXEC: btest-diff send/send.out
|
||||
|
||||
# @TEST-START-FILE send.zeek
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global runs = 0;
|
||||
global ping: event(msg: string, intended_ts: time, publish_ts: time);
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
suspend_processing();
|
||||
Broker::subscribe("zeek/event/my_topic");
|
||||
Broker::peer("127.0.0.1", to_port(getenv("BROKER_PORT")));
|
||||
}
|
||||
|
||||
event send_ping(msg: string, intended_ts: time)
|
||||
{
|
||||
print fmt(">>> Publish %s intended for %D (current_event_time=%D, network_time=%D)",
|
||||
msg, intended_ts, current_event_time(), network_time());
|
||||
Broker::publish("zeek/event/my_topic", ping, msg, intended_ts, network_time());
|
||||
}
|
||||
|
||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print fmt("sender added peer: endpoint=%s msg=%s",
|
||||
endpoint$network$address, msg);
|
||||
continue_processing();
|
||||
}
|
||||
|
||||
event new_connection(c: connection)
|
||||
{
|
||||
print fmt(">> Run %s (%D)", ++runs, network_time());
|
||||
|
||||
event send_ping("my-message-a", network_time());
|
||||
schedule 30 mins { send_ping("my-message-c", network_time() + 30 mins) };
|
||||
schedule 15 mins { send_ping("my-message-b", network_time() + 15 mins) };
|
||||
}
|
||||
|
||||
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print fmt("sender lost peer: endpoint=%s msg=%s",
|
||||
endpoint$network$address, msg);
|
||||
terminate();
|
||||
}
|
||||
|
||||
# @TEST-END-FILE
|
||||
|
||||
|
||||
# @TEST-START-FILE recv.zeek
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global msg_count = 0;
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::subscribe("zeek/event/my_topic");
|
||||
Broker::listen("127.0.0.1", to_port(getenv("BROKER_PORT")));
|
||||
}
|
||||
|
||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print fmt("receiver added peer: endpoint=%s msg=%s", endpoint$network$address, msg);
|
||||
}
|
||||
|
||||
event ping(msg: string, intended_ts: time, publish_ts: time) &is_used
|
||||
{
|
||||
if ( ++msg_count >= 10 )
|
||||
{
|
||||
terminate();
|
||||
return;
|
||||
}
|
||||
|
||||
print fmt("receiver got ping: %s intended for %D published at %D stamped to %D (is_remote = %s, intended_equals_stamped=%s)",
|
||||
msg, intended_ts, publish_ts, current_event_time(), is_remote_event(), intended_ts == current_event_time());
|
||||
}
|
||||
# @TEST-END-FILE
|
|
@ -30,6 +30,7 @@ function print_index(k: any)
|
|||
|
||||
event done()
|
||||
{
|
||||
Broker::publish("zeek/events", done);
|
||||
terminate();
|
||||
}
|
||||
|
||||
|
@ -50,7 +51,6 @@ event inserted()
|
|||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::auto_publish("zeek/events", done);
|
||||
Broker::subscribe("zeek/");
|
||||
|
||||
h = Broker::create_master("test");
|
||||
|
@ -84,7 +84,11 @@ global query_timeout = 1sec;
|
|||
global h: opaque of Broker::Store;
|
||||
|
||||
|
||||
global inserted: event();
|
||||
event inserted()
|
||||
{
|
||||
# Propagate inserted()
|
||||
Broker::publish("zeek/events", inserted);
|
||||
}
|
||||
|
||||
function print_index(k: any)
|
||||
{
|
||||
|
@ -131,7 +135,6 @@ event lookup(stage: count)
|
|||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::auto_publish("zeek/events", inserted);
|
||||
Broker::subscribe("zeek/");
|
||||
Broker::listen("127.0.0.1", to_port(getenv("BROKER_PORT")));
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ event do_terminate()
|
|||
event print_something(i: int)
|
||||
{
|
||||
print "Something sender", i;
|
||||
Broker::publish("zeek/event/my_topic", print_something, i);
|
||||
}
|
||||
|
||||
event unpeer(endpoint: Broker::EndpointInfo)
|
||||
|
@ -39,7 +40,6 @@ event unpeer(endpoint: Broker::EndpointInfo)
|
|||
event zeek_init()
|
||||
{
|
||||
Broker::subscribe("zeek/event/my_topic");
|
||||
Broker::auto_publish("zeek/event/my_topic", print_something);
|
||||
Broker::peer("127.0.0.1", to_port(getenv("BROKER_PORT")));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ event zeek_init()
|
|||
Broker::listen_websocket("127.0.0.1", to_port(getenv("BROKER_PORT")));
|
||||
}
|
||||
|
||||
function send_event()
|
||||
event send_event()
|
||||
{
|
||||
++event_count;
|
||||
local e = Broker::make_event(ping, "my-message", event_count);
|
||||
|
@ -39,7 +39,7 @@ function send_event()
|
|||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print fmt("sender added peer: endpoint=%s msg=%s", endpoint$network$address, msg);
|
||||
send_event();
|
||||
event send_event();
|
||||
}
|
||||
|
||||
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||
|
@ -53,7 +53,11 @@ event pong(msg: string, n: count) &is_used
|
|||
print fmt("sender got pong: %s, %s network_time=%s current_event_time=%s",
|
||||
msg, n, network_time(), current_event_time());
|
||||
set_network_time(network_time() + 10sec);
|
||||
send_event();
|
||||
|
||||
# pong is a remote event and a Broker::publish() would take
|
||||
# current_event_time() as the network time for Broker::publish(),
|
||||
# prevent this by queuing a new send_event().
|
||||
event send_event();
|
||||
}
|
||||
|
||||
|
||||
|
|
7
testing/btest/language/unspecified.zeek
Normal file
7
testing/btest/language/unspecified.zeek
Normal file
|
@ -0,0 +1,7 @@
|
|||
# @TEST-DOC: Test representation of unspecified table, set and vector
|
||||
# @TEST-EXEC: zeek -b %INPUT >output
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output
|
||||
|
||||
print type_name(set());
|
||||
print type_name(table());
|
||||
print type_name(vector());
|
|
@ -51,15 +51,6 @@ event fully_connected(n: string)
|
|||
terminate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "sent fully_connected event";
|
||||
}
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::auto_publish(Cluster::logger_topic, fully_connected);
|
||||
}
|
||||
|
||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
|
@ -74,16 +65,14 @@ event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|||
print "termination condition met: shutting down";
|
||||
terminate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if ( Cluster::node == "manager-1" )
|
||||
|
||||
local expected_nodes = Cluster::node == "manager-1" ? 5 : 4;
|
||||
if ( peer_count == expected_nodes )
|
||||
{
|
||||
if ( peer_count == 5 )
|
||||
event fully_connected(Cluster::node);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( peer_count == 4 )
|
||||
event fully_connected(Cluster::node);
|
||||
Broker::publish(Cluster::logger_topic, fully_connected, Cluster::node);
|
||||
print "sent fully_connected event";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,6 @@ redef Cluster::nodes = {
|
|||
};
|
||||
@TEST-END-FILE
|
||||
|
||||
global fully_connected: event();
|
||||
|
||||
global peer_count = 0;
|
||||
|
||||
global fully_connected_nodes = 0;
|
||||
|
@ -49,11 +47,6 @@ event fully_connected()
|
|||
}
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::auto_publish(Cluster::manager_topic, fully_connected);
|
||||
}
|
||||
|
||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print "Connected to a peer";
|
||||
|
@ -67,7 +60,7 @@ event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|||
else
|
||||
{
|
||||
if ( peer_count == 3 )
|
||||
event fully_connected();
|
||||
Broker::publish(Cluster::manager_topic, fully_connected);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,6 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
|||
terminate();
|
||||
}
|
||||
|
||||
global ready_for_data: event();
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
||||
}
|
||||
|
||||
@if ( Cluster::node == "worker-1" )
|
||||
event Cluster::Experimental::cluster_started()
|
||||
{
|
||||
|
|
|
@ -38,10 +38,6 @@ global n = 0;
|
|||
|
||||
event ready_for_data()
|
||||
{
|
||||
@if ( Cluster::node == "manager-1" )
|
||||
Config::set_value("testcount", 1);
|
||||
@endif
|
||||
|
||||
@if ( Cluster::node == "worker-1" )
|
||||
Config::set_value("testport", 44/tcp);
|
||||
Config::set_value("teststring", "b", "comment");
|
||||
|
@ -66,7 +62,6 @@ function option_changed(ID: string, new_value: any, location: string): any
|
|||
|
||||
event zeek_init() &priority=5
|
||||
{
|
||||
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
||||
Option::set_change_handler("testport", option_changed, -100);
|
||||
Option::set_change_handler("teststring", option_changed, -100);
|
||||
Option::set_change_handler("testcount", option_changed, -100);
|
||||
|
@ -79,9 +74,11 @@ event Cluster::node_up(name: string, id: string) &priority=-5
|
|||
{
|
||||
++peer_count;
|
||||
if ( peer_count == 1 )
|
||||
event ready_for_data();
|
||||
{
|
||||
Config::set_value("testcount", 1);
|
||||
Broker::publish(Cluster::worker_topic, ready_for_data);
|
||||
}
|
||||
}
|
||||
|
||||
@endif
|
||||
|
||||
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||
|
|
|
@ -50,9 +50,7 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
|||
terminate();
|
||||
}
|
||||
|
||||
global ready_for_data: event();
|
||||
|
||||
event ready_for_data()
|
||||
event ready_for_data() &is_used
|
||||
{
|
||||
if ( Cluster::node == "worker-1" )
|
||||
{
|
||||
|
@ -74,8 +72,6 @@ event ready_for_data()
|
|||
SumStats::observe("test", [$host=7.2.1.5], [$num=91]);
|
||||
SumStats::observe("test", [$host=10.10.10.10], [$num=5]);
|
||||
}
|
||||
|
||||
did_data = T;
|
||||
}
|
||||
|
||||
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
||||
|
@ -91,7 +87,8 @@ event second_test()
|
|||
event send_ready_for_data()
|
||||
{
|
||||
print "Sending ready for data";
|
||||
event ready_for_data();
|
||||
Broker::publish(Cluster::worker_topic, ready_for_data);
|
||||
did_data = T;
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,10 +101,4 @@ event Cluster::Experimental::cluster_started()
|
|||
schedule 5secs { send_ready_for_data() };
|
||||
schedule 10secs { second_test() };
|
||||
}
|
||||
|
||||
event zeek_init() &priority=100
|
||||
{
|
||||
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
||||
}
|
||||
|
||||
@endif
|
||||
|
|
71
testing/btest/scripts/base/protocols/dhcp/cluster.zeek
Normal file
71
testing/btest/scripts/base/protocols/dhcp/cluster.zeek
Normal file
|
@ -0,0 +1,71 @@
|
|||
# Test in cluster mode, the manager produces the cluster.log
|
||||
#
|
||||
# @TEST-PORT: BROKER_PORT1
|
||||
# @TEST-PORT: BROKER_PORT2
|
||||
#
|
||||
# @TEST-EXEC: zeek -b --parse-only %INPUT
|
||||
# @TEST-EXEC: btest-bg-run manager-1 "cp ../cluster-layout.zeek . && CLUSTER_NODE=manager-1 zeek -b %INPUT"
|
||||
# @TEST-EXEC: btest-bg-run worker-1 "cp ../cluster-layout.zeek . && CLUSTER_NODE=worker-1 zeek -b --pseudo-realtime -C -r $TRACES/dhcp/dhcp_ack_subscriber_id_and_agent_remote_id.trace %INPUT"
|
||||
|
||||
# @TEST-EXEC: btest-bg-wait 10
|
||||
# @TEST-EXEC: btest-diff worker-1/.stdout
|
||||
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||
# @TEST-EXEC: btest-diff manager-1/dhcp.log
|
||||
|
||||
@TEST-START-FILE cluster-layout.zeek
|
||||
redef Cluster::nodes = {
|
||||
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
||||
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
||||
};
|
||||
@TEST-END-FILE
|
||||
|
||||
@load base/protocols/dhcp
|
||||
@load base/frameworks/broker
|
||||
@load base/frameworks/cluster
|
||||
@load base/frameworks/logging
|
||||
|
||||
redef Log::default_rotation_interval = 0secs;
|
||||
redef Log::default_rotation_postprocessor_cmd = "echo";
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
redef Broker::disable_ssl = T;
|
||||
redef Cluster::manager_is_logger = T;
|
||||
|
||||
event terminate_me() {
|
||||
terminate();
|
||||
}
|
||||
|
||||
@if ( Cluster::local_node_type() == Cluster::WORKER )
|
||||
event zeek_init()
|
||||
{
|
||||
suspend_processing();
|
||||
}
|
||||
|
||||
event Cluster::node_up(name: string, id: string)
|
||||
{
|
||||
print "node_up", name;
|
||||
continue_processing();
|
||||
}
|
||||
|
||||
event dhcp_message(c: connection, is_orig: bool, msg: DHCP::Msg, options: DHCP::Options)
|
||||
{
|
||||
print "dhcp_message", c$uid;
|
||||
}
|
||||
|
||||
event Pcap::file_done(path: string)
|
||||
{
|
||||
print "file_done";
|
||||
terminate();
|
||||
}
|
||||
@else
|
||||
|
||||
event DHCP::aggregate_msgs(ts: time, id: conn_id, uid: string, is_orig: bool, msg: DHCP::Msg, options: DHCP::Options) &priority=5
|
||||
{
|
||||
print "DHCP::aggregate_msgs", ts, uid;
|
||||
}
|
||||
|
||||
event Cluster::node_down(name: string, id: string)
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
@endif
|
|
@ -34,10 +34,7 @@ event zeek_init()
|
|||
# notify_agent_hello event has arrived. The controller doesn't normally
|
||||
# talk to the supervisor, so connect to it.
|
||||
if ( Management::role == Management::CONTROLLER )
|
||||
{
|
||||
Broker::peer(getenv("ZEEK_DEFAULT_LISTEN_ADDRESS"), Broker::default_port, Broker::default_listen_retry);
|
||||
Broker::auto_publish(SupervisorControl::topic_prefix, SupervisorControl::stop_request);
|
||||
}
|
||||
}
|
||||
|
||||
event Management::Agent::API::notify_agent_hello(instance: string, id: string, connecting: bool, api_version: count)
|
||||
|
@ -50,7 +47,7 @@ event Management::Agent::API::notify_agent_hello(instance: string, id: string, c
|
|||
logged = T;
|
||||
|
||||
# This takes down the whole process tree.
|
||||
event SupervisorControl::stop_request();
|
||||
Broker::publish(SupervisorControl::topic_prefix, SupervisorControl::stop_request);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue