Skip to content

Commit

Permalink
avoid DNS of local names in fast tests (small optimization)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebres committed Dec 31, 2023
1 parent dd4431c commit 7de1057
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fail2ban/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ def F2B_SkipIfNoNetwork():
c.set('2001:db8::ffff', 'test-other')
c.set('87.142.124.10', 'test-host')
if unittest.F2B.no_network: # pragma: no cover
if unittest.F2B.fast: # pragma: no cover
for i in ('127.0.0.1', '::1'): # DNSUtils.dnsToIp('localhost')
c.set(i, 'localhost')
# precache all ip to dns used in test cases:
c.set('192.0.2.888', None)
c.set('8.8.4.4', 'dns.google')
Expand All @@ -329,8 +332,9 @@ def F2B_SkipIfNoNetwork():
c.set(*i)
# if fast - precache all host names as localhost addresses (speed-up getSelfIPs/ignoreself):
if unittest.F2B.fast: # pragma: no cover
ips = set([IPAddr('127.0.0.1'), IPAddr('::1')]); # DNSUtils.dnsToIp('localhost')
for i in DNSUtils.getSelfNames():
c.set(i, DNSUtils.dnsToIp('localhost'))
c.set(i, ips)


def mtimesleep():
Expand Down

0 comments on commit 7de1057

Please sign in to comment.