Merge "Don't bind to tcp/udp when running unit-tests"
This commit is contained in:
commit
357ec2399a
@ -311,6 +311,7 @@ class DNSService(object):
|
||||
def _dns_handle_tcp(self, sock_tcp):
|
||||
LOG.info("_handle_tcp thread started")
|
||||
|
||||
client = None
|
||||
while True:
|
||||
try:
|
||||
# handle a new TCP connection
|
||||
@ -332,18 +333,21 @@ class DNSService(object):
|
||||
# ending unexpectedly. Ensure proper ordering of blocks, and
|
||||
# ensure no exceptions are generated from within.
|
||||
except socket.timeout:
|
||||
client.close()
|
||||
if client:
|
||||
client.close()
|
||||
LOG.warning("TCP Timeout from: %(host)s:%(port)d",
|
||||
{'host': addr[0], 'port': addr[1]})
|
||||
|
||||
except socket.error as e:
|
||||
client.close()
|
||||
if client:
|
||||
client.close()
|
||||
errname = errno.errorcode[e.args[0]]
|
||||
LOG.warning("Socket error %(err)s from: %(host)s:%(port)d",
|
||||
{'host': addr[0], 'port': addr[1], 'err': errname})
|
||||
|
||||
except Exception:
|
||||
client.close()
|
||||
if client:
|
||||
client.close()
|
||||
LOG.exception("Unknown exception handling TCP request from: "
|
||||
"%(host)s:%(port)d",
|
||||
{'host': addr[0], 'port': addr[1]})
|
||||
@ -418,7 +422,8 @@ class DNSService(object):
|
||||
LOG.exception("Unknown exception handling TCP request from: "
|
||||
"%(host)s:%(port)d", {'host': host, 'port': port})
|
||||
finally:
|
||||
client.close()
|
||||
if client:
|
||||
client.close()
|
||||
|
||||
def _dns_handle_udp(self, sock_udp):
|
||||
"""Handle a DNS Query over UDP in a dedicated thread
|
||||
|
@ -28,13 +28,16 @@ import tempfile
|
||||
from contextlib import contextmanager
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import tooz.coordination
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
from oslo_config import cfg
|
||||
import tooz.coordination
|
||||
|
||||
from designate import policy
|
||||
import designate.service
|
||||
import designate.utils
|
||||
from designate import network_api
|
||||
from designate import policy
|
||||
from designate import rpc
|
||||
from designate.network_api import fake as fake_network_api
|
||||
from designate.sqlalchemy import utils as sqlalchemy_utils
|
||||
@ -81,7 +84,8 @@ class ServiceFixture(fixtures.Fixture):
|
||||
self.svc = cls()
|
||||
self.svc_name = svc_name
|
||||
|
||||
def setUp(self):
|
||||
@mock.patch.object(designate.service.DNSService, '_start')
|
||||
def setUp(self, mock_start):
|
||||
super(ServiceFixture, self).setUp()
|
||||
LOG.info('Starting service %s (%s)', self.svc_name, id(self.svc))
|
||||
self.svc.start()
|
||||
|
@ -13,11 +13,9 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import functools
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import six
|
||||
import testtools
|
||||
@ -135,22 +133,6 @@ class TestUtils(TestCase):
|
||||
['asc', 'desc'])
|
||||
|
||||
|
||||
class SocketListenTest(unittest.TestCase):
|
||||
|
||||
def test_listen_tcp(self):
|
||||
# Test listening on TCP on IPv4 and IPv6 addrs
|
||||
# bug 1566036
|
||||
for addr in ('', '0.0.0.0', '127.0.0.1', '::', '::1'):
|
||||
s = utils.bind_tcp(addr, 0, 1)
|
||||
s.close()
|
||||
|
||||
def test_listen_udp(self):
|
||||
# Test listening on UDP on IPv4 and IPv6 addrs
|
||||
for addr in ('', '0.0.0.0', '127.0.0.1', '::', '::1'):
|
||||
s = utils.bind_udp(addr, 0)
|
||||
s.close()
|
||||
|
||||
|
||||
def def_method(f, *args, **kwargs):
|
||||
@functools.wraps(f)
|
||||
def new_method(self):
|
||||
|
Loading…
Reference in New Issue
Block a user