mirror of https://github.com/fail2ban/fail2ban
disengage testExecuteTimeout test-case from -fast option, just make it faster (timeout shorter) in this case
parent
b011cf17b2
commit
b615ba49ff
|
@ -324,16 +324,13 @@ class CommandActionTest(LogCaptureTestCase):
|
||||||
self.assertLogged('HINT on 127: "Command not found"')
|
self.assertLogged('HINT on 127: "Command not found"')
|
||||||
|
|
||||||
def testExecuteTimeout(self):
|
def testExecuteTimeout(self):
|
||||||
unittest.F2B.SkipIfFast()
|
|
||||||
stime = time.time()
|
stime = time.time()
|
||||||
# Should take a minute
|
timeout = 1 if not unittest.F2B.fast else 0.01
|
||||||
self.assertFalse(CommandAction.executeCmd('sleep 30', timeout=1))
|
# Should take a 30 seconds (so timeout will occur)
|
||||||
|
self.assertFalse(CommandAction.executeCmd('sleep 30', timeout=timeout))
|
||||||
# give a test still 1 second, because system could be too busy
|
# give a test still 1 second, because system could be too busy
|
||||||
self.assertTrue(time.time() >= stime + 1 and time.time() <= stime + 2)
|
self.assertTrue(time.time() >= stime + timeout and time.time() <= stime + timeout + 1)
|
||||||
self.assertLogged(
|
self.assertLogged('sleep 30 -- timed out after')
|
||||||
'sleep 30 -- timed out after 1 seconds',
|
|
||||||
'sleep 30 -- timed out after 2 seconds'
|
|
||||||
)
|
|
||||||
self.assertLogged('sleep 30 -- killed with SIGTERM')
|
self.assertLogged('sleep 30 -- killed with SIGTERM')
|
||||||
|
|
||||||
def testExecuteTimeoutWithNastyChildren(self):
|
def testExecuteTimeoutWithNastyChildren(self):
|
||||||
|
|
Loading…
Reference in New Issue