stability of the test-cases: avoid echoing of server-ready in configure thread, if heavy-debug (only answer from new internal command "server-status").

pull/2087/head
sebres 2018-03-05 21:54:18 +01:00
parent cfc3979c84
commit 5b63ad17c6
2 changed files with 6 additions and 3 deletions

View File

@ -99,7 +99,7 @@ class Fail2banClient(Fail2banCmdLine, Thread):
ret = client.send(c)
if ret[0] == 0:
logSys.log(5, "OK : %r", ret[1])
if showRet or c[0] == 'echo':
if showRet or c[0] in ('echo', 'server-status'):
output(beautifier.beautify(ret[1]))
else:
logSys.error("NOK: %r", ret[1].args)
@ -128,7 +128,7 @@ class Fail2banClient(Fail2banCmdLine, Thread):
except Exception as e: # pragma: no cover
if showRet or self._conf["verbose"] > 1:
logSys.debug(e)
if showRet or c[0] == 'echo':
if showRet or c[0] in ('echo', 'server-status'):
sys.stdout.flush()
return streamRet
@ -186,7 +186,7 @@ class Fail2banClient(Fail2banCmdLine, Thread):
logSys.error("Fail2ban seems to be in unexpected state (not running but the socket exists)")
return None
stream.append(['echo', 'Server ready'])
stream.append(['server-status'])
return stream
##

View File

@ -115,6 +115,9 @@ class Transmitter:
return cnt
elif command[0] == "echo":
return command[1:]
elif command[0] == "server-status":
logSys.debug("Server ready")
return "Server ready"
elif command[0] == "sleep":
value = command[1]
time.sleep(float(value))