Merge "Improve Apache PID check on service restart"
This commit is contained in:
commit
bd522d07ea
|
@ -535,7 +535,8 @@ def restart_pid_check(service_name, ptable_string=None):
|
|||
@retry_on_exception(5, base_delay=3, exc_type=AssertionError)
|
||||
def check_pids_gone(svc_string):
|
||||
log("Checking no pids for {} exist".format(svc_string), level=INFO)
|
||||
assert(subprocess.call(["pgrep", svc_string]) == 1)
|
||||
assert(subprocess.call(["pgrep", svc_string, "--nslist", "pid",
|
||||
"--ns", str(os.getpid())]) == 1)
|
||||
|
||||
if not ptable_string:
|
||||
ptable_string = service_name
|
||||
|
|
|
@ -891,14 +891,18 @@ class TestKeystoneUtils(CharmTestCase):
|
|||
utils.restart_pid_check('apache2')
|
||||
self.service_stop.assert_called_once_with('apache2')
|
||||
self.service_start.assert_called_once_with('apache2')
|
||||
self.subprocess.call.assert_called_once_with(['pgrep', 'apache2'])
|
||||
self.subprocess.call.assert_called_once_with(
|
||||
['pgrep', 'apache2', '--nslist', 'pid', '--ns', str(os.getpid())]
|
||||
)
|
||||
|
||||
def test_restart_pid_check_ptable_string(self):
|
||||
self.subprocess.call.return_value = 1
|
||||
utils.restart_pid_check('apache2', ptable_string='httpd')
|
||||
self.service_stop.assert_called_once_with('apache2')
|
||||
self.service_start.assert_called_once_with('apache2')
|
||||
self.subprocess.call.assert_called_once_with(['pgrep', 'httpd'])
|
||||
self.subprocess.call.assert_called_once_with(
|
||||
['pgrep', 'httpd', '--nslist', 'pid', '--ns', str(os.getpid())]
|
||||
)
|
||||
|
||||
# Do not sleep() to speed up manual runs.
|
||||
@patch('charmhelpers.core.decorators.time')
|
||||
|
@ -910,9 +914,12 @@ class TestKeystoneUtils(CharmTestCase):
|
|||
self.service_start.assert_called_once_with('apache2')
|
||||
# self.subprocess.call.assert_called_once_with(['pgrep', 'httpd'])
|
||||
expected = [
|
||||
call(['pgrep', 'httpd']),
|
||||
call(['pgrep', 'httpd']),
|
||||
call(['pgrep', 'httpd']),
|
||||
call(['pgrep', 'httpd', '--nslist', 'pid', '--ns',
|
||||
str(os.getpid())]),
|
||||
call(['pgrep', 'httpd', '--nslist', 'pid', '--ns',
|
||||
str(os.getpid())]),
|
||||
call(['pgrep', 'httpd', '--nslist', 'pid', '--ns',
|
||||
str(os.getpid())])
|
||||
]
|
||||
self.assertEqual(self.subprocess.call.call_args_list, expected)
|
||||
|
||||
|
|
Loading…
Reference in New Issue