diff --git a/testing/btest/Baseline/scripts.policy.frameworks.cluster.cluster_started/manager-1..stdout b/testing/btest/Baseline/scripts.policy.frameworks.cluster.cluster_started/manager-1..stdout new file mode 100644 index 0000000000..3a12b7c3b1 --- /dev/null +++ b/testing/btest/Baseline/scripts.policy.frameworks.cluster.cluster_started/manager-1..stdout @@ -0,0 +1,7 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +node fully connected +node fully connected +node fully connected +node fully connected +node fully connected +Got cluster_started event diff --git a/testing/btest/Baseline/scripts.policy.frameworks.cluster.cluster_started_logger/manager-1..stdout b/testing/btest/Baseline/scripts.policy.frameworks.cluster.cluster_started_logger/manager-1..stdout new file mode 100644 index 0000000000..5ec524f061 --- /dev/null +++ b/testing/btest/Baseline/scripts.policy.frameworks.cluster.cluster_started_logger/manager-1..stdout @@ -0,0 +1,8 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +node fully connected +node fully connected +node fully connected +node fully connected +node fully connected +node fully connected +Got cluster_started event diff --git a/testing/btest/scripts/policy/frameworks/cluster/cluster_started.zeek b/testing/btest/scripts/policy/frameworks/cluster/cluster_started.zeek new file mode 100644 index 0000000000..57f2671ff5 --- /dev/null +++ b/testing/btest/scripts/policy/frameworks/cluster/cluster_started.zeek @@ -0,0 +1,40 @@ +# @TEST-DOC: Run a simple cluster to verify cluster_started() and node_fully_connected() are generated. +# @TEST-PORT: BROKER_PORT1 +# @TEST-PORT: BROKER_PORT2 +# @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 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-2 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-2 zeek -b %INPUT +# @TEST-EXEC: btest-bg-wait 40 +# @TEST-EXEC: btest-diff manager-1/.stdout + +@load base/frameworks/cluster +@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"))], + ["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"], + ["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 + +redef Log::default_rotation_interval = 0secs; + +event Cluster::Experimental::node_fully_connected(name: string, id: string, resending: bool) + { + print "node fully connected"; + } + +event Cluster::Experimental::cluster_started() + { + print "Got cluster_started event"; + terminate(); + } diff --git a/testing/btest/scripts/policy/frameworks/cluster/cluster_started_logger.zeek b/testing/btest/scripts/policy/frameworks/cluster/cluster_started_logger.zeek new file mode 100644 index 0000000000..4781f3fe03 --- /dev/null +++ b/testing/btest/scripts/policy/frameworks/cluster/cluster_started_logger.zeek @@ -0,0 +1,43 @@ +# @TEST-DOC: Run a cluster that includes a dedicated logger to verify cluster_started() and node_fully_connected() are generated. +# @TEST-PORT: BROKER_PORT1 +# @TEST-PORT: BROKER_PORT2 +# @TEST-PORT: BROKER_PORT3 +# @TEST-PORT: BROKER_PORT4 +# @TEST-PORT: BROKER_PORT5 +# @TEST-PORT: BROKER_PORT6 +# +# @TEST-EXEC: btest-bg-run manager-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=manager-1 zeek -b %INPUT +# @TEST-EXEC: btest-bg-run logger-1 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=logger-1 zeek -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-2 ZEEKPATH=$ZEEKPATH:.. CLUSTER_NODE=worker-2 zeek -b %INPUT +# @TEST-EXEC: btest-bg-wait 40 +# @TEST-EXEC: btest-diff manager-1/.stdout + +@load base/frameworks/cluster +@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"))], + ["logger-1"] = [$node_type=Cluster::LOGGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT2"))], + ["proxy-1"] = [$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_PORT4")), $manager="manager-1"], + ["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT5")), $manager="manager-1", $interface="eth0"], + ["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PORT6")), $manager="manager-1", $interface="eth1"], +}; +@TEST-END-FILE + +redef Log::default_rotation_interval = 0secs; + +event Cluster::Experimental::node_fully_connected(name: string, id: string, resending: bool) + { + print "node fully connected"; + } + +event Cluster::Experimental::cluster_started() + { + print "Got cluster_started event"; + terminate(); + }