Skip to content

Commit 1d28ec8

Browse files
committed
Made the test runner try multiple port numbers for the SMTP server, in order to handle the case where multiple test suites are in progress on the same host (which can happen when multiple buildbot slaves are running tests at the same time).
- Legacy-Id: 9186
1 parent b940623 commit 1d28ec8

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

ietf/utils/test_runner.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,20 @@ def setup_test_environment(self, **kwargs):
352352

353353
assert not settings.IDTRACKER_BASE_URL.endswith('/')
354354

355-
self.smtpd_driver = SMTPTestServerDriver((ietf.utils.mail.SMTP_ADDR['ip4'],ietf.utils.mail.SMTP_ADDR['port']),None)
356-
self.smtpd_driver.start()
355+
# Try to set up an SMTP test server. In case other test runs are
356+
# going on at the same time, try a range of ports.
357+
base = ietf.utils.mail.SMTP_ADDR['port']
358+
for offset in range(10):
359+
try:
360+
# remember the value so ietf.utils.mail.send_smtp() will use the same
361+
ietf.utils.mail.SMTP_ADDR['port'] = base + offset
362+
self.smtpd_driver = SMTPTestServerDriver((ietf.utils.mail.SMTP_ADDR['ip4'],ietf.utils.mail.SMTP_ADDR['port']),None)
363+
self.smtpd_driver.start()
364+
print(" Running an SMTP test server on %(ip4)s:%(port)s to catch outgoing email." % ietf.utils.mail.SMTP_ADDR)
365+
break
366+
except socket.error:
367+
pass
368+
357369

358370
super(IetfTestRunner, self).setup_test_environment(**kwargs)
359371

0 commit comments

Comments
 (0)