mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00

This is a cluster-layout.zeek template that can be copied into a testing directory if needed. The idea is that a developer sets environment variables within their btest and the Cluster::nodes variable is implicitly extended by appropriate nodes. For example, using @TEST-PORT BROKER_LOGGER1_PORT will add an appropriate logger-1 node to Cluster::nodes, based on the existence of the BROKER_LOGGER1_PORT environment variable.
85 lines
2.7 KiB
Text
85 lines
2.7 KiB
Text
#
|
|
# Use this file in a test by copying it into the tests directory:
|
|
#
|
|
# @TEST-EXEC: cp $FILES/broker/cluster-layout.zeek .
|
|
#
|
|
# Then specify @TEST-PORT using the following:
|
|
#
|
|
# BROKER_MANAGER_PORT
|
|
# BROKER_LOGGER1_PORT
|
|
# BROKER_LOGGER2_PORT
|
|
# BROKER_PROXY1_PORT
|
|
# BROKER_PROXY2_PORT
|
|
# BROKER_WORKER1_PORT
|
|
# BROKER_WORKER2_PORT
|
|
# BROKER_WORKER3_PORT
|
|
# BROKER_WORKER4_PORT
|
|
#
|
|
# The existence of the environment variable will add a corresponding node
|
|
# to Cluster::nodes.
|
|
|
|
|
|
# Redef'ed to F if logger-1 or logger-2 are active.
|
|
redef Cluster::manager_is_logger = T;
|
|
|
|
# Minimal cluster-layout for two nodes.
|
|
redef Cluster::nodes = {
|
|
["manager"] = [$node_type=Cluster::MANAGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_MANAGER_PORT"))],
|
|
};
|
|
|
|
# Depending on what environment variables are set, extend the Cluster::nodes table
|
|
# with more nodes. This allows tests to control the contents of Cluster::nodes
|
|
# just by using TEST-PORT accordingly to the used environment variables.
|
|
|
|
### Loggers
|
|
@if ( getenv("BROKER_LOGGER1_PORT") != "" )
|
|
redef Cluster::manager_is_logger = F;
|
|
redef Cluster::nodes += {
|
|
["logger-1"] = [$node_type=Cluster::LOGGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_LOGGER1_PORT")), $manager="manager"],
|
|
};
|
|
@endif
|
|
|
|
@if ( getenv("BROKER_LOGGER2_PORT") != "" )
|
|
redef Cluster::manager_is_logger = F;
|
|
redef Cluster::nodes += {
|
|
["logger-2"] = [$node_type=Cluster::LOGGER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_LOGGER2_PORT")), $manager="manager"],
|
|
};
|
|
@endif
|
|
|
|
### Proxies
|
|
@if ( getenv("BROKER_PROXY1_PORT") != "" )
|
|
redef Cluster::nodes += {
|
|
["proxy-1"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PROXY1_PORT")), $manager="manager"],
|
|
};
|
|
@endif
|
|
|
|
@if ( getenv("BROKER_PROXY2_PORT") != "" )
|
|
redef Cluster::nodes += {
|
|
["proxy-2"] = [$node_type=Cluster::PROXY, $ip=127.0.0.1, $p=to_port(getenv("BROKER_PROXY2_PORT")), $manager="manager"],
|
|
};
|
|
@endif
|
|
|
|
### Workers
|
|
@if ( getenv("BROKER_WORKER1_PORT") != "" )
|
|
redef Cluster::nodes += {
|
|
["worker-1"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_WORKER1_PORT")), $manager="manager"],
|
|
};
|
|
@endif
|
|
|
|
@if ( getenv("BROKER_WORKER2_PORT") != "" )
|
|
redef Cluster::nodes += {
|
|
["worker-2"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_WORKER2_PORT")), $manager="manager"],
|
|
};
|
|
@endif
|
|
|
|
@if ( getenv("BROKER_WORKER3_PORT") != "" )
|
|
redef Cluster::nodes += {
|
|
["worker-3"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_WORKER3_PORT")), $manager="manager"],
|
|
};
|
|
@endif
|
|
|
|
@if ( getenv("BROKER_WORKER4_PORT") != "" )
|
|
redef Cluster::nodes += {
|
|
["worker-4"] = [$node_type=Cluster::WORKER, $ip=127.0.0.1, $p=to_port(getenv("BROKER_WORKER4_PORT")), $manager="manager"],
|
|
};
|
|
@endif
|