btest: Remove Broker::auto_publish() usages

The ones that seemed to test Broker::auto_publish() were annotated
for removal.
This commit is contained in:
Arne Welzel 2024-11-06 16:49:00 +01:00
parent 927e936653
commit 455e05bc2e
14 changed files with 35 additions and 72 deletions

View file

@ -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,

View file

@ -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

View file

@ -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

View 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

View file

@ -1,3 +1,5 @@
# Remove in v8.1 when auto_publish() is gone.
#
# @TEST-GROUP: broker
#
# @TEST-PORT: BROKER_PORT

View file

@ -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"
#

View 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")));
}

View file

@ -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")));
}

View file

@ -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";
}
}

View file

@ -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);
}
}

View file

@ -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()
{

View file

@ -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)

View file

@ -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

View file

@ -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);
}
}