Browse Source

Fix for latest zeroconf version

The zeroconf library removed address in version 0.27.0 [1]
This patch should fix potential issues with that change.

Changes:
  ironic_lib/tests/test_mdns.py

[1] https://github.com/jstasiak/python-zeroconf/#changelog

Change-Id: I694ae5587ac8c3aae43d98902f56738773d31284
(cherry picked from commit 4c185438e6)
tags/2.21.2^0
Riccardo Pittau 1 month ago
parent
commit
cc50dab513
1 changed files with 24 additions and 3 deletions
  1. +24
    -3
      ironic_lib/tests/test_mdns.py

+ 24
- 3
ironic_lib/tests/test_mdns.py View File

@@ -35,7 +35,14 @@ class RegisterServiceTestCase(base.IronicLibTestCase):
info = mock_zc.return_value.register_service.call_args[0][0]
self.assertEqual('_openstack._tcp.local.', info.type)
self.assertEqual('baremetal._openstack._tcp.local.', info.name)
self.assertEqual('127.0.0.1', socket.inet_ntoa(info.address))
# NOTE(rpittau) address zeroconf differences
# the addresses attribute is not supported in the version used
# in Python 2.x
try:
result = socket.inet_ntoa(info.addresses[0])
except AttributeError:
result = socket.inet_ntoa(info.address)
self.assertEqual('127.0.0.1', result)
self.assertEqual({'path': '/baremetal'}, info.properties)

def test_with_params(self, mock_zc):
@@ -48,7 +55,14 @@ class RegisterServiceTestCase(base.IronicLibTestCase):
info = mock_zc.return_value.register_service.call_args[0][0]
self.assertEqual('_openstack._tcp.local.', info.type)
self.assertEqual('baremetal._openstack._tcp.local.', info.name)
self.assertEqual('127.0.0.1', socket.inet_ntoa(info.address))
# NOTE(rpittau) address zeroconf differences
# the addresses attribute is not supported in the version used
# in Python 2.x
try:
result = socket.inet_ntoa(info.addresses[0])
except AttributeError:
result = socket.inet_ntoa(info.address)
self.assertEqual('127.0.0.1', result)
self.assertEqual({'path': '/baremetal',
'answer': 42,
'foo': 'bar'},
@@ -78,7 +92,14 @@ class RegisterServiceTestCase(base.IronicLibTestCase):
info = mock_zc.return_value.register_service.call_args[0][0]
self.assertEqual('_openstack._tcp.local.', info.type)
self.assertEqual('baremetal._openstack._tcp.local.', info.name)
self.assertEqual('127.0.0.1', socket.inet_ntoa(info.address))
# NOTE(rpittau) address zeroconf differences
# the addresses attribute is not supported in the version used
# in Python 2.x
try:
result = socket.inet_ntoa(info.addresses[0])
except AttributeError:
result = socket.inet_ntoa(info.address)
self.assertEqual('127.0.0.1', result)
self.assertEqual({'path': '/baremetal'}, info.properties)

@mock.patch.object(mdns.time, 'sleep', autospec=True)


Loading…
Cancel
Save