Skip to content
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

SMTPActionTest tests failing with fail2ban 0.10.0 git head #1567

Closed
opoplawski opened this issue Oct 4, 2016 · 6 comments
Closed

SMTPActionTest tests failing with fail2ban 0.10.0 git head #1567

opoplawski opened this issue Oct 4, 2016 · 6 comments

Comments

@opoplawski
Copy link
Contributor

Environment:

Fedora rawhide package build

The issue:

Several SMTPAction tests fail as follows:

+ ./fail2ban-testcases-all-python3 --no-network --log-level heavydebug smtp
Testing using /usr/bin/python3.5
Fail2ban 0.10.0a1 test suite. Python 3.5.2 (default, Sep 14 2016, 11:31:14) [GCC 6.2.1 20160901 (Red Hat 6.2.1-1)]. Please wait...
 +  664 3FF81924B90 fail2ban.utils            WARNI |           utils-30: gatherTests          | Skipping gamin backend testing. Got exception 'No module named 'gamin''
 +  682 3FF81924B90 fail2ban.utils            WARNI |           utils-30: gatherTests          | I: Skipping systemd backend testing. Got exception 'No module named 'systemd''
testBan (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  +  683 3FF81924B90 fail2ban.jail             INFO  |            jail-20: __init__             | Creating new jail 'DummyJail #4395782036784 with 0 tickets'
ERROR
testOptions (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  +  804 3FF81924B90 fail2ban.jail             INFO  |            jail-20: __init__             | Creating new jail 'DummyJail #4395781556208 with 0 tickets'
ERROR
testStart (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  +  907 3FF81924B90 fail2ban.jail             INFO  |            jail-20: __init__             | Creating new jail 'DummyJail #4395781634760 with 0 tickets'
ERROR
testStop (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  + 1010 3FF81924B90 fail2ban.jail             INFO  |            jail-20: __init__             | Creating new jail 'DummyJail #4395770602160 with 0 tickets'
ERROR
======================================================================
ERROR: testBan (fail2ban.tests.action_d.test_smtp.SMTPActionTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./fail2ban/tests/action_d/test_smtp.py", line 102, in testBan
    self.action.ban(aInfo)
  File "config/action.d/smtp.py", line 223, in ban
    message % aInfo)
  File "config/action.d/smtp.py", line 158, in _sendMessage
    self.host, *smtp.connect(self.host))
  File "/usr/lib64/python3.5/smtplib.py", line 335, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib64/python3.5/smtplib.py", line 306, in _get_socket
    self.source_address)
  File "/usr/lib64/python3.5/socket.py", line 711, in create_connection
    raise err
  File "/usr/lib64/python3.5/socket.py", line 702, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
@sebres
Copy link
Contributor

sebres commented Oct 5, 2016

Firewall?
TestSMTPServer creates a listening connection using some free port, that will be used hereafter for communication,
see:

PYTHONPATH=. python -c 'from fail2ban.tests.action_d.test_smtp import TestSMTPServer; s = TestSMTPServer(("localhost", 0), None); print("port %s" % s.socket.getsockname()[1])'

@sebres
Copy link
Contributor

sebres commented Oct 5, 2016

I tend to skip this test if --no-network specified (is not really a network, because localhost, but...)

@opoplawski
Copy link
Contributor Author

These tests have been around for a while right? I'm not seeing failures with 0.9.5.

sebres added a commit to sebres/fail2ban that referenced this issue Oct 6, 2016
@sebres
Copy link
Contributor

sebres commented Oct 6, 2016

The port, that it listening is random, maybe some thing prevents to connect? I mean the error message is clearly enough.
I see small changes in server part (test_smtp.py) compared to 0.9, e. g. listener thread run changed from asyncore.loop to asyncserver.loop (because of sporadically bugs resp. better handling within fail2ban), but...
Neither we have any changes in smtp-action self, nor I can reproduce it on debian and co, nor I can comprehend this occurrence.
Strange... I can suspect only some timing problems, can you please test it with my branch, that wait for readiness of the test server after self._loop_thread.start()...
See 0.10...sebres:_0.10/test-smtp-action

Below you can find my output of original 0.10th, for python 2.7 and 3.5:

fail2ban-testcases -vv --no-network --log-level heavydebug smtp
Fail2ban 0.10.0a2 test suite. Python 2.7.12 (default, Jul  1 2016, 15:12:24) [GCC 5.4.0 20160609]. Please wait...
testBan (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  2016-10-06 10:55:15,392 7F8A1635D700 INFO  Creating new jail 'DummyJail #140230981117520 with 0 tickets'
 2016-10-06 10:55:15,402 7F8A1635D700 DEBUG Connected to SMTP '127.0.0.1:33826', response: 220: testsrv Python SMTP proxy version 0.2
 2016-10-06 10:55:15,406 7F8A1635D700 DEBUG Email '[Fail2Ban] DummyJail #140230981117520 with 0 tickets: banned 127.0.0.2 from testsrv' successfully sent
 2016-10-06 10:55:15,407 7F8A1635D700 DEBUG Disconnected from '127.0.0.1:33826', response 221: Bye
 2016-10-06 10:55:15,409 7F8A1635D700 DEBUG Connected to SMTP '127.0.0.1:33826', response: 220: testsrv Python SMTP proxy version 0.2
 2016-10-06 10:55:15,410 7F8A1635D700 DEBUG Email '[Fail2Ban] DummyJail #140230981117520 with 0 tickets: banned 127.0.0.2 from testsrv' successfully sent
 2016-10-06 10:55:15,411 7F8A1635D700 DEBUG Disconnected from '127.0.0.1:33826', response 221: Bye
 2016-10-06 10:55:15,412 7F8A1635D700 DEBUG Connected to SMTP '127.0.0.1:33826', response: 220: testsrv Python SMTP proxy version 0.2
 2016-10-06 10:55:15,414 7F8A1635D700 DEBUG Email '[Fail2Ban] DummyJail #140230981117520 with 0 tickets: banned 127.0.0.2 from testsrv' successfully sent
 2016-10-06 10:55:15,414 7F8A1635D700 DEBUG Disconnected from '127.0.0.1:33826', response 221: Bye
 2016-10-06 10:55:15,416 7F8A1635D700 DEBUG Connected to SMTP '127.0.0.1:33826', response: 220: testsrv Python SMTP proxy version 0.2
 2016-10-06 10:55:15,417 7F8A1635D700 DEBUG Email '[Fail2Ban] DummyJail #140230981117520 with 0 tickets: banned 127.0.0.2 from testsrv' successfully sent
 2016-10-06 10:55:15,418 7F8A1635D700 DEBUG Disconnected from '127.0.0.1:33826', response 221: Bye
ok
testOptions (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  2016-10-06 10:55:15,418 7F8A1635D700 INFO  Creating new jail 'DummyJail #140230987484688 with 0 tickets'
 2016-10-06 10:55:15,421 7F8A1635D700 DEBUG Connected to SMTP '127.0.0.1:32786', response: 220: testsrv Python SMTP proxy version 0.2
 2016-10-06 10:55:15,423 7F8A1635D700 DEBUG Email '[Fail2Ban] DummyJail #140230987484688 with 0 tickets: started on testsrv' successfully sent
 2016-10-06 10:55:15,423 7F8A1635D700 DEBUG Disconnected from '127.0.0.1:32786', response 221: Bye
 2016-10-06 10:55:15,425 7F8A1635D700 DEBUG Connected to SMTP '127.0.0.1:32786', response: 220: testsrv Python SMTP proxy version 0.2
 2016-10-06 10:55:15,427 7F8A1635D700 DEBUG Email '[Fail2Ban] DummyJail #140230987484688 with 0 tickets: started on testsrv' successfully sent
 2016-10-06 10:55:15,427 7F8A1635D700 DEBUG Disconnected from '127.0.0.1:32786', response 221: Bye
ok
testStart (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  2016-10-06 10:55:15,678 7F8A1635D700 INFO  Creating new jail 'DummyJail #140230976276752 with 0 tickets'
 2016-10-06 10:55:15,682 7F8A1635D700 DEBUG Connected to SMTP '127.0.0.1:34338', response: 220: testsrv Python SMTP proxy version 0.2
 2016-10-06 10:55:15,684 7F8A1635D700 DEBUG Email '[Fail2Ban] DummyJail #140230976276752 with 0 tickets: started on testsrv' successfully sent
 2016-10-06 10:55:15,684 7F8A1635D700 DEBUG Disconnected from '127.0.0.1:34338', response 221: Bye
ok
testStop (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  2016-10-06 10:55:15,935 7F8A1635D700 INFO  Creating new jail 'DummyJail #140230976277328 with 0 tickets'
 2016-10-06 10:55:15,938 7F8A1635D700 DEBUG Connected to SMTP '127.0.0.1:37252', response: 220: testsrv Python SMTP proxy version 0.2
 2016-10-06 10:55:15,940 7F8A1635D700 DEBUG Email '[Fail2Ban] DummyJail #140230976277328 with 0 tickets: stopped on testsrv' successfully sent
 2016-10-06 10:55:15,940 7F8A1635D700 DEBUG Disconnected from '127.0.0.1:37252', response 221: Bye
ok
fail2ban-testcases -vv --no-network --log-level heavydebug smtp
Fail2ban 0.10.0a2 test suite. Python 3.5.2 (default, Jul  5 2016, 12:43:10) [GCC 5.4.0 20160609]. Please wait...
testBan (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  2016-10-06 10:59:55,424 7F93D52BF700 INFO  Creating new jail 'DummyJail #140272840479016 with 0 tickets'
 2016-10-06 10:59:55,436 7F93D52BF700 DEBUG Connected to SMTP '127.0.0.1:32991', response: 220: b'testsrv Python SMTP proxy version 0.3'
 2016-10-06 10:59:55,476 7F93D52BF700 DEBUG Email '[Fail2Ban] DummyJail #140272840479016 with 0 tickets: banned 127.0.0.2 from testsrv' successfully sent
 2016-10-06 10:59:55,477 7F93D52BF700 DEBUG Disconnected from '127.0.0.1:32991', response 221: b'Bye'
 2016-10-06 10:59:55,479 7F93D52BF700 DEBUG Connected to SMTP '127.0.0.1:32991', response: 220: b'testsrv Python SMTP proxy version 0.3'
 2016-10-06 10:59:55,520 7F93D52BF700 DEBUG Email '[Fail2Ban] DummyJail #140272840479016 with 0 tickets: banned 127.0.0.2 from testsrv' successfully sent
 2016-10-06 10:59:55,520 7F93D52BF700 DEBUG Disconnected from '127.0.0.1:32991', response 221: b'Bye'
 2016-10-06 10:59:55,522 7F93D52BF700 DEBUG Connected to SMTP '127.0.0.1:32991', response: 220: b'testsrv Python SMTP proxy version 0.3'
 2016-10-06 10:59:55,563 7F93D52BF700 DEBUG Email '[Fail2Ban] DummyJail #140272840479016 with 0 tickets: banned 127.0.0.2 from testsrv' successfully sent
 2016-10-06 10:59:55,564 7F93D52BF700 DEBUG Disconnected from '127.0.0.1:32991', response 221: b'Bye'
 2016-10-06 10:59:55,566 7F93D52BF700 DEBUG Connected to SMTP '127.0.0.1:32991', response: 220: b'testsrv Python SMTP proxy version 0.3'
 2016-10-06 10:59:55,607 7F93D52BF700 DEBUG Email '[Fail2Ban] DummyJail #140272840479016 with 0 tickets: banned 127.0.0.2 from testsrv' successfully sent
 2016-10-06 10:59:55,608 7F93D52BF700 DEBUG Disconnected from '127.0.0.1:32991', response 221: b'Bye'
ok
testOptions (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  2016-10-06 10:59:55,859 7F93D52BF700 INFO  Creating new jail 'DummyJail #140272840479968 with 0 tickets'
 2016-10-06 10:59:55,862 7F93D52BF700 DEBUG Connected to SMTP '127.0.0.1:40322', response: 220: b'testsrv Python SMTP proxy version 0.3'
 2016-10-06 10:59:55,904 7F93D52BF700 DEBUG Email '[Fail2Ban] DummyJail #140272840479968 with 0 tickets: started on testsrv' successfully sent
 2016-10-06 10:59:55,904 7F93D52BF700 DEBUG Disconnected from '127.0.0.1:40322', response 221: b'Bye'
 2016-10-06 10:59:55,906 7F93D52BF700 DEBUG Connected to SMTP '127.0.0.1:40322', response: 220: b'testsrv Python SMTP proxy version 0.3'
 2016-10-06 10:59:55,948 7F93D52BF700 DEBUG Email '[Fail2Ban] DummyJail #140272840479968 with 0 tickets: started on testsrv' successfully sent
 2016-10-06 10:59:55,949 7F93D52BF700 DEBUG Disconnected from '127.0.0.1:40322', response 221: b'Bye'
ok
testStart (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  2016-10-06 10:59:56,199 7F93D52BF700 INFO  Creating new jail 'DummyJail #140272890162200 with 0 tickets'
 2016-10-06 10:59:56,203 7F93D52BF700 DEBUG Connected to SMTP '127.0.0.1:33778', response: 220: b'testsrv Python SMTP proxy version 0.3'
 2016-10-06 10:59:56,244 7F93D52BF700 DEBUG Email '[Fail2Ban] DummyJail #140272890162200 with 0 tickets: started on testsrv' successfully sent
 2016-10-06 10:59:56,244 7F93D52BF700 DEBUG Disconnected from '127.0.0.1:33778', response 221: b'Bye'
ok
testStop (fail2ban.tests.action_d.test_smtp.SMTPActionTest) ...  2016-10-06 10:59:56,250 7F93D52BF700 INFO  Creating new jail 'DummyJail #140272892092656 with 0 tickets'
 2016-10-06 10:59:56,253 7F93D52BF700 DEBUG Connected to SMTP '127.0.0.1:43740', response: 220: b'testsrv Python SMTP proxy version 0.3'
 2016-10-06 10:59:56,292 7F93D52BF700 DEBUG Email '[Fail2Ban] DummyJail #140272892092656 with 0 tickets: stopped on testsrv' successfully sent
 2016-10-06 10:59:56,292 7F93D52BF700 DEBUG Disconnected from '127.0.0.1:43740', response 221: b'Bye'
ok

@sebres
Copy link
Contributor

sebres commented Oct 13, 2016

@opoplawski ping

@sebres
Copy link
Contributor

sebres commented Nov 29, 2016

please reopen if news available

@sebres sebres closed this as completed Nov 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants