diff --git a/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/manager-1..stdout b/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/manager-1..stdout new file mode 100644 index 0000000000..21f258d510 --- /dev/null +++ b/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/manager-1..stdout @@ -0,0 +1 @@ +option changed, testport, 45/unknown, ../configfile diff --git a/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/manager-1.config.log b/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/manager-1.config.log new file mode 100644 index 0000000000..a9794564b3 --- /dev/null +++ b/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/manager-1.config.log @@ -0,0 +1,23 @@ +#separator \x09 +#set_separator , +#empty_field (empty) +#unset_field - +#path config +#open 2018-06-29-20-24-53 +#fields ts id old_value new_value location +#types time string string string string +1530303893.918762 testbool T F ../configfile +1530303893.918762 testcount 0 1 ../configfile +1530303893.918762 testcount 1 2 ../configfile +1530303893.918762 testint 0 -1 ../configfile +1530303893.918762 testenum SSH::LOG Conn::LOG ../configfile +1530303893.918762 testport 42/tcp 45/unknown ../configfile +1530303893.918762 testaddr 127.0.0.1 127.0.0.1 ../configfile +1530303893.918762 testaddr 127.0.0.1 2607:f8b0:4005:801::200e ../configfile +1530303893.918762 testinterval 1.0 sec 60.0 ../configfile +1530303893.918762 testtime 0.0 1507321987.0 ../configfile +1530303893.918762 test_set (empty) b,c,a,d,erdbeerschnitzel ../configfile +1530303893.918762 test_set b,c,a,d,erdbeerschnitzel \x28empty) ../configfile +1530303893.918762 test_set \x28empty) \x2d ../configfile +1530303893.918762 test_set_full 2,1,7,15,10,3 6,4,1,7,5,3 ../configfile +#close 2018-06-29-20-25-06 diff --git a/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/worker-1..stdout b/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/worker-1..stdout new file mode 100644 index 0000000000..b55e8dd13c --- /dev/null +++ b/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/worker-1..stdout @@ -0,0 +1,11 @@ +cluster_set_option, testtime, [data=broker::data{1507321987000000000ns}], ../configfile +cluster_set_option, testint, [data=broker::data{-1}], ../configfile +option changed, testport, 45/unknown, ../configfile +cluster_set_option, testport, [data=broker::data{45/?}], ../configfile +cluster_set_option, testinterval, [data=broker::data{60000000000ns}], ../configfile +cluster_set_option, test_set, [data=broker::data{{-}}], ../configfile +cluster_set_option, testaddr, [data=broker::data{2607:f8b0:4005:801::200e}], ../configfile +cluster_set_option, testenum, [data=broker::data{Conn::LOG}], ../configfile +cluster_set_option, testbool, [data=broker::data{F}], ../configfile +cluster_set_option, testcount, [data=broker::data{2}], ../configfile +cluster_set_option, test_set_full, [data=broker::data{{1, 3, 4, 5, 6, 7}}], ../configfile diff --git a/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/worker-2..stdout b/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/worker-2..stdout new file mode 100644 index 0000000000..b55e8dd13c --- /dev/null +++ b/testing/btest/Baseline/scripts.base.frameworks.config.read_config_cluster/worker-2..stdout @@ -0,0 +1,11 @@ +cluster_set_option, testtime, [data=broker::data{1507321987000000000ns}], ../configfile +cluster_set_option, testint, [data=broker::data{-1}], ../configfile +option changed, testport, 45/unknown, ../configfile +cluster_set_option, testport, [data=broker::data{45/?}], ../configfile +cluster_set_option, testinterval, [data=broker::data{60000000000ns}], ../configfile +cluster_set_option, test_set, [data=broker::data{{-}}], ../configfile +cluster_set_option, testaddr, [data=broker::data{2607:f8b0:4005:801::200e}], ../configfile +cluster_set_option, testenum, [data=broker::data{Conn::LOG}], ../configfile +cluster_set_option, testbool, [data=broker::data{F}], ../configfile +cluster_set_option, testcount, [data=broker::data{2}], ../configfile +cluster_set_option, test_set_full, [data=broker::data{{1, 3, 4, 5, 6, 7}}], ../configfile diff --git a/testing/btest/scripts/base/frameworks/config/read_config_cluster.bro b/testing/btest/scripts/base/frameworks/config/read_config_cluster.bro new file mode 100644 index 0000000000..d44518579f --- /dev/null +++ b/testing/btest/scripts/base/frameworks/config/read_config_cluster.bro @@ -0,0 +1,102 @@ +# @TEST-EXEC: btest-bg-run manager-1 BROPATH=$BROPATH:.. CLUSTER_NODE=manager-1 bro %INPUT +# @TEST-EXEC: sleep 1 +# @TEST-EXEC: btest-bg-run worker-1 BROPATH=$BROPATH:.. CLUSTER_NODE=worker-1 bro %INPUT +# @TEST-EXEC: btest-bg-run worker-2 BROPATH=$BROPATH:.. CLUSTER_NODE=worker-2 bro %INPUT +# @TEST-EXEC: btest-bg-wait 15 +# @TEST-EXEC: btest-diff manager-1/.stdout +# @TEST-EXEC: btest-diff worker-1/.stdout +# @TEST-EXEC: btest-diff worker-2/.stdout +# @TEST-EXEC: btest-diff manager-1/config.log + +@load base/frameworks/config + + +@TEST-START-FILE cluster-layout.bro +redef Cluster::nodes = { + ["manager-1"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=37757/tcp], + ["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=37760/tcp, $manager="manager-1", $interface="eth0"], + ["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=37761/tcp, $manager="manager-1", $interface="eth1"], +}; +@TEST-END-FILE + +@TEST-START-FILE configfile +testbool F +testcount 1 +testcount 2 +testcount 2 +testint -1 +testenum Conn::LOG +testport 45 +testaddr 127.0.0.1 +testaddr 2607:f8b0:4005:801::200e +testinterval 60 +testtime 1507321987 +test_set a,b,c,d,erdbeerschnitzel +test_vector 1,2,3,4,5,6 +test_set (empty) +test_set - +test_set_full 1,3,4,5,6,7 +@TEST-END-FILE + +redef Log::default_rotation_interval = 0secs; + +export { + option testbool: bool = T; + option testcount: count = 0; + option testint: int = 0; + option testenum = SSH::LOG; + option testport = 42/tcp; + option testaddr = 127.0.0.1; + option testtime = network_time(); + option testinterval = 1sec; + option teststring = "a"; + option test_set: set[string] = {}; + option test_set_full: set[count] = {1, 2, 3, 7, 10, 15}; + #option test_vector: vector of count = {}; +} + +event bro_init() + { + Config::read_config("../configfile"); + } + +event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string) + { + terminate(); + } + +function option_changed(ID: string, new_value: any, location: string): any + { + print "option changed", ID, new_value, location; + return new_value; + } + +event bro_init() &priority=5 + { + Option::set_change_handler("testport", option_changed, -100); + Option::set_change_handler("teststring", option_changed, -100); + } + +event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string) + { + terminate(); + } + +@if ( Cluster::is_enabled() && Cluster::local_node_type() == Cluster::MANAGER ) +event die() + { + terminate(); + } + +event Cluster::node_up(name: string, id: string) + { + schedule 10sec { die() }; + } +@endif + +module Config; + +event Config::cluster_set_option(ID: string, val: any, location: string) &priority=-10 + { + print "cluster_set_option", ID, val, location; + }