mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Move the asserts to happen sooner and make sure the processes are getting killed properly
This commit is contained in:
parent
68b9aaa2cc
commit
3dbbdc8393
1 changed files with 33 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
|||
import subprocess
|
||||
import time
|
||||
|
||||
import pytest
|
||||
from pytestshellutils.exceptions import FactoryNotStarted
|
||||
|
@ -9,6 +10,7 @@ pytestmark = [
|
|||
|
||||
|
||||
def test_salt_master_as_daemon(salt_master_factory):
|
||||
max_grep_tries = 5
|
||||
for cli_option in ("-d", "--daemon"):
|
||||
try:
|
||||
with salt_master_factory.started(
|
||||
|
@ -18,6 +20,10 @@ def test_salt_master_as_daemon(salt_master_factory):
|
|||
except FactoryNotStarted:
|
||||
pass
|
||||
finally:
|
||||
assert salt_master_factory.impl._terminal_result.stdout == ""
|
||||
assert salt_master_factory.impl._terminal_result.stderr == ""
|
||||
assert salt_master_factory.impl._terminal_result.returncode == 0
|
||||
|
||||
# We are going to kill the possible child processes based on the entire cmdline
|
||||
# We know this is unique to these processes because of the unique name of the config files, for example
|
||||
cmdline = salt_master_factory.cmdline(cli_option)
|
||||
|
@ -27,13 +33,21 @@ def test_salt_master_as_daemon(salt_master_factory):
|
|||
stderr=subprocess.PIPE,
|
||||
).communicate()
|
||||
assert pkill_proc[1] == b""
|
||||
|
||||
assert salt_master_factory.impl._terminal_result.stdout == ""
|
||||
assert salt_master_factory.impl._terminal_result.stderr == ""
|
||||
assert salt_master_factory.impl._terminal_result.returncode == 0
|
||||
for _ in range(max_grep_tries):
|
||||
pgrep_proc = subprocess.Popen(
|
||||
["pgrep", "-f", " ".join(cmdline)],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
).communicate()
|
||||
if pgrep_proc[0] == b"" and pgrep_proc[1] == b"":
|
||||
break
|
||||
time.sleep(1)
|
||||
else:
|
||||
pytest.skip("Skipping this test because processes didn't kill in time.")
|
||||
|
||||
|
||||
def test_salt_minion_as_daemon(salt_minion_factory):
|
||||
max_grep_tries = 5
|
||||
for cli_option in ("-d", "--daemon"):
|
||||
try:
|
||||
with salt_minion_factory.started(
|
||||
|
@ -43,6 +57,10 @@ def test_salt_minion_as_daemon(salt_minion_factory):
|
|||
except FactoryNotStarted:
|
||||
pass
|
||||
finally:
|
||||
assert salt_minion_factory.impl._terminal_result.stdout == ""
|
||||
assert salt_minion_factory.impl._terminal_result.stderr == ""
|
||||
assert salt_minion_factory.impl._terminal_result.returncode == 0
|
||||
|
||||
# We are going to kill the possible child processes based on the entire cmdline
|
||||
# We know this is unique to these processes because of the unique name of the config files, for example
|
||||
cmdline = salt_minion_factory.cmdline(cli_option)
|
||||
|
@ -52,7 +70,14 @@ def test_salt_minion_as_daemon(salt_minion_factory):
|
|||
stderr=subprocess.PIPE,
|
||||
).communicate()
|
||||
assert pkill_proc[1] == b""
|
||||
|
||||
assert salt_minion_factory.impl._terminal_result.stdout == ""
|
||||
assert salt_minion_factory.impl._terminal_result.stderr == ""
|
||||
assert salt_minion_factory.impl._terminal_result.returncode == 0
|
||||
for _ in range(max_grep_tries):
|
||||
pgrep_proc = subprocess.Popen(
|
||||
["pgrep", "-f", " ".join(cmdline)],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
).communicate()
|
||||
if pgrep_proc[0] == b"" and pgrep_proc[1] == b"":
|
||||
break
|
||||
time.sleep(1)
|
||||
else:
|
||||
pytest.skip("Skipping this test because processes didn't kill in time.")
|
||||
|
|
Loading…
Add table
Reference in a new issue