mirror of https://github.com/fail2ban/fail2ban
extend test-cases to check the database is still operable (not locked) after all the errors during the simulation
parent
3be82a9ce9
commit
bd54d472b3
|
@ -268,6 +268,7 @@ class DatabaseTest(LogCaptureTestCase):
|
||||||
self.assertEqual(readtickets[i].getIP(), ticket.getIP())
|
self.assertEqual(readtickets[i].getIP(), ticket.getIP())
|
||||||
self.assertEqual(len(readtickets[i].getMatches()), len(ticket.getMatches()))
|
self.assertEqual(len(readtickets[i].getMatches()), len(ticket.getMatches()))
|
||||||
|
|
||||||
|
self.pruneLog('[test-phase 2] simulate errors')
|
||||||
## simulate errors in dumps/loads:
|
## simulate errors in dumps/loads:
|
||||||
priorEnc = database.PREFER_ENC
|
priorEnc = database.PREFER_ENC
|
||||||
try:
|
try:
|
||||||
|
@ -287,6 +288,13 @@ class DatabaseTest(LogCaptureTestCase):
|
||||||
finally:
|
finally:
|
||||||
database.PREFER_ENC = priorEnc
|
database.PREFER_ENC = priorEnc
|
||||||
|
|
||||||
|
## check the database is still operable (not locked) after all the errors:
|
||||||
|
self.pruneLog('[test-phase 3] still operable?')
|
||||||
|
self.db.addBan(self.jail, FailTicket("127.0.0.8"))
|
||||||
|
readtickets = self.db.getBans(jail=self.jail)
|
||||||
|
self.assertEqual(len(readtickets), 15)
|
||||||
|
self.assertNotLogged("json loads failed", "json dumps failed")
|
||||||
|
|
||||||
def _testAdd3Bans(self):
|
def _testAdd3Bans(self):
|
||||||
self.testAddJail()
|
self.testAddJail()
|
||||||
for i in (1, 2, 3):
|
for i in (1, 2, 3):
|
||||||
|
|
Loading…
Reference in New Issue