mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-21 22:38:08 +00:00
Tweak tests to allow systemd as init system
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
95e799ed6e
commit
74b0904af4
@ -39,7 +39,7 @@ testinfra.backend.docker.DockerBackend.run = run_bash
|
|||||||
def host():
|
def host():
|
||||||
# run a container
|
# run a container
|
||||||
docker_id = (
|
docker_id = (
|
||||||
subprocess.check_output(["docker", "run", "-t", "-d", "--cap-add=ALL", IMAGE])
|
subprocess.check_output(["docker", "run", "-t", "-d", "--privileged", IMAGE])
|
||||||
.decode()
|
.decode()
|
||||||
.strip()
|
.strip()
|
||||||
)
|
)
|
||||||
|
@ -168,7 +168,10 @@ def test_installPihole_fresh_install_readableFiles(host):
|
|||||||
mock_command("dialog", {"*": ("", "0")}, host)
|
mock_command("dialog", {"*": ("", "0")}, host)
|
||||||
# mock git pull
|
# mock git pull
|
||||||
mock_command_passthrough("git", {"pull": ("", "0")}, host)
|
mock_command_passthrough("git", {"pull": ("", "0")}, host)
|
||||||
# mock systemctl to not start lighttpd and FTL
|
# if systemd is not PID 1 mock systemctl to not start lighttpd and FTL
|
||||||
|
init_system = host.run("cat /proc/1/comm")
|
||||||
|
print(init_system.stdout)
|
||||||
|
if "systemd" not in init_system.stdout:
|
||||||
mock_command_2(
|
mock_command_2(
|
||||||
"systemctl",
|
"systemctl",
|
||||||
{
|
{
|
||||||
@ -278,6 +281,7 @@ def test_installPihole_fresh_install_readableFiles(host):
|
|||||||
)
|
)
|
||||||
actual_rc = host.run(check_dnsmasqconf).rc
|
actual_rc = host.run(check_dnsmasqconf).rc
|
||||||
assert exit_status_success == actual_rc
|
assert exit_status_success == actual_rc
|
||||||
|
if "systemd" not in init_system.stdout:
|
||||||
# check readable and executable /etc/init.d/pihole-FTL
|
# check readable and executable /etc/init.d/pihole-FTL
|
||||||
check_init = test_cmd.format("x", "/etc/init.d/pihole-FTL", piholeuser)
|
check_init = test_cmd.format("x", "/etc/init.d/pihole-FTL", piholeuser)
|
||||||
actual_rc = host.run(check_init).rc
|
actual_rc = host.run(check_init).rc
|
||||||
@ -362,7 +366,9 @@ def test_installPihole_fresh_install_readableBlockpage(host, test_webpage):
|
|||||||
|
|
||||||
# mock git pull
|
# mock git pull
|
||||||
mock_command_passthrough("git", {"pull": ("", "0")}, host)
|
mock_command_passthrough("git", {"pull": ("", "0")}, host)
|
||||||
# mock systemctl to start lighttpd and FTL
|
init_system = host.run("cat /proc/1/comm")
|
||||||
|
if "systemd" not in init_system.stdout:
|
||||||
|
# if systemd is not PID 1 mock systemctl to not start lighttpd and FTL
|
||||||
ligthttpdcommand = dedent(
|
ligthttpdcommand = dedent(
|
||||||
r'''\"\"
|
r'''\"\"
|
||||||
echo 'starting lighttpd with {}'
|
echo 'starting lighttpd with {}'
|
||||||
|
@ -137,6 +137,9 @@ def test_getFTLPIDFile_and_getFTLPID_custom(host):
|
|||||||
host.run(
|
host.run(
|
||||||
"""
|
"""
|
||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
|
# adding a small delay here because otherwise there is some kind of
|
||||||
|
# race condition with systemd deleting files in /tmp
|
||||||
|
sleep 1
|
||||||
echo "PIDFILE=${tmpfile}" > /etc/pihole/pihole-FTL.conf
|
echo "PIDFILE=${tmpfile}" > /etc/pihole/pihole-FTL.conf
|
||||||
echo "1234" > ${tmpfile}
|
echo "1234" > ${tmpfile}
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user