mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add btest for brokerstore delete with complex index.
Slightly adapted. I wasn't sure how much guarantee we have around the change propagation when calling terminate() right after the delete. Flipped it around a bit, having the worker outlive the manger instead.
This commit is contained in:
parent
5c1df2b706
commit
bba07cea8b
3 changed files with 81 additions and 0 deletions
|
@ -0,0 +1,61 @@
|
|||
# @TEST-DOC: Test deletion of elements in a broker backed table with composite keys. Regression test for #3342.
|
||||
#
|
||||
# @TEST-PORT: BROKER_PORT1
|
||||
# @TEST-PORT: BROKER_PORT2
|
||||
#
|
||||
# @TEST-EXEC: btest-bg-run manager-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=manager-1 zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-bg-run worker-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-1 zeek -b %INPUT
|
||||
# @TEST-EXEC: btest-bg-wait 20
|
||||
# @TEST-EXEC: btest-diff manager-1/.stdout
|
||||
# @TEST-EXEC: btest-diff worker-1/.stdout
|
||||
|
||||
@load policy/frameworks/cluster/experimental
|
||||
|
||||
@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
|
||||
|
||||
function change_handler(t: table[string, count] of count, tpe: TableChange,
|
||||
k0: string, k1: count, v: count)
|
||||
{
|
||||
print Cluster::node, "change_handler", tpe, k0, k1, v;
|
||||
|
||||
# Terminate the manager when it sees the removed table element.
|
||||
if ( tpe == TABLE_ELEMENT_REMOVED && Cluster::local_node_type() == Cluster::MANAGER )
|
||||
terminate();
|
||||
}
|
||||
|
||||
global t: table[string, count] of count &backend=Broker::MEMORY &on_change=change_handler;
|
||||
|
||||
event zeek_done()
|
||||
{
|
||||
print Cluster::node, "zeek_done", t;
|
||||
}
|
||||
|
||||
# The worker populates the broker backed table and deletes a single entry,
|
||||
# then waits on the manager before terminating itself.
|
||||
@if ( Cluster::local_node_type() == Cluster::WORKER )
|
||||
event do_delete()
|
||||
{
|
||||
delete t["b", 2];
|
||||
}
|
||||
|
||||
event Cluster::Experimental::cluster_started()
|
||||
{
|
||||
print "Got cluster_started event";
|
||||
t["a", 1] = 12;
|
||||
t["b", 2] = 23;
|
||||
t["c", 3] = 42;
|
||||
|
||||
schedule 0.01sec { do_delete() };
|
||||
}
|
||||
|
||||
event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string)
|
||||
{
|
||||
print Cluster::node, "peer_lost";
|
||||
terminate();
|
||||
}
|
||||
@endif
|
Loading…
Add table
Add a link
Reference in a new issue