Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up dummy-ups code, behavior and logs; added NUT_DEBUG_PID option #2118

Merged
merged 21 commits into from
Oct 19, 2023
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
33a97c8
drivers/dummy-ups.c: clarify some debug messages
jimklimov Oct 18, 2023
c994849
drivers/dummy-ups.c: clarify a nested if/elif/... tree
jimklimov Oct 18, 2023
834bfb9
drivers/dummy-ups.c: reconcile method prototype with implem
jimklimov Oct 18, 2023
f5b495f
drivers/dummy-ups.c: clarify that "upsfd" is not really used in file-…
jimklimov Oct 18, 2023
1956b01
drivers/dummy-ups.c: use better-qualified "fn" rather than potentiall…
jimklimov Oct 18, 2023
45da143
drivers/dummy-ups.c: refactor prepare_filepath() into one helper method
jimklimov Oct 18, 2023
4dc9eae
drivers/dummy-ups.c: avoid blank line in debug logs
jimklimov Oct 18, 2023
76e2939
drivers/dummy-ups.c: bump (C) and version due to recent changes
jimklimov Oct 18, 2023
2db24c3
tests/NIT/nit.sh: better filter the processes we look at after sandbo…
jimklimov Oct 18, 2023
664097b
tests/NIT/nit.sh: testcase_sandbox_start_drivers_after_upsd(): bump t…
jimklimov Oct 18, 2023
06eb71f
tests/NIT/nit.sh: testcase_sandbox_start_drivers_after_upsd(): fix ma…
jimklimov Oct 18, 2023
2bca73b
tests/NIT/nit.sh: tag progress/report messages emitted by test cases …
jimklimov Oct 18, 2023
861b50e
tests/NIT/nit.sh: report driver PIDs when debugging
jimklimov Oct 18, 2023
9fbb5a7
tests/NIT/nit.sh: sandbox_start_drivers(): report success or failure
jimklimov Oct 18, 2023
21fe028
common/common.c: optionally support NUT_DEBUG_PID envvar presence to …
jimklimov Oct 18, 2023
ecc5031
tests/NIT/nit.sh: use NUT_DEBUG_PID envvar to help test-log readability
jimklimov Oct 18, 2023
7a30529
tests/NIT/nit.sh: use log_separator() before sandbox_forget_configs()…
jimklimov Oct 18, 2023
ec9172e
tests/NIT/nit.sh: tag more progress messages with respective testcase…
jimklimov Oct 18, 2023
72c985d
tests/NIT/nit.sh: testcase_sandbox_nutscanner_list(): fix reporting
jimklimov Oct 18, 2023
7701368
tests/NIT/nit.sh: avoid printing "Error:..." in successful cases
jimklimov Oct 18, 2023
71710c2
GitIgnore .ci*.txt* if some are left over in the NUT CI farm work area
jimklimov Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests/NIT/nit.sh: tag more progress messages with respective testcase…
…; revise upsd stopping after testcase_upsd_allow_no_device()

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov committed Oct 18, 2023

Unverified

This user has not yet uploaded their public signing key.
commit ec9172ef69081286e6bbb82b8ff13d0bbb47bb37
54 changes: 31 additions & 23 deletions tests/NIT/nit.sh
Original file line number Diff line number Diff line change
@@ -551,11 +551,11 @@ testcase_upsd_no_configs_at_all() {
log_info "[testcase_upsd_no_configs_at_all] Test UPSD without configs at all"
upsd -F
if [ "$?" = 0 ]; then
log_error "upsd should fail without configs"
log_error "[testcase_upsd_no_configs_at_all] upsd should fail without configs"
FAILED="`expr $FAILED + 1`"
FAILED_FUNCS="$FAILED_FUNCS testcase_upsd_no_configs_at_all"
else
log_info "OK, upsd failed to start in wrong conditions"
log_info "[testcase_upsd_no_configs_at_all] PASSED: upsd failed to start in wrong conditions"
PASSED="`expr $PASSED + 1`"
fi
}
@@ -566,11 +566,11 @@ testcase_upsd_no_configs_driver_file() {
generatecfg_upsd_trivial
upsd -F
if [ "$?" = 0 ]; then
log_error "upsd should fail without driver config file"
log_error "[testcase_upsd_no_configs_driver_file] upsd should fail without driver config file"
FAILED="`expr $FAILED + 1`"
FAILED_FUNCS="$FAILED_FUNCS testcase_upsd_no_configs_driver_file"
else
log_info "OK, upsd failed to start in wrong conditions"
log_info "[testcase_upsd_no_configs_driver_file] PASSED: upsd failed to start in wrong conditions"
PASSED="`expr $PASSED + 1`"
fi
}
@@ -582,11 +582,11 @@ testcase_upsd_no_configs_in_driver_file() {
generatecfg_ups_trivial
upsd -F
if [ "$?" = 0 ]; then
log_error "upsd should fail without drivers defined in config file"
log_error "[testcase_upsd_no_configs_in_driver_file] upsd should fail without drivers defined in config file"
FAILED="`expr $FAILED + 1`"
FAILED_FUNCS="$FAILED_FUNCS testcase_upsd_no_configs_in_driver_file"
else
log_info "OK, upsd failed to start in wrong conditions"
log_info "[testcase_upsd_no_configs_in_driver_file] PASSED: upsd failed to start in wrong conditions"
PASSED="`expr $PASSED + 1`"
fi
}
@@ -602,7 +602,7 @@ testcase_upsd_allow_no_device() {
fi
upsd -F &
PID_UPSD="$!"
log_debug "Tried to start UPSD as PID $PID_UPSD"
log_debug "[testcase_upsd_allow_no_device] Tried to start UPSD as PID $PID_UPSD"
sleep 2

COUNTDOWN=60
@@ -616,57 +616,65 @@ testcase_upsd_allow_no_device() {

if [ "$COUNTDOWN" -le 50 ] ; then
# Should not get to this, except on very laggy systems maybe
log_warn "Had to wait a few retries for the UPSD process to appear"
log_warn "[testcase_upsd_allow_no_device] Had to wait a few retries for the UPSD process to appear"
fi

res_testcase_upsd_allow_no_device=0
if [ "$COUNTDOWN" -gt 0 ] \
&& isPidAlive "$PID_UPSD" \
; then
log_info "OK, upsd is running"
log_info "[testcase_upsd_allow_no_device] OK, upsd is running"
PASSED="`expr $PASSED + 1`"

log_separator
log_info "Query listing from UPSD by UPSC (no devices configured yet) to test that UPSD responds to UPSC"
log_info "[testcase_upsd_allow_no_device] Query listing from UPSD by UPSC (no devices configured yet) to test that UPSD responds to UPSC"
if runcmd upsc -l localhost:$NUT_PORT ; then
:
else
# Note: avoid exact matching for stderr, because it can have Init SSL messages etc.
if echo "$CMDERR" | grep "Error: Server disconnected" >/dev/null ; then
log_warn "Retry once to rule out laggy systems"
log_warn "[testcase_upsd_allow_no_device] Retry once to rule out laggy systems"
sleep 3
runcmd upsc -l localhost:$NUT_PORT
fi
if echo "$CMDERR" | grep "Error: Server disconnected" >/dev/null ; then
log_warn "Retry once more to rule out very laggy systems"
log_warn "[testcase_upsd_allow_no_device] Retry once more to rule out very laggy systems"
sleep 15
runcmd upsc -l localhost:$NUT_PORT
fi
[ "$CMDRES" = 0 ] || die "upsd does not respond on port ${NUT_PORT} ($?): $CMDOUT"
[ "$CMDRES" = 0 ] || die "[testcase_upsd_allow_no_device] upsd does not respond on port ${NUT_PORT} ($?): $CMDOUT"
fi
if [ -n "$CMDOUT" ] ; then
log_error "got reply for upsc listing when none was expected: $CMDOUT"
log_error "[testcase_upsd_allow_no_device] got reply for upsc listing when none was expected: $CMDOUT"
FAILED="`expr $FAILED + 1`"
FAILED_FUNCS="$FAILED_FUNCS testcase_upsd_allow_no_device"
res_testcase_upsd_allow_no_device=1
else
log_info "OK, empty response as expected"
log_info "[testcase_upsd_allow_no_device] OK, empty response as expected"
PASSED="`expr $PASSED + 1`"
fi
else
log_error "upsd was expected to be running although no devices are defined; is ups.conf populated?"
log_error "[testcase_upsd_allow_no_device] upsd was expected to be running although no devices are defined; is ups.conf populated?"
ls -la "$NUT_CONFPATH/" || true
FAILED="`expr $FAILED + 1`"
FAILED_FUNCS="$FAILED_FUNCS testcase_upsd_allow_no_device"
res_testcase_upsd_allow_no_device=1
report_NUT_PORT

UPSD_RES=0
kill -15 $PID_UPSD
wait $PID_UPSD || UPSD_RES=$?
log_error "upsd exit-code was: $UPSD_RES"
return $UPSD_RES
fi

log_info "[testcase_upsd_allow_no_device] stopping upsd: $PID_UPSD"
UPSD_RES=0
kill -15 $PID_UPSD
wait $PID_UPSD
wait $PID_UPSD || UPSD_RES=$?
if [ "$res_testcase_upsd_allow_no_device" = 0 ] ; then
log_info "[testcase_upsd_allow_no_device] upsd exit-code was: $UPSD_RES"
else
log_error "[testcase_upsd_allow_no_device] upsd exit-code was: $UPSD_RES"
fi
if [ "$UPSD_RES" != 0 ]; then
return $UPSD_RES
fi
return $res_testcase_upsd_allow_no_device
}

testgroup_upsd_invalid_configs() {