Add in a test to kill start.sh and then ensure that pihole-FTL is gracefully exited.
We add in some sleeps to ensure that the log file is being written to before we check it Log entry tests are based on many different passes of running this locally with all sorts of timeouts and sleeps, this seems to be the most consistent Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
parent
b41d50b94f
commit
374f6f2537
|
@ -52,9 +52,12 @@ ensure_basic_configuration() {
|
|||
# chown pihole:root "${PI_HOLE_BIN_DIR}/pihole"
|
||||
|
||||
mkdir -p /etc/pihole
|
||||
if [[ ! -f /etc/pihole/adlists.list ]]; then
|
||||
echo "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" > /etc/pihole/adlists.list
|
||||
if [[ -z "${PYTEST}" ]]; then
|
||||
if [[ ! -f /etc/pihole/adlists.list ]]; then
|
||||
echo "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" >/etc/pihole/adlists.list
|
||||
fi
|
||||
fi
|
||||
|
||||
chown -R pihole:pihole /etc/pihole
|
||||
|
||||
|
||||
|
|
|
@ -147,6 +147,12 @@ stop() {
|
|||
sleep 0.5
|
||||
done
|
||||
|
||||
# If we are running pytest, keep the container alive for a little longer
|
||||
# to allow the tests to complete
|
||||
if [[ ${PYTEST} ]]; then
|
||||
sleep 10
|
||||
fi
|
||||
|
||||
exit
|
||||
}
|
||||
|
||||
|
|
|
@ -11,3 +11,20 @@ def test_pihole_uid_env_var(docker):
|
|||
def test_pihole_gid_env_var(docker):
|
||||
func = docker.run("id -g pihole")
|
||||
assert "456" in func.stdout
|
||||
|
||||
|
||||
# We immediately remove the adlists.list file so that gravity does not attempt to download a default list
|
||||
# Wait 5 seconds for gravity to finish, then kill the start.sh script
|
||||
# Finally, tail the FTL log to see if it shuts down cleanly
|
||||
@pytest.mark.parametrize("test_args", ['-e "PH_VERBOSE=1"'])
|
||||
def test_pihole_ftl_clean_shutdown(docker):
|
||||
func = docker.run(
|
||||
"""
|
||||
sleep 5
|
||||
killall --signal 15 start.sh
|
||||
sleep 5
|
||||
tail -f /var/log/pihole-FTL.log
|
||||
"""
|
||||
)
|
||||
assert "INFO: Shutting down... // exit code 0 // jmpret 0" in func.stdout
|
||||
assert "INFO: ########## FTL terminated after" in func.stdout
|
||||
|
|
Loading…
Reference in New Issue