parent
29ac797907
commit
1d7f8dcf63
|
@ -94,12 +94,13 @@ class OneDNS(resolver.DynamicResolver):
|
|||
test = kwargs.pop('test', False)
|
||||
test_vms = kwargs.pop('test_vms', None)
|
||||
sync_interval = kwargs.pop('sync_interval', 5 * 60)
|
||||
self.sync(vms=test_vms)
|
||||
if self._udp_server is None or not self._udp_server.isAlive():
|
||||
self.start(*args, **kwargs)
|
||||
time.sleep(sync_interval)
|
||||
while self._udp_server.isAlive():
|
||||
self.sync(vms=test_vms)
|
||||
try:
|
||||
self.sync(vms=test_vms)
|
||||
except Exception:
|
||||
log.exception('onedns sync failed:')
|
||||
time.sleep(sync_interval)
|
||||
if test:
|
||||
break
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from testfixtures import LogCapture
|
||||
|
||||
from onedns import exception
|
||||
from onedns.tests import vcr
|
||||
from onedns.tests import utils
|
||||
|
@ -76,3 +80,14 @@ def test_onedns_remove_vm_by_id(oneclient, one_dns):
|
|||
_add_and_verify(one_dns, vm)
|
||||
one_dns.remove_vm_by_id(vm.id)
|
||||
utils.verify_vm_dns_absent(dns_entries)
|
||||
|
||||
|
||||
def test_onedns_daemon_no_crash(one_dns):
|
||||
def sync_fail(*args, **kwargs):
|
||||
raise Exception('this should be logged')
|
||||
with LogCapture() as log_capture:
|
||||
with mock.patch.object(one_dns, 'sync', sync_fail):
|
||||
one_dns.daemon(test=True, sync_interval=1)
|
||||
log_capture.check(
|
||||
('onedns', 'ERROR', 'onedns sync failed:')
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue