mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add expiration to sqlite-cluster.btest
This commit is contained in:
parent
97a2ec379e
commit
fb165c5ef1
3 changed files with 32 additions and 10 deletions
|
@ -1,4 +1,6 @@
|
||||||
### 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.
|
||||||
worker-1, put result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<uninitialized>]
|
worker-1, put result 1, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<uninitialized>]
|
||||||
|
worker-1, put result 2, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<uninitialized>]
|
||||||
sqlite_data_written
|
sqlite_data_written
|
||||||
worker-1, [code=Storage::SUCCESS, error_str=<uninitialized>, value=5678]
|
worker-1, get result 1 after expiration, [code=Storage::SUCCESS, error_str=<uninitialized>, value=value1234]
|
||||||
|
worker-1, get result 2 after expiration, [code=Storage::KEY_NOT_FOUND, error_str=<uninitialized>, value=<uninitialized>]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
### 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.
|
||||||
sqlite_data_written
|
sqlite_data_written
|
||||||
worker-2, [code=Storage::SUCCESS, error_str=<uninitialized>, value=5678]
|
worker-2, get result 1 after expiration, [code=Storage::SUCCESS, error_str=<uninitialized>, value=value1234]
|
||||||
|
worker-2, get result 2 after expiration, [code=Storage::KEY_NOT_FOUND, error_str=<uninitialized>, value=<uninitialized>]
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# @TEST-EXEC: btest-bg-run manager ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=manager zeek -b %INPUT
|
# @TEST-EXEC: btest-bg-run manager ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=manager 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 -k 5
|
# @TEST-EXEC: btest-bg-wait -k 10
|
||||||
# @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
|
||||||
# @TEST-EXEC:
|
# @TEST-EXEC:
|
||||||
|
@ -20,11 +20,18 @@
|
||||||
@load policy/frameworks/storage/backend/sqlite
|
@load policy/frameworks/storage/backend/sqlite
|
||||||
@load policy/frameworks/cluster/experimental
|
@load policy/frameworks/cluster/experimental
|
||||||
|
|
||||||
|
redef Storage::expire_interval = 2 secs;
|
||||||
|
|
||||||
global sqlite_data_written: event() &is_used;
|
global sqlite_data_written: event() &is_used;
|
||||||
|
|
||||||
@if ( Cluster::local_node_type() == Cluster::WORKER )
|
@if ( Cluster::local_node_type() == Cluster::WORKER )
|
||||||
|
|
||||||
global backend: opaque of Storage::BackendHandle;
|
global backend: opaque of Storage::BackendHandle;
|
||||||
|
global key1: string = "key1234";
|
||||||
|
global value1: string = "value1234";
|
||||||
|
|
||||||
|
global key2: string = "key2345";
|
||||||
|
global value2: string = "value2345";
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
|
@ -40,13 +47,22 @@ event zeek_init()
|
||||||
backend = open_res$value;
|
backend = open_res$value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event check_removed()
|
||||||
|
{
|
||||||
|
local res = Storage::Sync::get(backend, key1);
|
||||||
|
print Cluster::node, "get result 1 after expiration", res;
|
||||||
|
|
||||||
|
res = Storage::Sync::get(backend, key2);
|
||||||
|
print Cluster::node, "get result 2 after expiration", res;
|
||||||
|
|
||||||
|
Storage::Sync::close_backend(backend);
|
||||||
|
terminate();
|
||||||
|
}
|
||||||
|
|
||||||
event sqlite_data_written()
|
event sqlite_data_written()
|
||||||
{
|
{
|
||||||
print "sqlite_data_written";
|
print "sqlite_data_written";
|
||||||
local res = Storage::Sync::get(backend, "1234");
|
schedule 5secs { check_removed() };
|
||||||
print Cluster::node, res;
|
|
||||||
Storage::Sync::close_backend(backend);
|
|
||||||
terminate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@else
|
@else
|
||||||
|
@ -72,8 +88,11 @@ event sqlite_data_written()
|
||||||
|
|
||||||
event Cluster::Experimental::cluster_started()
|
event Cluster::Experimental::cluster_started()
|
||||||
{
|
{
|
||||||
local res = Storage::Sync::put(backend, [ $key="1234", $value="5678" ]);
|
local res = Storage::Sync::put(backend, [ $key=key1, $value=value1 ]);
|
||||||
print Cluster::node, "put result", res;
|
print Cluster::node, "put result 1", res;
|
||||||
|
|
||||||
|
res = Storage::Sync::put(backend, [ $key=key2, $value=value2, $expire_time=2 sec ]);
|
||||||
|
print Cluster::node, "put result 2", res;
|
||||||
|
|
||||||
local e = Cluster::make_event(sqlite_data_written);
|
local e = Cluster::make_event(sqlite_data_written);
|
||||||
Cluster::publish(Cluster::manager_topic, e);
|
Cluster::publish(Cluster::manager_topic, e);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue