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
0.10-cs: client-server rewritten as modules / start in foreground / test coverage for cs #1413
0.10-cs: client-server rewritten as modules / start in foreground / test coverage for cs #1413
Conversation
# Conflicts: # fail2ban/server/server.py
…ng start and daemonize) completely rewritten: - client/server functionality moved away from bin and using now the common interface (introduced in fail2bancmdline); - start in foreground fixed; - server can act as client corresponding command line; - command "restart" added: in opposite to "reload" in reality restarts the server (new process); - several client/server bugs during starting process fixed.
, closes fail2ban#1139 small code review and fixing of some bugs during client-server communication process (in the test cases);
…orker threads daemonized (to prevent hanging on exit).
…eview), wait 4 server ready, test cases fixed (py2/py3)
… of server/client (with or without fork)
coverage of test cases increased;
Current coverage is 92.11%@@ 0.10 #1413 diff @@
==========================================
Files 71 75 +4
Lines 9235 10168 +933
Methods 0 0
Messages 0 0
Branches 1399 1548 +149
==========================================
+ Hits 8437 9366 +929
+ Misses 567 536 -31
- Partials 231 266 +35
|
if verbosity > 2: | ||
fmt = ' +%(relativeCreated)5d %(thread)X %(levelname)-5.5s' + fmt | ||
else: | ||
fmt = ' %(asctime)-15s %(thread)X %(levelname)-5.5s' + fmt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems mixed indentation with spaces and tabs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Why didn't you listen to a wise man? #1139 (comment) |
@@ -386,6 +412,9 @@ def assertNotLogged(self, *s, **kwargs): | |||
def pruneLog(self): | |||
self._log.truncate(0) | |||
|
|||
def pruneLog(self): | |||
self._log.truncate(0) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
So please do first the move, send it as a PR, we merge it after tests pass, and hopefully this diff becomes manageable |
Because:
Wrong, it is possible - just compare:
My git does it automatically (it can find the code lines, moved from other files)
Move what and where? |
On Thu, 12 May 2016, Serg G. Brester wrote:
I am not arguing against moving altogether, and understand that it
good!
good -- that could be a good point [lets call it POINTX] to send a
not sure what was the difficulty to have a PR for POINTX
I meant while reviewing PR on github. I often do reviews from the
could there be a PR for POINTX mentioned above? Yaroslav O. Halchenko |
I don't know all the test cases of this commit pass, I'll make a commit 556ddaa as separated PR. I can remember a "bug" for 'flushed' vs 'rolled over' in testFlushLogs, was fixed later from me... |
btw -- tests fail for me (only) strangely since seems to (rightfully?) need a sample log file which is not in git... confused (don't have time atm to investigate) how it passed on travis:
|
You have not clean copy - perhabs one custom config I can rewrite this test case, that will ignore all configs, that don't have corresponding test log file... Or just ignore this one...
|
…re readable) case shows how evil except Exception can be ;)
dfd9121
to
06dcad7
Compare
return True | ||
|
||
@staticmethod | ||
def exit(code=0): # pragma: no cover - can't test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope -- pragma is incorrect -- could be tested via mocking at least for the smoke testing and/or logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the global exit handler is overwritten in test cases (to test forked processes exit code), so it can't (we need a return code).
Indeed, we could rewrite it using mock module, but the overhead is unnecessarily (several times larger) for coverage of this 2 lines.
I'm done, ready to merge to 0.10... Still again: that is a first shot (minimal invasive surgery), better mocking can be made later, because the test cases are almost wholehearted (I mean expected behavior of CS). |
…ace need for custom --s)
…d runs per client/server
sent you a PR sebres#6 |
pid_exists already available in Utils; small bug and stability fixing;
sebres#6 merged, but rewritten a little bit (see 2 commits above) |
…ers + minor PEP8ing
I still don't like having tests specific logic within code itself (all the PRODUCTION thing) and persistent mocking of stuff within test module, but I guess we will leave it for the future |
closes #1121
closes #1139
Several enhancements, bug fixed and code optimization:
-vvv
)