From a1fd2c507e68d02fd30f707f6af7e302e629aebf Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 22 Dec 2017 13:00:29 +0100 Subject: [PATCH] method `waitForServerEnd` renamed into `stopAndWaitForServerEnd` (because will also stop the server) --- fail2ban/tests/fail2banclienttestcase.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fail2ban/tests/fail2banclienttestcase.py b/fail2ban/tests/fail2banclienttestcase.py index 11d1983e..1e2d1b33 100644 --- a/fail2ban/tests/fail2banclienttestcase.py +++ b/fail2ban/tests/fail2banclienttestcase.py @@ -304,7 +304,7 @@ def with_foreground_server_thread(startextra={}): th.start() # to wait for end of server, default accept any exit code, because multi-threaded, # thus server can exit in-between... - def _waitForServerEnd(code=(SUCCESS, FAILED)): + def _stopAndWaitForServerEnd(code=(SUCCESS, FAILED)): # if seems to be down - try to catch end phase (wait a bit for end:True to recognize down state): if not phase.get('end', None) and not os.path.exists(pjoin(tmp, "f2b.pid")): Utils.wait_for(lambda: phase.get('end', None) is not None, MID_WAITTIME) @@ -315,7 +315,7 @@ def with_foreground_server_thread(startextra={}): Utils.wait_for(lambda: phase.get('end', None) is not None, MAX_WAITTIME) self.assertTrue(phase.get('end', None)) self.assertLogged("Shutdown successful", "Exiting Fail2ban", all=True) - self.waitForServerEnd = _waitForServerEnd + self.stopAndWaitForServerEnd = _stopAndWaitForServerEnd # wait for start thread: Utils.wait_for(lambda: phase.get('start', None) is not None, MAX_WAITTIME) self.assertTrue(phase.get('start', None)) @@ -330,12 +330,12 @@ def with_foreground_server_thread(startextra={}): # wait for server end (if not yet already exited): DefLogSys.info('=== within server: end. ===') self.pruneLog() - self.waitForServerEnd() + self.stopAndWaitForServerEnd() # we start client/server directly in current process (new thread), # so don't kill (same process) - if success, just wait for end of worker: if phase.get('end', None): th.join() - self.waitForServerEnd = None + self.stopAndWaitForServerEnd = None return wrapper return _deco_wrapper @@ -1232,8 +1232,7 @@ class Fail2banServerTest(Fail2banClientServerBase): self.assertIn('\\125-000-004 1;\n', mp) # stop server and wait for end: - self.execCmd(SUCCESS, startparams, 'stop') - self.waitForServerEnd(SUCCESS) + self.stopAndWaitForServerEnd(SUCCESS) # check flushed (all sessions were deleted from map-file): self.assertLogged("[nginx-blck-lst] Flush ticket(s) with nginx-block-map")