# Test that the install command can install a custom value of the broport
# broctl option.
#
# @TEST-EXEC: bash %INPUT
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-cluster-layout btest-diff no-logger
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-cluster-layout btest-diff two-loggers
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-cluster-layout btest-diff two-proxies

. broctl-test-setup

standalonelayout=$BROCTL_INSTALL_PREFIX/spool/installed-scripts-do-not-touch/auto/standalone-layout.bro
clusterlayout=$BROCTL_INSTALL_PREFIX/spool/installed-scripts-do-not-touch/auto/cluster-layout.bro

# Test a standalone config.

broctl install

# Verify that the test port number is not installed by default
! grep -q 41234 $standalonelayout

# Change the configuration to use a test port number
echo "broport=41234" >> $BROCTL_INSTALL_PREFIX/etc/broctl.cfg

broctl install

# Verify that the test port number was installed
grep -q 41234 $standalonelayout

# Test a cluster config with no logger node.

while read line; do installfile $line; done << EOF
etc/node.cfg__cluster
EOF

broctl install

cp $clusterlayout no-logger

# Test a cluster config with two logger nodes.

while read line; do installfile $line; done << EOF
etc/node.cfg__two_loggers
EOF

broctl install

cp $clusterlayout two-loggers

# Test a cluster config with two proxy nodes.

while read line; do installfile $line; done << EOF
etc/node.cfg__two_proxies
EOF

broctl install

cp $clusterlayout two-proxies
