fix bats-test for freebsd (#1333)
This commit is contained in:
parent
c077668511
commit
0c35263c29
|
@ -97,15 +97,15 @@ declare stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "$FILE cscli config backup" {
|
@test "$FILE cscli config backup" {
|
||||||
tempdir=$(mktemp -u -p "${BATS_TEST_TMPDIR}")
|
backupdir=$(TMPDIR="${BATS_TEST_TMPDIR}" mktemp -u)
|
||||||
run -0 cscli config backup "${tempdir}"
|
run -0 cscli config backup "${backupdir}"
|
||||||
assert_output --partial "Starting configuration backup"
|
assert_output --partial "Starting configuration backup"
|
||||||
run -1 --separate-stderr cscli config backup "${tempdir}"
|
run -1 --separate-stderr cscli config backup "${backupdir}"
|
||||||
|
|
||||||
run -0 echo "$stderr"
|
run -0 echo "$stderr"
|
||||||
assert_output --partial "Failed to backup configurations"
|
assert_output --partial "Failed to backup configurations"
|
||||||
assert_output --partial "file exists"
|
assert_output --partial "file exists"
|
||||||
rm -rf -- "${tempdir:?}"
|
rm -rf -- "${backupdir:?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "$FILE cscli lapi status" {
|
@test "$FILE cscli lapi status" {
|
||||||
|
|
|
@ -61,11 +61,11 @@ declare stderr
|
||||||
|
|
||||||
@test "$FILE cscli config backup" {
|
@test "$FILE cscli config backup" {
|
||||||
yq 'del(.api.server)' -i "${CONFIG_DIR}/config.yaml"
|
yq 'del(.api.server)' -i "${CONFIG_DIR}/config.yaml"
|
||||||
tempdir=$(mktemp -u -p "${BATS_TEST_TMPDIR}")
|
backupdir=$(TMPDIR="${BATS_TEST_TMPDIR}" mktemp -u)
|
||||||
run -0 cscli config backup "${tempdir}"
|
run -0 cscli config backup "${backupdir}"
|
||||||
assert_output --partial "Starting configuration backup"
|
assert_output --partial "Starting configuration backup"
|
||||||
run -1 --separate-stderr cscli config backup "${tempdir}"
|
run -1 --separate-stderr cscli config backup "${backupdir}"
|
||||||
rm -rf -- "${tempdir:?}"
|
rm -rf -- "${backupdir:?}"
|
||||||
|
|
||||||
run -0 echo "$stderr"
|
run -0 echo "$stderr"
|
||||||
assert_output --partial "Failed to backup configurations"
|
assert_output --partial "Failed to backup configurations"
|
||||||
|
|
|
@ -66,15 +66,15 @@ config_disable_agent() {
|
||||||
|
|
||||||
@test "$FILE no agent: cscli config backup" {
|
@test "$FILE no agent: cscli config backup" {
|
||||||
config_disable_agent
|
config_disable_agent
|
||||||
tempdir=$(mktemp -u -p "${BATS_TEST_TMPDIR}")
|
backupdir=$(TMPDIR="${BATS_TEST_TMPDIR}" mktemp -u)
|
||||||
run -0 cscli config backup "${tempdir}"
|
run -0 cscli config backup "${backupdir}"
|
||||||
assert_output --partial "Starting configuration backup"
|
assert_output --partial "Starting configuration backup"
|
||||||
run -1 --separate-stderr cscli config backup "${tempdir}"
|
run -1 --separate-stderr cscli config backup "${backupdir}"
|
||||||
|
|
||||||
run -0 echo "$stderr"
|
run -0 echo "$stderr"
|
||||||
assert_output --partial "Failed to backup configurations"
|
assert_output --partial "Failed to backup configurations"
|
||||||
assert_output --partial "file exists"
|
assert_output --partial "file exists"
|
||||||
rm -rf -- "${tempdir:?}"
|
rm -rf -- "${backupdir:?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "$FILE no agent: lapi status should be ok" {
|
@test "$FILE no agent: lapi status should be ok" {
|
||||||
|
|
|
@ -57,15 +57,15 @@ config_disable_capi() {
|
||||||
|
|
||||||
@test "$FILE no agent: cscli config backup" {
|
@test "$FILE no agent: cscli config backup" {
|
||||||
config_disable_capi
|
config_disable_capi
|
||||||
tempdir=$(mktemp -u -p "${BATS_TEST_TMPDIR}")
|
backupdir=$(TMPDIR="${BATS_TEST_TMPDIR}" mktemp -u)
|
||||||
run -0 cscli config backup "${tempdir}"
|
run -0 cscli config backup "${backupdir}"
|
||||||
assert_output --partial "Starting configuration backup"
|
assert_output --partial "Starting configuration backup"
|
||||||
run -1 --separate-stderr cscli config backup "${tempdir}"
|
run -1 --separate-stderr cscli config backup "${backupdir}"
|
||||||
|
|
||||||
run -0 echo "$stderr"
|
run -0 echo "$stderr"
|
||||||
assert_output --partial "Failed to backup configurations"
|
assert_output --partial "Failed to backup configurations"
|
||||||
assert_output --partial "file exists"
|
assert_output --partial "file exists"
|
||||||
rm -rf -- "${tempdir:?}"
|
rm -rf -- "${backupdir:?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "$FILE without capi: cscli lapi status -> success" {
|
@test "$FILE without capi: cscli lapi status -> success" {
|
||||||
|
|
|
@ -30,7 +30,7 @@ teardown() {
|
||||||
#----------
|
#----------
|
||||||
|
|
||||||
@test "$FILE 1.1.1.172 has been banned" {
|
@test "$FILE 1.1.1.172 has been banned" {
|
||||||
tmpfile=$(mktemp -p "${BATS_TEST_TMPDIR}")
|
tmpfile=$(TMPDIR="${BATS_TEST_TMPDIR}" mktemp)
|
||||||
touch "${tmpfile}"
|
touch "${tmpfile}"
|
||||||
echo -e "---\nfilename: $tmpfile\nlabels:\n type: syslog\n" >>"${CONFIG_DIR}/acquis.yaml"
|
echo -e "---\nfilename: $tmpfile\nlabels:\n type: syslog\n" >>"${CONFIG_DIR}/acquis.yaml"
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ fi
|
||||||
|
|
||||||
wait_for_port() {
|
wait_for_port() {
|
||||||
for _ in $(seq 40); do
|
for _ in $(seq 40); do
|
||||||
nc -z localhost "$1" && return
|
nc -z localhost "$1" >/dev/null 2>&1 && return
|
||||||
sleep .05
|
sleep .05
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -59,7 +59,8 @@ stop_instance() {
|
||||||
if [ -f "${DAEMON_PID}" ]; then
|
if [ -f "${DAEMON_PID}" ]; then
|
||||||
# terminate quickly with extreme prejudice, all the application data will be
|
# terminate quickly with extreme prejudice, all the application data will be
|
||||||
# thrown away anyway. also terminate the child processes (notification plugin).
|
# thrown away anyway. also terminate the child processes (notification plugin).
|
||||||
PGID="$(ps --no-headers -p "$(cat "${DAEMON_PID}")" -o pgid | tr -d ' ')"
|
PGID="$(ps -o pgid= -p "$(cat "${DAEMON_PID}")" | tr -d ' ')"
|
||||||
|
# ps above should work on linux, freebsd, busybox..
|
||||||
if [ -n "${PGID}" ]; then
|
if [ -n "${PGID}" ]; then
|
||||||
kill -- "-${PGID}"
|
kill -- "-${PGID}"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -20,7 +20,7 @@ check_requirements() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v yq >/dev/null; then
|
if ! command -v yq >/dev/null; then
|
||||||
die "missing required program 'yq'. You can install it with 'GO111MODULE=on go get github.com/mikefarah/yq/v4'"
|
die "missing required program 'yq'. You can install it with 'GO111MODULE=on go get github.com/mikefarah/yq/v4' and add ~/go/bin to $PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SYSTEM=$(uname -s)
|
SYSTEM=$(uname -s)
|
||||||
|
|
Loading…
Reference in a new issue