mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Simplify btests using cluster_started event.
This commit is contained in:
parent
4ddf7562b9
commit
342d88fbd4
30 changed files with 92 additions and 405 deletions
|
@ -1,10 +1 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
### NOTE: This file has been sorted with diff-sort.
|
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
Got fully_connected event
|
|
||||||
Got fully_connected event
|
|
||||||
Got fully_connected event
|
|
||||||
Got fully_connected event
|
|
||||||
|
|
|
@ -1,4 +1 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
|
|
|
@ -1,4 +1 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
|
|
|
@ -1,4 +1 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
|
|
|
@ -1,5 +1,2 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
Connected to a peer
|
|
||||||
got forwarded event
|
got forwarded event
|
||||||
|
|
|
@ -10,15 +10,13 @@
|
||||||
# @TEST-EXEC: btest-bg-wait 45
|
# @TEST-EXEC: btest-bg-wait 45
|
||||||
# @TEST-EXEC: btest-diff manager-1/.stdout
|
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
||||||
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
||||||
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
||||||
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT4")), $manager="manager-1", $interface="eth0"],
|
|
||||||
["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT5")), $manager="manager-1", $interface="eth1"],
|
|
||||||
};
|
};
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
@ -43,8 +41,6 @@ event zeek_init()
|
||||||
my_pool = Cluster::register_pool(my_pool_spec);
|
my_pool = Cluster::register_pool(my_pool_spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
global proxy_count = 0;
|
|
||||||
|
|
||||||
event go_away()
|
event go_away()
|
||||||
{
|
{
|
||||||
terminate();
|
terminate();
|
||||||
|
@ -78,20 +74,14 @@ function print_stuff(heading: string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
if ( Cluster::node != "manager-1" )
|
if ( Cluster::node != "manager-1" )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( name == "proxy-1" || name == "proxy-2" )
|
print_stuff("1st stuff");
|
||||||
++proxy_count;
|
local e = Broker::make_event(go_away);
|
||||||
|
Broker::publish(Cluster::node_topic("proxy-1"), e);
|
||||||
if ( proxy_count == 2 )
|
|
||||||
{
|
|
||||||
print_stuff("1st stuff");
|
|
||||||
local e = Broker::make_event(go_away);
|
|
||||||
Broker::publish(Cluster::node_topic("proxy-1"), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_down(name: string, id: string)
|
event Cluster::node_down(name: string, id: string)
|
||||||
|
|
|
@ -10,15 +10,13 @@
|
||||||
# @TEST-EXEC: btest-bg-wait 45
|
# @TEST-EXEC: btest-bg-wait 45
|
||||||
# @TEST-EXEC: btest-diff manager-1/.stdout
|
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
||||||
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
||||||
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
||||||
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT4")), $manager="manager-1", $interface="eth0"],
|
|
||||||
["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT5")), $manager="manager-1", $interface="eth1"],
|
|
||||||
};
|
};
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
@ -43,8 +41,6 @@ event zeek_init()
|
||||||
my_pool = Cluster::register_pool(my_pool_spec);
|
my_pool = Cluster::register_pool(my_pool_spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
global proxy_count = 0;
|
|
||||||
|
|
||||||
event go_away()
|
event go_away()
|
||||||
{
|
{
|
||||||
terminate();
|
terminate();
|
||||||
|
@ -78,20 +74,14 @@ function print_stuff(heading: string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
if ( Cluster::node != "manager-1" )
|
if ( Cluster::node != "manager-1" )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( name == "proxy-1" || name == "proxy-2" )
|
print_stuff("1st stuff");
|
||||||
++proxy_count;
|
local e = Broker::make_event(go_away);
|
||||||
|
Broker::publish(Cluster::node_topic("proxy-1"), e);
|
||||||
if ( proxy_count == 2 )
|
|
||||||
{
|
|
||||||
print_stuff("1st stuff");
|
|
||||||
local e = Broker::make_event(go_away);
|
|
||||||
Broker::publish(Cluster::node_topic("proxy-1"), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_down(name: string, id: string)
|
event Cluster::node_down(name: string, id: string)
|
||||||
|
|
|
@ -1,39 +1,25 @@
|
||||||
# @TEST-PORT: BROKER_PORT1
|
# @TEST-PORT: BROKER_PORT1
|
||||||
# @TEST-PORT: BROKER_PORT2
|
# @TEST-PORT: BROKER_PORT2
|
||||||
# @TEST-PORT: BROKER_PORT3
|
# @TEST-PORT: BROKER_PORT3
|
||||||
# @TEST-PORT: BROKER_PORT4
|
|
||||||
# @TEST-PORT: BROKER_PORT5
|
|
||||||
#
|
#
|
||||||
# @TEST-EXEC: btest-bg-run manager-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=manager-1 zeek -b %INPUT
|
# @TEST-EXEC: btest-bg-run manager-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=manager-1 zeek -B broker -b %INPUT
|
||||||
# @TEST-EXEC: btest-bg-run proxy-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=proxy-1 zeek -b %INPUT
|
|
||||||
# @TEST-EXEC: btest-bg-run proxy-2 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=proxy-2 zeek -b %INPUT
|
|
||||||
# @TEST-EXEC: btest-bg-run worker-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-1 zeek -b %INPUT
|
# @TEST-EXEC: btest-bg-run worker-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-1 zeek -b %INPUT
|
||||||
# @TEST-EXEC: btest-bg-run worker-2 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-2 zeek -b %INPUT
|
# @TEST-EXEC: btest-bg-run worker-2 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-2 zeek -b %INPUT
|
||||||
# @TEST-EXEC: btest-bg-wait 45
|
# @TEST-EXEC: btest-bg-wait 45
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff manager-1/.stdout
|
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||||
# @TEST-EXEC: btest-diff proxy-1/.stdout
|
|
||||||
# @TEST-EXEC: btest-diff proxy-2/.stdout
|
|
||||||
# @TEST-EXEC: btest-diff worker-1/.stdout
|
# @TEST-EXEC: btest-diff worker-1/.stdout
|
||||||
# @TEST-EXEC: btest-diff worker-2/.stdout
|
# @TEST-EXEC: btest-diff worker-2/.stdout
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
||||||
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1", $interface="eth0"],
|
||||||
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1", $interface="eth1"],
|
||||||
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT4")), $manager="manager-1", $interface="eth0"],
|
|
||||||
["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT5")), $manager="manager-1", $interface="eth1"],
|
|
||||||
};
|
};
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
global fully_connected: event();
|
|
||||||
|
|
||||||
global peer_count = 0;
|
|
||||||
global peers_lost = 0;
|
|
||||||
global fully_connected_nodes = 0;
|
|
||||||
|
|
||||||
redef Broker::forward_messages = T;
|
redef Broker::forward_messages = T;
|
||||||
|
|
||||||
event forwarded_event()
|
event forwarded_event()
|
||||||
|
@ -46,33 +32,17 @@ event forwarded_event()
|
||||||
terminate();
|
terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
event ready()
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
# note that the publishing node, worker-1, will not receive the forwarded
|
# note that the publishing node, worker-1, will not receive the forwarded
|
||||||
# event as Broker's forwarding prevents the message going back to the
|
# event as Broker's forwarding prevents the message going back to the
|
||||||
# immediate sender.
|
# immediate sender.
|
||||||
Broker::publish("test_topic", forwarded_event);
|
if ( Cluster::node == "worker-1" )
|
||||||
}
|
Broker::publish("test_topic", forwarded_event);
|
||||||
|
|
||||||
event fully_connected()
|
|
||||||
{
|
|
||||||
if ( ! is_remote_event() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
print "Got fully_connected event";
|
|
||||||
fully_connected_nodes = fully_connected_nodes + 1;
|
|
||||||
|
|
||||||
if ( Cluster::node == "manager-1" )
|
|
||||||
{
|
|
||||||
if ( peer_count == 4 && fully_connected_nodes == 4 )
|
|
||||||
Broker::publish(Cluster::node_topic("worker-1"), ready);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
Broker::auto_publish(Cluster::manager_topic, fully_connected);
|
|
||||||
|
|
||||||
if ( Cluster::node == "manager-1" )
|
if ( Cluster::node == "manager-1" )
|
||||||
Broker::forward("test_topic");
|
Broker::forward("test_topic");
|
||||||
if ( Cluster::node == "worker-1" )
|
if ( Cluster::node == "worker-1" )
|
||||||
|
@ -81,33 +51,7 @@ event zeek_init()
|
||||||
Broker::subscribe("test_topic");
|
Broker::subscribe("test_topic");
|
||||||
}
|
}
|
||||||
|
|
||||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|
||||||
{
|
|
||||||
print "Connected to a peer";
|
|
||||||
peer_count = peer_count + 1;
|
|
||||||
|
|
||||||
if ( Cluster::node == "manager-1" )
|
|
||||||
{
|
|
||||||
if ( peer_count == 4 && fully_connected_nodes == 4 )
|
|
||||||
Broker::publish(Cluster::node_topic("worker-1"), ready);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( peer_count == 3 )
|
|
||||||
event fully_connected();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||||
{
|
{
|
||||||
++peers_lost;
|
terminate();
|
||||||
|
|
||||||
if ( Cluster::node == "manager-1" )
|
|
||||||
{
|
|
||||||
if ( peers_lost == 2 )
|
|
||||||
# Both workers terminated
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
terminate();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
# @TEST-EXEC: btest-diff logger-1/test.log
|
# @TEST-EXEC: btest-diff logger-1/test.log
|
||||||
# @TEST-EXEC: btest-diff logger-10/test.log
|
# @TEST-EXEC: btest-diff logger-10/test.log
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::manager_is_logger = F;
|
redef Cluster::manager_is_logger = F;
|
||||||
|
@ -42,7 +42,6 @@ event zeek_init() &priority=5
|
||||||
Log::create_stream(Test::LOG, [$columns=Info, $path="test"]);
|
Log::create_stream(Test::LOG, [$columns=Info, $path="test"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
global peer_count = 0;
|
|
||||||
global c = 0;
|
global c = 0;
|
||||||
|
|
||||||
event go_away()
|
event go_away()
|
||||||
|
@ -63,23 +62,17 @@ event do_count()
|
||||||
schedule 0.01sec { do_count() };
|
schedule 0.01sec { do_count() };
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
print "node_up", name;
|
if ( Cluster::node != "worker-1" )
|
||||||
++peer_count;
|
return;
|
||||||
|
|
||||||
if ( Cluster::node == "worker-1" && peer_count == 3 )
|
Cluster::logger_pool$rr_key_seq["Cluster::rr_log_topic"] = 0;
|
||||||
{
|
schedule 0.25sec { do_count() };
|
||||||
Cluster::logger_pool$rr_key_seq["Cluster::rr_log_topic"] = 0;
|
|
||||||
schedule 0.25sec { do_count() };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_down(name: string, id: string)
|
event Cluster::node_down(name: string, id: string)
|
||||||
{
|
{
|
||||||
print "node_down", name;
|
|
||||||
--peer_count;
|
|
||||||
|
|
||||||
if ( name == "worker-1" )
|
if ( name == "worker-1" )
|
||||||
schedule 2sec { go_away() };
|
schedule 2sec { go_away() };
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,20 +10,16 @@
|
||||||
# @TEST-EXEC: btest-bg-wait 40
|
# @TEST-EXEC: btest-bg-wait 40
|
||||||
# @TEST-EXEC: btest-diff manager-1/.stdout
|
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
||||||
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
||||||
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
||||||
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT4")), $manager="manager-1", $interface="eth0"],
|
|
||||||
["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT5")), $manager="manager-1", $interface="eth1"],
|
|
||||||
};
|
};
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
global proxy_count = 0;
|
|
||||||
|
|
||||||
event go_away()
|
event go_away()
|
||||||
{
|
{
|
||||||
terminate();
|
terminate();
|
||||||
|
@ -48,20 +44,14 @@ function print_stuff(heading: string)
|
||||||
print "hrw", v[i], Cluster::hrw_topic(Cluster::proxy_pool, v[i]);
|
print "hrw", v[i], Cluster::hrw_topic(Cluster::proxy_pool, v[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
if ( Cluster::node != "manager-1" )
|
if ( Cluster::node != "manager-1" )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( name == "proxy-1" || name == "proxy-2" )
|
print_stuff("1st stuff");
|
||||||
++proxy_count;
|
local e = Broker::make_event(go_away);
|
||||||
|
Broker::publish(Cluster::node_topic("proxy-1"), e);
|
||||||
if ( proxy_count == 2 )
|
|
||||||
{
|
|
||||||
print_stuff("1st stuff");
|
|
||||||
local e = Broker::make_event(go_away);
|
|
||||||
Broker::publish(Cluster::node_topic("proxy-1"), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_down(name: string, id: string)
|
event Cluster::node_down(name: string, id: string)
|
||||||
|
|
|
@ -12,19 +12,16 @@
|
||||||
# @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
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT1"))],
|
||||||
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
||||||
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
||||||
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT4")), $manager="manager-1", $interface="eth0"],
|
|
||||||
["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT5")), $manager="manager-1", $interface="eth1"],
|
|
||||||
};
|
};
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
global proxy_count = 0;
|
|
||||||
global q = 0;
|
global q = 0;
|
||||||
|
|
||||||
event go_away()
|
event go_away()
|
||||||
|
@ -59,20 +56,14 @@ function send_stuff(heading: string)
|
||||||
distributed_event_rr, v[i]);
|
distributed_event_rr, v[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
if ( Cluster::node != "manager-1" )
|
if ( Cluster::node != "manager-1" )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( name == "proxy-1" || name == "proxy-2" )
|
send_stuff("1st stuff");
|
||||||
++proxy_count;
|
local e = Broker::make_event(go_away);
|
||||||
|
Broker::publish(Cluster::node_topic("proxy-1"), e);
|
||||||
if ( proxy_count == 2 )
|
|
||||||
{
|
|
||||||
send_stuff("1st stuff");
|
|
||||||
local e = Broker::make_event(go_away);
|
|
||||||
Broker::publish(Cluster::node_topic("proxy-1"), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_down(name: string, id: string)
|
event Cluster::node_down(name: string, id: string)
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# @TEST-EXEC: btest-diff manager-1/config.log
|
# @TEST-EXEC: btest-diff manager-1/config.log
|
||||||
|
|
||||||
@load base/frameworks/config
|
@load base/frameworks/config
|
||||||
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
|
@ -44,7 +44,7 @@ event zeek_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@if ( Cluster::node == "worker-1" )
|
@if ( Cluster::node == "worker-1" )
|
||||||
event ready_for_data()
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
Config::set_value("testport", 44/tcp);
|
Config::set_value("testport", 44/tcp);
|
||||||
Config::set_value("teststring", "b", "comment");
|
Config::set_value("teststring", "b", "comment");
|
||||||
|
@ -68,15 +68,3 @@ event zeek_init() &priority=5
|
||||||
Option::set_change_handler("testport", option_changed, -100);
|
Option::set_change_handler("testport", option_changed, -100);
|
||||||
Option::set_change_handler("teststring", option_changed, -100);
|
Option::set_change_handler("teststring", option_changed, -100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
|
||||||
|
|
||||||
global peer_count = 0;
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
|
||||||
{
|
|
||||||
++peer_count;
|
|
||||||
if ( peer_count == 2 )
|
|
||||||
event ready_for_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
@endif
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ redef Cluster::nodes = {
|
||||||
};
|
};
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
@load base/frameworks/intel
|
@load base/frameworks/intel
|
||||||
|
|
||||||
module Intel;
|
module Intel;
|
||||||
|
@ -41,33 +41,12 @@ redef Intel::send_store_on_node_up = F;
|
||||||
|
|
||||||
global log_writes = 0;
|
global log_writes = 0;
|
||||||
global worker_data = 0;
|
global worker_data = 0;
|
||||||
global proxy_ready = F;
|
|
||||||
global sent_data = F;
|
global sent_data = F;
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
if ( Cluster::local_node_type() == Cluster::PROXY &&
|
|
||||||
Cluster::get_active_node_count(Cluster::WORKER) == 2 )
|
|
||||||
{
|
|
||||||
# Make the proxy tell the manager explicitly when both workers
|
|
||||||
# have checked in. The cluster framework normally generates this
|
|
||||||
# event with the Broker ID as second argument. We borrow the
|
|
||||||
# event to signal readiness, using recognizable arguments.
|
|
||||||
Broker::publish(Cluster::manager_topic, Cluster::node_up, Cluster::node, Cluster::node);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( Cluster::local_node_type() == Cluster::MANAGER )
|
if ( Cluster::local_node_type() == Cluster::MANAGER )
|
||||||
{
|
Intel::insert([$indicator="1.2.3.4", $indicator_type=Intel::ADDR, $meta=[$source="manager"]]);
|
||||||
if ( name == "proxy-1" && id == "proxy-1" )
|
|
||||||
proxy_ready = T;
|
|
||||||
|
|
||||||
# Insert data once both workers and the proxy are connected, and
|
|
||||||
# the proxy has indicated that it too has both workers connected.
|
|
||||||
if ( Cluster::get_active_node_count(Cluster::WORKER) == 2 &&
|
|
||||||
Cluster::proxy_pool$alive_count == 1 && proxy_ready )
|
|
||||||
Intel::insert([$indicator="1.2.3.4", $indicator_type=Intel::ADDR, $meta=[$source="manager"]]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Watch for new indicators sent to workers.
|
# Watch for new indicators sent to workers.
|
||||||
|
|
|
@ -22,21 +22,18 @@ redef Cluster::nodes = {
|
||||||
};
|
};
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
@load base/frameworks/intel
|
@load base/frameworks/intel
|
||||||
|
|
||||||
module Intel;
|
module Intel;
|
||||||
|
|
||||||
redef Log::default_rotation_interval=0sec;
|
redef Log::default_rotation_interval=0sec;
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
# Insert the data once both workers are connected.
|
# Insert the data once both workers are connected.
|
||||||
if ( Cluster::local_node_type() == Cluster::MANAGER &&
|
if ( Cluster::local_node_type() == Cluster::MANAGER )
|
||||||
Cluster::get_active_node_count(Cluster::WORKER) == 2 )
|
|
||||||
{
|
|
||||||
Intel::insert([$indicator="1.2.3.4", $indicator_type=Intel::ADDR, $meta=[$source="manager"]]);
|
Intel::insert([$indicator="1.2.3.4", $indicator_type=Intel::ADDR, $meta=[$source="manager"]]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global log_writes = 0;
|
global log_writes = 0;
|
||||||
|
|
|
@ -28,6 +28,7 @@ e@mail.com Intel::EMAIL source1 Phishing email source http://some-data-distribut
|
||||||
|
|
||||||
@load base/frameworks/control
|
@load base/frameworks/control
|
||||||
@load base/frameworks/intel
|
@load base/frameworks/intel
|
||||||
|
@load policy/frameworks/cluster/experimental
|
||||||
redef Log::default_rotation_interval=0sec;
|
redef Log::default_rotation_interval=0sec;
|
||||||
|
|
||||||
module Intel;
|
module Intel;
|
||||||
|
@ -55,31 +56,16 @@ event do_it()
|
||||||
Broker::publish(Cluster::node_topic("manager-1"), do_it);
|
Broker::publish(Cluster::node_topic("manager-1"), do_it);
|
||||||
}
|
}
|
||||||
|
|
||||||
global hi_count = 0;
|
|
||||||
|
|
||||||
event start_it()
|
event start_it()
|
||||||
{
|
{
|
||||||
Broker::publish(Cluster::node_topic("worker-1"), do_it);
|
Broker::publish(Cluster::node_topic("worker-1"), do_it);
|
||||||
}
|
}
|
||||||
|
|
||||||
event hi()
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
if ( Cluster::node == "manager-1" )
|
if ( Cluster::node == "manager-1" )
|
||||||
{
|
# Give more time for intel distribution.
|
||||||
++hi_count;
|
schedule 1sec { start_it() };
|
||||||
|
|
||||||
if ( hi_count == 2 )
|
|
||||||
# Give more time for intel distribution.
|
|
||||||
schedule 1sec { start_it() };
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Broker::publish(Cluster::node_topic("manager-1"), hi);
|
|
||||||
}
|
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string) &priority=-100
|
|
||||||
{
|
|
||||||
if ( Cluster::node == "manager-1" )
|
|
||||||
Broker::publish(Cluster::node_topic(name), hi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event do_terminate()
|
event do_terminate()
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
# @TEST-EXEC: btest-diff manager-1/intel.log
|
# @TEST-EXEC: btest-diff manager-1/intel.log
|
||||||
|
|
||||||
@load base/frameworks/intel
|
@load base/frameworks/intel
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
# @TEST-START-FILE cluster-layout.zeek
|
# @TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
|
@ -41,8 +41,11 @@ event test_manager()
|
||||||
Broker::publish(Cluster::worker_topic, test_worker);
|
Broker::publish(Cluster::worker_topic, test_worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
event ready()
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
|
if ( Cluster::node != "manager-1" )
|
||||||
|
return;
|
||||||
|
|
||||||
# Insert the data once all workers are connected.
|
# Insert the data once all workers are connected.
|
||||||
Intel::insert([$indicator="192.168.0.1", $indicator_type=Intel::ADDR, $meta=[$source="source1"]]);
|
Intel::insert([$indicator="192.168.0.1", $indicator_type=Intel::ADDR, $meta=[$source="source1"]]);
|
||||||
Intel::insert([$indicator="192.168.0.2", $indicator_type=Intel::ADDR, $meta=[$source="source1"]]);
|
Intel::insert([$indicator="192.168.0.2", $indicator_type=Intel::ADDR, $meta=[$source="source1"]]);
|
||||||
|
@ -54,12 +57,6 @@ event ready()
|
||||||
event test_manager();
|
event test_manager();
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
|
||||||
{
|
|
||||||
if ( Cluster::node == "worker-1" )
|
|
||||||
Broker::publish(Cluster::manager_topic, ready);
|
|
||||||
}
|
|
||||||
|
|
||||||
event Intel::remove_item(item: Item, purge_indicator: bool)
|
event Intel::remove_item(item: Item, purge_indicator: bool)
|
||||||
{
|
{
|
||||||
print fmt("Removing %s (source: %s).", item$indicator, item$meta$source);
|
print fmt("Removing %s (source: %s).", item$indicator, item$meta$source);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# @TEST-EXEC: btest-bg-wait 20
|
# @TEST-EXEC: btest-bg-wait 20
|
||||||
# @TEST-EXEC: btest-diff manager-1/notice.log
|
# @TEST-EXEC: btest-diff manager-1/notice.log
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
@load base/frameworks/notice
|
@load base/frameworks/notice
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
|
@ -25,11 +25,6 @@ redef enum Notice::Type += {
|
||||||
Test_Notice,
|
Test_Notice,
|
||||||
};
|
};
|
||||||
|
|
||||||
event Cluster::node_down(name: string, id: string)
|
|
||||||
{
|
|
||||||
terminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
event delayed_notice()
|
event delayed_notice()
|
||||||
{
|
{
|
||||||
if ( Cluster::node == "worker-1" )
|
if ( Cluster::node == "worker-1" )
|
||||||
|
@ -41,27 +36,16 @@ event terminate_me()
|
||||||
terminate();
|
terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
event ready()
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
|
if ( Cluster::node != "worker-1" )
|
||||||
|
return;
|
||||||
|
|
||||||
schedule 1secs { delayed_notice() };
|
schedule 1secs { delayed_notice() };
|
||||||
schedule 2secs { terminate_me() };
|
schedule 2secs { terminate_me() };
|
||||||
}
|
}
|
||||||
|
|
||||||
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
|
||||||
|
|
||||||
global peer_count = 0;
|
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
|
||||||
{
|
|
||||||
peer_count = peer_count + 1;
|
|
||||||
|
|
||||||
if ( peer_count == 2 )
|
|
||||||
Broker::publish(Cluster::worker_topic, ready);
|
|
||||||
}
|
|
||||||
|
|
||||||
event Cluster::node_down(name: string, id: string)
|
event Cluster::node_down(name: string, id: string)
|
||||||
{
|
{
|
||||||
terminate();
|
terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@endif
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
# @TEST-EXEC: btest-diff manager-1/notice.log
|
# @TEST-EXEC: btest-diff manager-1/notice.log
|
||||||
|
|
||||||
@load base/frameworks/notice
|
@load base/frameworks/notice
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
|
@ -63,14 +63,9 @@ event Notice::begin_suppression(ts: time, suppress_for: interval, note: Notice::
|
||||||
|
|
||||||
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
||||||
|
|
||||||
global peer_count = 0;
|
event Cluster::Experimental::cluster_started()
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
|
||||||
{
|
{
|
||||||
peer_count = peer_count + 1;
|
Broker::publish(Cluster::node_topic("worker-2"), do_notice);
|
||||||
|
|
||||||
if ( peer_count == 3 )
|
|
||||||
Broker::publish(Cluster::node_topic("worker-2"), do_notice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global proceed_count = 0;
|
global proceed_count = 0;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff manager-1/.stdout
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff manager-1/.stdout
|
||||||
|
|
||||||
@load base/frameworks/sumstats
|
@load base/frameworks/sumstats
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
|
@ -49,9 +49,7 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||||
terminate();
|
terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
global ready_for_data: event();
|
event Cluster::Experimental::cluster_started()
|
||||||
|
|
||||||
event ready_for_data()
|
|
||||||
{
|
{
|
||||||
if ( Cluster::node == "worker-1" )
|
if ( Cluster::node == "worker-1" )
|
||||||
{
|
{
|
||||||
|
@ -76,22 +74,3 @@ event ready_for_data()
|
||||||
|
|
||||||
did_data = T;
|
did_data = T;
|
||||||
}
|
}
|
||||||
|
|
||||||
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
|
||||||
|
|
||||||
event zeek_init() &priority=100
|
|
||||||
{
|
|
||||||
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
global peer_count = 0;
|
|
||||||
|
|
||||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|
||||||
{
|
|
||||||
++peer_count;
|
|
||||||
|
|
||||||
if ( peer_count == 2 )
|
|
||||||
event ready_for_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
@endif
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff manager-1/.stdout
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff manager-1/.stdout
|
||||||
|
|
||||||
@load base/frameworks/sumstats
|
@load base/frameworks/sumstats
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
|
@ -95,7 +95,7 @@ event send_ready_for_data()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
event cont_test()
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
print "Performing first epoch, no observations";
|
print "Performing first epoch, no observations";
|
||||||
local ret = SumStats::next_epoch("test");
|
local ret = SumStats::next_epoch("test");
|
||||||
|
@ -110,14 +110,4 @@ event zeek_init() &priority=100
|
||||||
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
global peer_count = 0;
|
|
||||||
|
|
||||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|
||||||
{
|
|
||||||
++peer_count;
|
|
||||||
|
|
||||||
if ( peer_count == 2 )
|
|
||||||
event cont_test();
|
|
||||||
}
|
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# @TEST-EXEC: btest-diff manager-1/.stdout
|
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||||
#
|
#
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
@load base/frameworks/sumstats
|
@load base/frameworks/sumstats
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
|
@ -38,8 +38,6 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||||
terminate();
|
terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
global ready_for_data: event();
|
|
||||||
|
|
||||||
event on_demand()
|
event on_demand()
|
||||||
{
|
{
|
||||||
local host = 7.2.1.5;
|
local host = 7.2.1.5;
|
||||||
|
@ -63,7 +61,7 @@ event ready_to_demand()
|
||||||
event on_demand();
|
event on_demand();
|
||||||
}
|
}
|
||||||
|
|
||||||
event ready_for_data()
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
if ( Cluster::node == "worker-1" )
|
if ( Cluster::node == "worker-1" )
|
||||||
{
|
{
|
||||||
|
@ -82,15 +80,3 @@ event ready_for_data()
|
||||||
|
|
||||||
Broker::publish(Cluster::manager_topic, ready_to_demand);
|
Broker::publish(Cluster::manager_topic, ready_to_demand);
|
||||||
}
|
}
|
||||||
|
|
||||||
global peer_count = 0;
|
|
||||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|
||||||
{
|
|
||||||
if ( Cluster::node != "manager-1" )
|
|
||||||
return;
|
|
||||||
|
|
||||||
++peer_count;
|
|
||||||
if ( peer_count == 2 )
|
|
||||||
Broker::publish(Cluster::worker_topic, ready_for_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff manager-1/.stdout
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort btest-diff manager-1/.stdout
|
||||||
|
|
||||||
@load base/frameworks/sumstats
|
@load base/frameworks/sumstats
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
redef Cluster::nodes = {
|
redef Cluster::nodes = {
|
||||||
|
@ -52,15 +52,7 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||||
terminate();
|
terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
global ready_for_data: event();
|
event Cluster::Experimental::cluster_started()
|
||||||
|
|
||||||
event zeek_init()
|
|
||||||
{
|
|
||||||
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
event ready_for_data()
|
|
||||||
{
|
{
|
||||||
if ( Cluster::node == "worker-1" )
|
if ( Cluster::node == "worker-1" )
|
||||||
{
|
{
|
||||||
|
@ -112,15 +104,3 @@ event ready_for_data()
|
||||||
|
|
||||||
did_data = T;
|
did_data = T;
|
||||||
}
|
}
|
||||||
|
|
||||||
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
|
||||||
|
|
||||||
global peer_count = 0;
|
|
||||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|
||||||
{
|
|
||||||
++peer_count;
|
|
||||||
if ( peer_count == 2 )
|
|
||||||
event ready_for_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
@endif
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ redef Cluster::nodes = {
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
@load base/frameworks/sumstats
|
@load base/frameworks/sumstats
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
redef Log::default_rotation_interval = 0secs;
|
redef Log::default_rotation_interval = 0secs;
|
||||||
|
|
||||||
|
@ -57,14 +57,7 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||||
terminate();
|
terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
global ready_for_data: event();
|
event Cluster::Experimental::cluster_started()
|
||||||
|
|
||||||
event zeek_init()
|
|
||||||
{
|
|
||||||
Broker::auto_publish(Cluster::worker_topic, ready_for_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
event ready_for_data()
|
|
||||||
{
|
{
|
||||||
const loop_v: vector of count = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100};
|
const loop_v: vector of count = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100};
|
||||||
|
|
||||||
|
@ -105,16 +98,3 @@ event ready_for_data()
|
||||||
|
|
||||||
did_data = T;
|
did_data = T;
|
||||||
}
|
}
|
||||||
|
|
||||||
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
|
||||||
|
|
||||||
global peer_count = 0;
|
|
||||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
|
||||||
{
|
|
||||||
++peer_count;
|
|
||||||
if ( peer_count == 2 )
|
|
||||||
event ready_for_data();
|
|
||||||
}
|
|
||||||
|
|
||||||
@endif
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,16 @@
|
||||||
# @TEST-EXEC: btest-bg-wait 10
|
# @TEST-EXEC: btest-bg-wait 10
|
||||||
# @TEST-EXEC: btest-diff manager-1/.stdout
|
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@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"))],
|
||||||
|
["logger-1"] = [$node_type=Cluster::LOGGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
||||||
|
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
||||||
|
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT4")), $manager="manager-1", $interface="eth0"],
|
||||||
|
};
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
@load policy/frameworks/cluster/experimental
|
||||||
@load base/frameworks/telemetry
|
@load base/frameworks/telemetry
|
||||||
@load base/utils/active-http
|
@load base/utils/active-http
|
||||||
|
|
||||||
|
@ -57,8 +66,6 @@ event run_test()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
global node_count = 0;
|
|
||||||
|
|
||||||
@if ( Cluster::node == "manager-1" )
|
@if ( Cluster::node == "manager-1" )
|
||||||
# Use a dynamic metrics port for testing to avoid colliding on 9911/tcp
|
# Use a dynamic metrics port for testing to avoid colliding on 9911/tcp
|
||||||
# when running tests in parallel.
|
# when running tests in parallel.
|
||||||
|
@ -70,14 +77,11 @@ event zeek_init()
|
||||||
print Cluster::node, "original Broker::metrics_port", orig_metrics_port;
|
print Cluster::node, "original Broker::metrics_port", orig_metrics_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
++node_count;
|
# Run the test once all nodes are up and metrics_export_interval
|
||||||
# Run the test after all nodes are up and metrics_export_interval
|
|
||||||
# has passed at least once.
|
# has passed at least once.
|
||||||
if ( Cluster::node == "manager-1" )
|
schedule 2 * Broker::metrics_export_interval { run_test() };
|
||||||
if ( node_count == 3 )
|
|
||||||
schedule 2 * Broker::metrics_export_interval { run_test() };
|
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@ -87,12 +91,3 @@ event Cluster::node_down(name: string, id: string)
|
||||||
print fmt("node_down on %s", Cluster::node);
|
print fmt("node_down on %s", Cluster::node);
|
||||||
terminate();
|
terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@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"))],
|
|
||||||
["logger-1"] = [$node_type=Cluster::LOGGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2")), $manager="manager-1"],
|
|
||||||
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT3")), $manager="manager-1"],
|
|
||||||
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT4")), $manager="manager-1", $interface="eth0"],
|
|
||||||
};
|
|
||||||
@TEST-END-FILE
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# @TEST-EXEC: btest-bg-wait 40
|
# @TEST-EXEC: btest-bg-wait 40
|
||||||
# @TEST-EXEC: btest-diff manager-1/.stdout
|
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
|
||||||
@load policy/frameworks/cluster/experimental
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
# @TEST-EXEC: btest-bg-wait 40
|
# @TEST-EXEC: btest-bg-wait 40
|
||||||
# @TEST-EXEC: btest-diff manager-1/.stdout
|
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
|
||||||
@load policy/frameworks/cluster/experimental
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
@TEST-START-FILE cluster-layout.zeek
|
@TEST-START-FILE cluster-layout.zeek
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
# @TEST-EXEC: btest-diff zeek/worker-1/stdout
|
# @TEST-EXEC: btest-diff zeek/worker-1/stdout
|
||||||
# @TEST-EXEC: btest-diff zeek/proxy-1/stdout
|
# @TEST-EXEC: btest-diff zeek/proxy-1/stdout
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
|
||||||
@load policy/frameworks/cluster/experimental
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
# So the supervised node doesn't terminate right away.
|
# So the supervised node doesn't terminate right away.
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
# @TEST-EXEC: btest-diff zeek/worker-2/stdout
|
# @TEST-EXEC: btest-diff zeek/worker-2/stdout
|
||||||
# @TEST-EXEC: btest-diff zeek/proxy-1/stdout
|
# @TEST-EXEC: btest-diff zeek/proxy-1/stdout
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
|
||||||
@load policy/frameworks/cluster/experimental
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
# So the supervised node doesn't terminate right away.
|
# So the supervised node doesn't terminate right away.
|
||||||
|
|
|
@ -18,7 +18,7 @@ redef Cluster::nodes = {
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
@load misc/weird-stats
|
@load misc/weird-stats
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
redef Cluster::retry_interval = 1sec;
|
redef Cluster::retry_interval = 1sec;
|
||||||
redef Broker::default_listen_retry = 1sec;
|
redef Broker::default_listen_retry = 1sec;
|
||||||
|
@ -44,8 +44,11 @@ event ready_again()
|
||||||
schedule 5secs { terminate_me() };
|
schedule 5secs { terminate_me() };
|
||||||
}
|
}
|
||||||
|
|
||||||
event ready_for_data()
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
|
if ( Cluster::node == "manager-1" )
|
||||||
|
return;
|
||||||
|
|
||||||
local n = 0;
|
local n = 0;
|
||||||
|
|
||||||
if ( Cluster::node == "worker-1" )
|
if ( Cluster::node == "worker-1" )
|
||||||
|
@ -70,18 +73,3 @@ event ready_for_data()
|
||||||
|
|
||||||
schedule 5secs { ready_again() };
|
schedule 5secs { ready_again() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@if ( Cluster::local_node_type() == Cluster::MANAGER )
|
|
||||||
|
|
||||||
global peer_count = 0;
|
|
||||||
|
|
||||||
event Cluster::node_up(name: string, id: string)
|
|
||||||
{
|
|
||||||
++peer_count;
|
|
||||||
|
|
||||||
if ( peer_count == 2 )
|
|
||||||
Broker::publish(Cluster::worker_topic, ready_for_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@endif
|
|
||||||
|
|
|
@ -11,14 +11,13 @@
|
||||||
# @TEST-EXEC: btest-diff zeek/worker-1/stdout
|
# @TEST-EXEC: btest-diff zeek/worker-1/stdout
|
||||||
# @TEST-EXEC: btest-diff zeek/proxy-1/stdout
|
# @TEST-EXEC: btest-diff zeek/proxy-1/stdout
|
||||||
|
|
||||||
@load base/frameworks/cluster
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
# So the supervised node doesn't terminate right away.
|
# So the supervised node doesn't terminate right away.
|
||||||
redef exit_only_after_terminate=T;
|
redef exit_only_after_terminate=T;
|
||||||
|
|
||||||
global supervisor_output_file: file;
|
global supervisor_output_file: file;
|
||||||
global topic = "test-topic";
|
global topic = "test-topic";
|
||||||
global peer_count = 0;
|
|
||||||
|
|
||||||
event shutdown()
|
event shutdown()
|
||||||
{
|
{
|
||||||
|
@ -65,19 +64,10 @@ event zeek_init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string)
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
|
||||||
++peer_count;
|
|
||||||
|
|
||||||
if ( Supervisor::is_supervised() )
|
|
||||||
{
|
|
||||||
if ( Cluster::node == "manager" && peer_count == 4 )
|
|
||||||
Broker::publish(topic, shutdown);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
|
||||||
{
|
{
|
||||||
|
if ( Cluster::node == "manager" )
|
||||||
|
Broker::publish(topic, shutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
event zeek_done()
|
event zeek_done()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue