Merge pull request #8458 from certbot/fix-py2-integration

Fix Python 2 integration tests
This commit is contained in:
Brad Warren
2020-11-17 15:39:01 -08:00
committed by GitHub
@@ -1,5 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
"""Module to setup an RFC2136-capable DNS server""" """Module to setup an RFC2136-capable DNS server"""
from __future__ import print_function
import os import os
import os.path import os.path
from pkg_resources import resource_filename from pkg_resources import resource_filename
@@ -38,6 +40,8 @@ class DNSServer(object):
self.bind_root = tempfile.mkdtemp() self.bind_root = tempfile.mkdtemp()
self.process = None
self.dns_xdist = { self.dns_xdist = {
'address': BIND_BIND_ADDRESS[0], 'address': BIND_BIND_ADDRESS[0],
'port': BIND_BIND_ADDRESS[1] 'port': BIND_BIND_ADDRESS[1]
@@ -58,11 +62,12 @@ class DNSServer(object):
def stop(self): def stop(self):
"""Stop the DNS server, and clean its resources""" """Stop the DNS server, and clean its resources"""
try: if self.process:
self.process.terminate() try:
self.process.wait() self.process.terminate()
except BaseException as e: self.process.wait()
print("BIND9 did not stop cleanly: {}".format(e), file=sys.stderr) except BaseException as e:
print("BIND9 did not stop cleanly: {}".format(e), file=sys.stderr)
shutil.rmtree(self.bind_root, ignore_errors=True) shutil.rmtree(self.bind_root, ignore_errors=True)
@@ -72,7 +77,8 @@ class DNSServer(object):
def _configure_bind(self): def _configure_bind(self):
"""Configure the BIND9 server based on the prebaked configuration""" """Configure the BIND9 server based on the prebaked configuration"""
bind_conf_src = resource_filename('certbot_integration_tests', 'assets/bind-config') bind_conf_src = resource_filename('certbot_integration_tests', 'assets/bind-config')
shutil.copytree(bind_conf_src, self.bind_root, dirs_exist_ok=True) for dir in ('conf', 'zones'):
shutil.copytree(os.path.join(bind_conf_src, dir), os.path.join(self.bind_root, dir))
def _start_bind(self): def _start_bind(self):
"""Launch the BIND9 server as a Docker container""" """Launch the BIND9 server as a Docker container"""