mirror of https://github.com/fail2ban/fail2ban
TST: flushLog to run correctly regardless of user/travis instigated logging level
parent
a4d4f7b8f8
commit
62e54424a7
|
@ -680,14 +680,24 @@ class TransmitterLogging(TransmitterBase):
|
||||||
l.warn("After flushlogs")
|
l.warn("After flushlogs")
|
||||||
with open(fn2,'r') as f:
|
with open(fn2,'r') as f:
|
||||||
line1 = f.next()
|
line1 = f.next()
|
||||||
#print line1
|
if line1.find('Changed logging target to') >= 0:
|
||||||
|
line1 = f.next()
|
||||||
self.assertTrue(line1.endswith("Before file moved\n"))
|
self.assertTrue(line1.endswith("Before file moved\n"))
|
||||||
line2 = f.next()
|
line2 = f.next()
|
||||||
#print line2
|
|
||||||
self.assertTrue(line2.endswith("After file moved\n"))
|
self.assertTrue(line2.endswith("After file moved\n"))
|
||||||
self.assertRaises(StopIteration, f.next)
|
try:
|
||||||
|
n = f.next()
|
||||||
|
if n.find("Command: ['flushlogs']") >=0:
|
||||||
|
self.assertRaises(StopIteration, f.next)
|
||||||
|
else:
|
||||||
|
self.fail("Exception StopIteration or Command: ['flushlogs'] expected. Got: %s" % n)
|
||||||
|
except StopIteration:
|
||||||
|
pass # on higher debugging levels this is expected
|
||||||
with open(fn,'r') as f:
|
with open(fn,'r') as f:
|
||||||
self.assertTrue(f.next().endswith("After flushlogs\n"))
|
line1 = f.next()
|
||||||
|
if line1.find('rollover performed on') >= 0:
|
||||||
|
line1 = f.next()
|
||||||
|
self.assertTrue(line1.endswith("After flushlogs\n"))
|
||||||
self.assertRaises(StopIteration, f.next)
|
self.assertRaises(StopIteration, f.next)
|
||||||
finally:
|
finally:
|
||||||
os.remove(fn2)
|
os.remove(fn2)
|
||||||
|
|
Loading…
Reference in New Issue