-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BR]: Database repair test fails with sqlite 3.42.0 #3586
Comments
Thx for detailed description and comprehensive analysis. |
One way to do it would just be to mock it out more, I guess, if all we want to test is that fail2ban follows the path we want it to...instead of trying to produce a db that actually makes sqlite3 error out, we could just mock out sqlite3 and have the mock raise the desired exception. |
Well in that case it would be enough to create another test additionally to |
yeah, it's definitely awkward. the only benefit of the mock approach over just testing it directly would be that it would at least check we catch the currently-expected exception and call For downstream I've just disabled the test, I'll leave it up to you to decide what to do upstream as I can't find any great fix! |
This will anyway happen for truncate-4000 attempt, since there are 2 (one was restorable another not): fail2ban/fail2ban/tests/databasetestcase.py Line 126 in 8eac5f5
|
For completeness for the bug: see https://sqlite.org/forum/forumpost/c20515073f2ff970. |
Should be fixed in cabcc9b (tested on sqlite3 3.44.x from deb-sid). Thus closed. Don't hesitate to ping here, if it still broken on your side. |
The issue:
The database recovery test -
testRepairDb
infail2ban/tests/databasetestcase.py
- does not work with sqlite 3.42.0. The test case expects that the test database file truncated to 14000 bytes is considered corrupt by the sqlite3 Python library, but can be dumped by the sqlite3 console command. With sqlite versions before 3.42.0, that was the case. With 3.42.0, it no longer is. sqlite 3.42.0 fails to dump the test file truncated to 14000 bytes (or any size in 100 byte increments up to 14300 bytes). If I instead truncate the test file to 14400 bytes, sqlite 3.42.0 can dump it, but the sqlite3 Python library does not consider it corrupt. So I have not found a way to make the test work with sqlite 3.42.0.Steps to reproduce
Run the test case with sqlite 3.42.0 installed. You can also quite easily fiddle around with this at a console: copy out the test database file (
fail2ban/tests/files/database_v1.db
), truncate it to various lengths withtruncate
, and examine the output ofsqlite3 (testfilename.db) .dump
on the truncated versions. At lengths of 14400 bytes and longer, both old and new sqlite can dump it 'perfectly'. At lengths of 14300 bytes and shorter, old sqlite dumps a slightly messed-up version (with theCREATE INDEX logs_jail_path
statement truncated and several other statements missing); new sqlite just errors out withERROR: (11) database disk image is malformed
.Expected behavior
Test case should pass.
Observed behavior
Test case fails.
The text was updated successfully, but these errors were encountered: