Merge "Refactor unit tests for server network"

This commit is contained in:
Zuul 2018-01-02 14:59:46 +00:00 committed by Gerrit Code Review
commit 5aa603bb2b

View File

@ -123,7 +123,7 @@ resources:
image: F17-x86_64-gold image: F17-x86_64-gold
flavor: m1.large flavor: m1.large
networks: networks:
- { uuid: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' } - { network: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' }
subnet: subnet:
type: OS::Neutron::Subnet type: OS::Neutron::Subnet
properties: properties:
@ -218,6 +218,17 @@ resources:
""" """
def create_fake_iface(port=None, net=None, mac=None, ip=None, subnet=None):
class fake_interface(object):
def __init__(self, port_id, net_id, mac_addr, fixed_ip, subnet_id):
self.port_id = port_id
self.net_id = net_id
self.mac_addr = mac_addr
self.fixed_ips = [{'ip_address': fixed_ip, 'subnet_id': subnet_id}]
return fake_interface(port, net, mac, ip, subnet)
class ServersTest(common.HeatTestCase): class ServersTest(common.HeatTestCase):
def setUp(self): def setUp(self):
super(ServersTest, self).setUp() super(ServersTest, self).setUp()
@ -356,15 +367,6 @@ class ServersTest(common.HeatTestCase):
scheduler.TaskRunner(server.create)() scheduler.TaskRunner(server.create)()
return server return server
def _create_fake_iface(self, port, mac, ip):
class fake_interface(object):
def __init__(self, port_id, mac_addr, fixed_ip):
self.port_id = port_id
self.mac_addr = mac_addr
self.fixed_ips = [{'ip_address': fixed_ip}]
return fake_interface(port, mac, ip)
def test_subnet_dependency_by_network_id(self): def test_subnet_dependency_by_network_id(self):
templ, stack = self._setup_test_stack('subnet-test', templ, stack = self._setup_test_stack('subnet-test',
subnet_template) subnet_template)
@ -414,11 +416,15 @@ class ServersTest(common.HeatTestCase):
# this makes sure the auto increment worked on server creation # this makes sure the auto increment worked on server creation
self.assertGreater(server.id, 0) self.assertGreater(server.id, 0)
interfaces = [ interfaces = [create_fake_iface(port='1234',
self._create_fake_iface('1234', 'fa:16:3e:8c:22:aa', '4.5.6.7'), mac='fa:16:3e:8c:22:aa',
self._create_fake_iface('5678', 'fa:16:3e:8c:33:bb', '5.6.9.8'), ip='4.5.6.7'),
self._create_fake_iface( create_fake_iface(port='5678',
'1013', 'fa:16:3e:8c:44:cc', '10.13.12.13')] mac='fa:16:3e:8c:33:bb',
ip='5.6.9.8'),
create_fake_iface(port='1013',
mac='fa:16:3e:8c:44:cc',
ip='10.13.12.13')]
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
self.patchobject(return_server, 'interface_list', self.patchobject(return_server, 'interface_list',
@ -555,11 +561,15 @@ class ServersTest(common.HeatTestCase):
override_name=True) override_name=True)
server.resource_id = '1234' server.resource_id = '1234'
interfaces = [ interfaces = [create_fake_iface(port='1234',
self._create_fake_iface('1234', 'fa:16:3e:8c:22:aa', '4.5.6.7'), mac='fa:16:3e:8c:22:aa',
self._create_fake_iface('5678', 'fa:16:3e:8c:33:bb', '5.6.9.8'), ip='4.5.6.7'),
self._create_fake_iface( create_fake_iface(port='5678',
'1013', 'fa:16:3e:8c:44:cc', '10.13.12.13')] mac='fa:16:3e:8c:33:bb',
ip='5.6.9.8'),
create_fake_iface(port='1013',
mac='fa:16:3e:8c:44:cc',
ip='10.13.12.13')]
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
self.patchobject(return_server, 'interface_list', self.patchobject(return_server, 'interface_list',
@ -1949,28 +1959,20 @@ class ServersTest(common.HeatTestCase):
server.properties.data['networks'] = [{'network': 'public_id', server.properties.data['networks'] = [{'network': 'public_id',
'fixed_ip': '5.6.9.8'}] 'fixed_ip': '5.6.9.8'}]
class fake_interface(object): iface0 = create_fake_iface(port='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
def __init__(self, port_id, net_id, fixed_ip, mac_addr): net='public',
self.port_id = port_id ip='5.6.9.8',
self.net_id = net_id mac='fa:16:3e:8c:33:aa')
self.mac_addr = mac_addr iface1 = create_fake_iface(port='bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
net='public',
self.fixed_ips = [{'ip_address': fixed_ip}] ip='4.5.6.7',
mac='fa:16:3e:8c:22:aa')
iface = fake_interface('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', iface2 = create_fake_iface(port='cccccccc-cccc-cccc-cccc-cccccccccccc',
'public', net='private',
'5.6.9.8', ip='10.13.12.13',
'fa:16:3e:8c:33:aa') mac='fa:16:3e:8c:44:cc')
iface1 = fake_interface('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
'public',
'4.5.6.7',
'fa:16:3e:8c:22:aa')
iface2 = fake_interface('cccccccc-cccc-cccc-cccc-cccccccccccc',
'private',
'10.13.12.13',
'fa:16:3e:8c:44:cc')
self.patchobject(return_server, 'interface_list', self.patchobject(return_server, 'interface_list',
return_value=[iface, iface1, iface2]) return_value=[iface0, iface1, iface2])
self.patchobject(neutron.NeutronClientPlugin, self.patchobject(neutron.NeutronClientPlugin,
'find_resourceid_by_name_or_id', 'find_resourceid_by_name_or_id',
@ -3260,15 +3262,6 @@ class ServersTest(common.HeatTestCase):
'allocate_network': str_network, 'allocate_network': str_network,
'tag': tag} 'tag': tag}
def create_fake_iface(self, port, net, ip):
class fake_interface(object):
def __init__(self, port_id, net_id, fixed_ip):
self.port_id = port_id
self.net_id = net_id
self.fixed_ips = [{'ip_address': fixed_ip}]
return fake_interface(port, net, ip)
def test_get_network_id_neutron(self): def test_get_network_id_neutron(self):
return_server = self.fc.servers.list()[3] return_server = self.fc.servers.list()[3]
server = self._create_test_server(return_server, 'networks_update') server = self._create_test_server(return_server, 'networks_update')
@ -3385,22 +3378,25 @@ class ServersTest(common.HeatTestCase):
ip='1.2.3.4'), ip='1.2.3.4'),
self.create_old_net(net='gggggggg-1111-1111-1111-gggggggggggg'), self.create_old_net(net='gggggggg-1111-1111-1111-gggggggggggg'),
self.create_old_net(port='dddddddd-dddd-dddd-dddd-dddddddddddd'), self.create_old_net(port='dddddddd-dddd-dddd-dddd-dddddddddddd'),
self.create_old_net(uuid='gggggggg-1111-1111-1111-gggggggggggg', self.create_old_net(net='gggggggg-1111-1111-1111-gggggggggggg',
ip='5.6.7.8')] ip='5.6.7.8')]
# new order 2 3 0 1 4 # new order 2 3 0 1 4
interfaces = [ interfaces = [
self.create_fake_iface('cccccccc-cccc-cccc-cccc-cccccccccccc', create_fake_iface(port='cccccccc-cccc-cccc-cccc-cccccccccccc',
nets[2]['network'], '10.0.0.11'), net=nets[2]['network'],
self.create_fake_iface(nets[3]['port'], ip='10.0.0.11'),
'gggggggg-1111-1111-1111-gggggggggggg', create_fake_iface(port=nets[3]['port'],
'10.0.0.12'), net='gggggggg-1111-1111-1111-gggggggggggg',
self.create_fake_iface(nets[0]['port'], ip='10.0.0.12'),
'gggggggg-1111-1111-1111-gggggggggggg', create_fake_iface(port=nets[0]['port'],
'10.0.0.13'), net='gggggggg-1111-1111-1111-gggggggggggg',
self.create_fake_iface('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', ip='10.0.0.13'),
nets[1]['network'], nets[1]['fixed_ip']), create_fake_iface(port='bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
self.create_fake_iface('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', net=nets[1]['network'],
nets[4]['network'], nets[4]['fixed_ip'])] ip=nets[1]['fixed_ip']),
create_fake_iface(port='eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee',
net=nets[4]['network'],
ip=nets[4]['fixed_ip'])]
# all networks should get port id # all networks should get port id
expected = [ expected = [
{'port': 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', {'port': 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
@ -3440,12 +3436,12 @@ class ServersTest(common.HeatTestCase):
'allocate_network': None, 'allocate_network': None,
'tag': None}, 'tag': None},
{'port': 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', {'port': 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee',
'uuid': 'gggggggg-1111-1111-1111-gggggggggggg', 'uuid': None,
'fixed_ip': '5.6.7.8', 'fixed_ip': '5.6.7.8',
'subnet': None, 'subnet': None,
'port_extra_properties': None, 'port_extra_properties': None,
'floating_ip': None, 'floating_ip': None,
'network': None, 'network': 'gggggggg-1111-1111-1111-gggggggggggg',
'allocate_network': None, 'allocate_network': None,
'tag': None}] 'tag': None}]
@ -3468,9 +3464,10 @@ class ServersTest(common.HeatTestCase):
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
iface = self.create_fake_iface('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', iface = create_fake_iface(
'450abbc9-9b6d-4d6f-8c3a-c47ac34100ef', port='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'1.2.3.4') net='450abbc9-9b6d-4d6f-8c3a-c47ac34100ef',
ip='1.2.3.4')
self.patchobject(return_server, 'interface_list', return_value=[iface]) self.patchobject(return_server, 'interface_list', return_value=[iface])
mock_detach = self.patchobject(return_server, 'interface_detach') mock_detach = self.patchobject(return_server, 'interface_detach')
mock_attach = self.patchobject(return_server, 'interface_attach') mock_attach = self.patchobject(return_server, 'interface_attach')
@ -3505,9 +3502,10 @@ class ServersTest(common.HeatTestCase):
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
iface = self.create_fake_iface('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', iface = create_fake_iface(
'450abbc9-9b6d-4d6f-8c3a-c47ac34100ef', port='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'1.2.3.4') net='450abbc9-9b6d-4d6f-8c3a-c47ac34100ef',
ip='1.2.3.4')
self.patchobject(return_server, 'interface_list', return_value=[iface]) self.patchobject(return_server, 'interface_list', return_value=[iface])
mock_detach = self.patchobject(return_server, 'interface_detach') mock_detach = self.patchobject(return_server, 'interface_detach')
mock_attach = self.patchobject(return_server, 'interface_attach') mock_attach = self.patchobject(return_server, 'interface_attach')
@ -3555,9 +3553,11 @@ class ServersTest(common.HeatTestCase):
mock_create_port = self.patchobject( mock_create_port = self.patchobject(
neutronclient.Client, 'create_port') neutronclient.Client, 'create_port')
iface = self.create_fake_iface('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', iface = create_fake_iface(
'05d8e681-4b37-4570-bc8d-810089f706b2', port='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'1.2.3.4') net='05d8e681-4b37-4570-bc8d-810089f706b2',
subnet='aaa09d50-8c23-4498-a542-aa0deb24f73e',
ip='1.2.3.4')
self.patchobject(return_server, 'interface_list', return_value=[iface]) self.patchobject(return_server, 'interface_list', return_value=[iface])
mock_detach = self.patchobject(return_server, 'interface_detach') mock_detach = self.patchobject(return_server, 'interface_detach')
mock_attach = self.patchobject(return_server, 'interface_attach') mock_attach = self.patchobject(return_server, 'interface_attach')
@ -3611,9 +3611,11 @@ class ServersTest(common.HeatTestCase):
'network_id_from_subnet_id', 'network_id_from_subnet_id',
return_value='05d8e681-4b37-4570-bc8d-810089f706b2') return_value='05d8e681-4b37-4570-bc8d-810089f706b2')
iface = self.create_fake_iface('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', iface = create_fake_iface(
'05d8e681-4b37-4570-bc8d-810089f706b2', port='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'1.2.3.4') net='05d8e681-4b37-4570-bc8d-810089f706b2',
subnet='aaa09d50-8c23-4498-a542-aa0deb24f73e',
ip='1.2.3.4')
self.patchobject(return_server, 'interface_list', return_value=[iface]) self.patchobject(return_server, 'interface_list', return_value=[iface])
mock_detach = self.patchobject(return_server, 'interface_detach') mock_detach = self.patchobject(return_server, 'interface_detach')
mock_attach = self.patchobject(return_server, 'interface_attach') mock_attach = self.patchobject(return_server, 'interface_attach')
@ -3662,9 +3664,10 @@ class ServersTest(common.HeatTestCase):
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
iface = self.create_fake_iface('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', iface = create_fake_iface(
'450abbc9-9b6d-4d6f-8c3a-c47ac34100ef', port='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'1.2.3.4') net='450abbc9-9b6d-4d6f-8c3a-c47ac34100ef',
ip='1.2.3.4')
self.patchobject(return_server, 'interface_list', return_value=[iface]) self.patchobject(return_server, 'interface_list', return_value=[iface])
mock_detach = self.patchobject(return_server, 'interface_detach') mock_detach = self.patchobject(return_server, 'interface_detach')
mock_attach = self.patchobject(return_server, 'interface_attach') mock_attach = self.patchobject(return_server, 'interface_attach')
@ -3692,9 +3695,10 @@ class ServersTest(common.HeatTestCase):
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
iface = self.create_fake_iface('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', iface = create_fake_iface(
'450abbc9-9b6d-4d6f-8c3a-c47ac34100ef', port='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'1.2.3.4') net='450abbc9-9b6d-4d6f-8c3a-c47ac34100ef',
ip='1.2.3.4')
self.patchobject(return_server, 'interface_list', return_value=[iface]) self.patchobject(return_server, 'interface_list', return_value=[iface])
mock_detach = self.patchobject(return_server, 'interface_detach') mock_detach = self.patchobject(return_server, 'interface_detach')
mock_attach = self.patchobject(return_server, 'interface_attach') mock_attach = self.patchobject(return_server, 'interface_attach')
@ -3727,10 +3731,9 @@ class ServersTest(common.HeatTestCase):
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
poor_interfaces = [ poor_interfaces = [
self.create_fake_iface('95e25541-d26a-478d-8f36-ae1c8f6b74dc', create_fake_iface(port='95e25541-d26a-478d-8f36-ae1c8f6b74dc',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'11.12.13.14') ip='11.12.13.14')]
]
self.patchobject(return_server, 'interface_list', self.patchobject(return_server, 'interface_list',
return_value=poor_interfaces) return_value=poor_interfaces)
@ -3786,16 +3789,15 @@ class ServersTest(common.HeatTestCase):
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
port_interfaces = [ port_interfaces = [
self.create_fake_iface('95e25541-d26a-478d-8f36-ae1c8f6b74dc', create_fake_iface(port='95e25541-d26a-478d-8f36-ae1c8f6b74dc',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'11.12.13.14'), ip='11.12.13.14'),
self.create_fake_iface('4121f61a-1b2e-4ab0-901e-eade9b1cb09d', create_fake_iface(port='4121f61a-1b2e-4ab0-901e-eade9b1cb09d',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'21.22.23.24'), ip='21.22.23.24'),
self.create_fake_iface('0907fa82-a024-43c2-9fc5-efa1bccaa74a', create_fake_iface(port='0907fa82-a024-43c2-9fc5-efa1bccaa74a',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'31.32.33.34') ip='31.32.33.34')]
]
self.patchobject(return_server, 'interface_list', self.patchobject(return_server, 'interface_list',
return_value=port_interfaces) return_value=port_interfaces)
@ -3835,19 +3837,18 @@ class ServersTest(common.HeatTestCase):
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
poor_interfaces = [ poor_interfaces = [
self.create_fake_iface('95e25541-d26a-478d-8f36-ae1c8f6b74dc', create_fake_iface(port='95e25541-d26a-478d-8f36-ae1c8f6b74dc',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'11.12.13.14'), ip='11.12.13.14'),
self.create_fake_iface('450abbc9-9b6d-4d6f-8c3a-c47ac34100ef', create_fake_iface(port='450abbc9-9b6d-4d6f-8c3a-c47ac34100ef',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'1.2.3.4'), ip='1.2.3.4'),
self.create_fake_iface('4121f61a-1b2e-4ab0-901e-eade9b1cb09d', create_fake_iface(port='4121f61a-1b2e-4ab0-901e-eade9b1cb09d',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'21.22.23.24'), ip='21.22.23.24'),
self.create_fake_iface('0907fa82-a024-43c2-9fc5-efa1bccaa74a', create_fake_iface(port='0907fa82-a024-43c2-9fc5-efa1bccaa74a',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'31.32.33.34') ip='31.32.33.34')]
]
self.patchobject(return_server, 'interface_list', self.patchobject(return_server, 'interface_list',
return_value=poor_interfaces) return_value=poor_interfaces)
@ -3883,16 +3884,15 @@ class ServersTest(common.HeatTestCase):
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
poor_interfaces = [ poor_interfaces = [
self.create_fake_iface('95e25541-d26a-478d-8f36-ae1c8f6b74dc', create_fake_iface(port='95e25541-d26a-478d-8f36-ae1c8f6b74dc',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'11.12.13.14'), ip='11.12.13.14'),
self.create_fake_iface('4121f61a-1b2e-4ab0-901e-eade9b1cb09d', create_fake_iface(port='4121f61a-1b2e-4ab0-901e-eade9b1cb09d',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'21.22.23.24'), ip='21.22.23.24'),
self.create_fake_iface('0907fa82-a024-43c2-9fc5-efa1bccaa74a', create_fake_iface(port='0907fa82-a024-43c2-9fc5-efa1bccaa74a',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'31.32.33.34') ip='31.32.33.34')]
]
self.patchobject(return_server, 'interface_list', self.patchobject(return_server, 'interface_list',
return_value=poor_interfaces) return_value=poor_interfaces)
mock_detach = self.patchobject(return_server, 'interface_detach') mock_detach = self.patchobject(return_server, 'interface_detach')
@ -3927,16 +3927,15 @@ class ServersTest(common.HeatTestCase):
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
poor_interfaces = [ poor_interfaces = [
self.create_fake_iface('95e25541-d26a-478d-8f36-ae1c8f6b74dc', create_fake_iface(port='95e25541-d26a-478d-8f36-ae1c8f6b74dc',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'11.12.13.14'), ip='11.12.13.14'),
self.create_fake_iface('4121f61a-1b2e-4ab0-901e-eade9b1cb09d', create_fake_iface(port='4121f61a-1b2e-4ab0-901e-eade9b1cb09d',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'21.22.23.24'), ip='21.22.23.24'),
self.create_fake_iface('0907fa82-a024-43c2-9fc5-efa1bccaa74a', create_fake_iface(port='0907fa82-a024-43c2-9fc5-efa1bccaa74a',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'31.32.33.34') ip='31.32.33.34')]
]
self.patchobject(return_server, 'interface_list', self.patchobject(return_server, 'interface_list',
return_value=poor_interfaces) return_value=poor_interfaces)
@ -3973,13 +3972,12 @@ class ServersTest(common.HeatTestCase):
self.patchobject(self.fc.servers, 'get', return_value=return_server) self.patchobject(self.fc.servers, 'get', return_value=return_server)
poor_interfaces = [ poor_interfaces = [
self.create_fake_iface('95e25541-d26a-478d-8f36-ae1c8f6b74dc', create_fake_iface(port='95e25541-d26a-478d-8f36-ae1c8f6b74dc',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'11.12.13.14'), ip='11.12.13.14'),
self.create_fake_iface('4121f61a-1b2e-4ab0-901e-eade9b1cb09d', create_fake_iface(port='4121f61a-1b2e-4ab0-901e-eade9b1cb09d',
'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', net='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'21.22.23.24'), ip='21.22.23.24')]
]
self.patchobject(return_server, 'interface_list', self.patchobject(return_server, 'interface_list',
return_value=poor_interfaces) return_value=poor_interfaces)
@ -4586,10 +4584,10 @@ class ServerInternalPortTest(ServersTest):
self.port_create.return_value = {'port': {'id': '7788'}} self.port_create.return_value = {'port': {'id': '7788'}}
data_set = self.patchobject(resource.Resource, 'data_set') data_set = self.patchobject(resource.Resource, 'data_set')
old_net = [{'network': '4321', old_net = [self.create_old_net(net='4321',
'subnet': '1234', subnet='1234',
'fixed_ip': '127.0.0.1'}, ip='127.0.0.1'),
{'port': '3344'}] self.create_old_net(port='3344')]
new_net = [{'port': '3344'}, new_net = [{'port': '3344'},
{'port': '5566'}, {'port': '5566'},
@ -4597,10 +4595,11 @@ class ServerInternalPortTest(ServersTest):
'subnet': '5678', 'subnet': '5678',
'fixed_ip': '10.0.0.1'} 'fixed_ip': '10.0.0.1'}
] ]
interfaces = [
self.create_fake_iface('1122', '4321', '127.0.0.1'), interfaces = [create_fake_iface(port='1122', net='4321',
self.create_fake_iface('3344', '4321', '10.0.0.2'), ip='127.0.0.1', subnet='1234'),
] create_fake_iface(port='3344', net='4321', ip='10.0.0.2',
subnet='subnet')]
server.calculate_networks(old_net, new_net, interfaces) server.calculate_networks(old_net, new_net, interfaces)
@ -4657,16 +4656,12 @@ class ServerInternalPortTest(ServersTest):
'11910', '11910',
'1199']) '1199'])
old_net = [{'network': '4321', old_net = [
'subnet': '1234', self.create_old_net(net='4321', subnet='1234', ip='127.0.0.1',
'fixed_ip': '127.0.0.1', port='1122', floating_ip='1199'),
'port': '1122', self.create_old_net(net='8765', subnet='5678', ip='127.0.0.2',
'floating_ip': '1199'}, port='3344', floating_ip='9911')
{'network': '8765', ]
'subnet': '5678',
'fixed_ip': '127.0.0.2',
'port': '3344',
'floating_ip': '9911'}]
new_net = [{'network': '8765', new_net = [{'network': '8765',
'subnet': '5678', 'subnet': '5678',