Skip to content

Commit

Permalink
feat: Globally define LOGS_DIR for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cdalvaro committed Oct 26, 2024
1 parent e7cab16 commit b7da05c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export PLATFORM=${PLATFORM:-$(docker version --format='{{.Server.Os}}/{{.Server.
#----------------------------------------------------------------------------------------------------------------------
export BOOTUP_WAIT_SECONDS=${BOOTUP_WAIT_SECONDS:-60}

#--- ENV VARIABLE ---------------------------------------------------------------------------------------------------
# NAME: LOGS_DIR
# DESCRIPTION: The directory to store the logs. Default: 'logs'.
#----------------------------------------------------------------------------------------------------------------------
export LOGS_DIR="${SCRIPT_PATH:-$(mktemp salt_master_test.XXXXX)}/logs"

#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: cleanup
# DESCRIPTION: Clean up tasks.
Expand All @@ -63,7 +69,6 @@ function cleanup() {
fi

echo " - Removing logs ..."
LOGS_DIR="${SCRIPT_PATH}/logs"
if [[ -d "${LOGS_DIR}" ]]; then
for service in master minion api key; do
[[ -f "${LOGS_DIR}"/salt/"${service}".log ]] && rm -fv "${LOGS_DIR}"/salt/"${service}".log
Expand Down Expand Up @@ -132,7 +137,6 @@ function container_log() {
# DESCRIPTION: Print salt-master log.
#----------------------------------------------------------------------------------------------------------------------
function master_log() {
local LOGS_DIR="${SCRIPT_PATH}/logs"
local SALT_MASTER_LOG="${LOGS_DIR}/salt/master.log"

[[ -f "${SALT_MASTER_LOG}" ]] || return 0
Expand All @@ -145,7 +149,6 @@ function master_log() {
# DESCRIPTION: Print built-in salt-minion log.
#----------------------------------------------------------------------------------------------------------------------
function builtin_minion_log() {
local LOGS_DIR="${SCRIPT_PATH}/logs"
local SALT_MINION_LOG="${LOGS_DIR}/salt/minion.log"

[[ -f "${SALT_MINION_LOG}" ]] || return 0
Expand All @@ -172,7 +175,7 @@ function minion_log() {
function start_container_and_wait() {
# shellcheck disable=SC2206
local DOCKER_ARGS=($@)
local LOGS_DIR="${SCRIPT_PATH}/logs"

mkdir -p "${LOGS_DIR}"

# Common config
Expand Down

0 comments on commit b7da05c

Please sign in to comment.