Skip to content

Commit

Permalink
Allow multiple arguments in setup_node
Browse files Browse the repository at this point in the history
  • Loading branch information
tobim committed Apr 8, 2024
1 parent 77a65c0 commit 2ee9a07
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tenzir/integration/lib/bats-tenzir/src/fixtures.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause

export_default_paths() {
BATS_TEST_DATADIR="$(realpath $(dirname ${BATS_TEST_DIRNAME}))"
BATS_TEST_DATADIR="$(realpath "$(dirname "${BATS_TEST_DIRNAME}")")"
# Look for the first folder called `integration/` that is a parent
# of the location of the test file.
export BATS_TENZIR_DATADIR="${BATS_TEST_DATADIR%%/integration/*}/data"
Expand All @@ -27,34 +27,32 @@ export_default_node_config() {

bats_tenzir_initialize() {
# Normalize the environment unless `BATS_TENZIR_KEEP_ENVIRONMENT` is set.
if [[ ! -n ${BATS_TENZIR_KEEP_ENVIRONMENT} ]]; then
unset $(printenv | grep -o '^TENZIR[^=]*' | paste -s -)
if [[ -z ${BATS_TENZIR_KEEP_ENVIRONMENT} ]]; then
unset "$(printenv | grep -o '^TENZIR[^=]*' | paste -s -)"
fi

export_default_paths
export_default_node_config
}

setup_node() {
local node_args=$1
# Always enforce bare mode even when using custom config.
export TENZIR_BARE_MODE=true
# Print node config
set | grep -Ee "^TENZIR" || true >&3
# The inner exec is needed so that signals to $NODE_PID actually reach the
# node.
exec {NODE_OUT}< <(exec tenzir-node --print-endpoint ${node_args})
exec {NODE_OUT}< <(exec tenzir-node --print-endpoint "${@}")
NODE_PID=$!
read -r -u "$NODE_OUT" TENZIR_ENDPOINT
export TENZIR_ENDPOINT
}

setup_node_with_plugins() {
local plugins=$1
local node_args=$2
export_default_node_config
export TENZIR_PLUGINS="$plugins"
setup_node ${node_args}
setup_node "${@:1}"
}

# Start a node with a configuration suitable for most integration tests.
Expand Down

0 comments on commit 2ee9a07

Please sign in to comment.