Merge lp:~hopem/charm-helpers/lp1500386 into lp:charm-helpers

Proposed by Edward Hope-Morley
Status: Superseded
Proposed branch: lp:~hopem/charm-helpers/lp1500386
Merge into: lp:charm-helpers
Diff against target: 94 lines (+32/-8)
3 files modified
charmhelpers/contrib/openstack/context.py (+3/-3)
charmhelpers/contrib/openstack/neutron.py (+3/-3)
tests/contrib/openstack/test_os_contexts.py (+26/-2)
To merge this branch: bzr merge lp:~hopem/charm-helpers/lp1500386
Reviewer Review Type Date Requested Status
Liam Young (community) Needs Fixing
OpenStack Charmers Pending
Review via email: mp+272572@code.launchpad.net

This proposal has been superseded by a proposal from 2015-09-29.

To post a comment you must log in.
Revision history for this message
Liam Young (gnuoy) wrote :

Looks like there is an unstable (using py3) unit test:

FAIL: test_phy_nic_mtu_context_vlan_w_duplicate_raw (tests.contrib.openstack.test_os_contexts.ContextTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/liam/branches/merges/charm-helpers-272572/.venv3/lib/python3.4/site-packages/mock.py", line 1201, in patched
    return func(*args, **keywargs)
  File "/home/liam/branches/merges/charm-helpers-272572/tests/contrib/openstack/test_os_contexts.py", line 2678, in test_phy_nic_mtu_context_vlan_w_duplicate_raw
    'mtu': 5000})
AssertionError: {'devs': 'eth0\\neth0.200\\neth0.100', 'mtu': 5000} != {'devs': 'eth0\\neth0.100\\neth0.200', 'mtu': 5000}
- {'devs': 'eth0\\neth0.200\\neth0.100', 'mtu': 5000}
? ^ ^

+ {'devs': 'eth0\\neth0.100\\neth0.200', 'mtu': 5000}
? ^ ^

review: Needs Fixing
lp:~hopem/charm-helpers/lp1500386 updated
460. By Edward Hope-Morley

fix py3 ordering issue

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/context.py'
2--- charmhelpers/contrib/openstack/context.py 2015-09-25 16:11:52 +0000
3+++ charmhelpers/contrib/openstack/context.py 2015-09-29 20:58:03 +0000
4@@ -1364,7 +1364,7 @@
5 normalized.update({port: port for port in resolved
6 if port in ports})
7 if resolved:
8- return {bridge: normalized[port] for port, bridge in
9+ return {normalized[port]: bridge for port, bridge in
10 six.iteritems(portmap) if port in normalized.keys()}
11
12 return None
13@@ -1375,8 +1375,8 @@
14 def __call__(self):
15 ctxt = {}
16 mappings = super(PhyNICMTUContext, self).__call__()
17- if mappings and mappings.values():
18- ports = mappings.values()
19+ if mappings and mappings.keys():
20+ ports = sorted(mappings.keys())
21 napi_settings = NeutronAPIContext()()
22 mtu = napi_settings.get('network_device_mtu')
23 all_ports = set()
24
25=== modified file 'charmhelpers/contrib/openstack/neutron.py'
26--- charmhelpers/contrib/openstack/neutron.py 2015-09-02 14:09:43 +0000
27+++ charmhelpers/contrib/openstack/neutron.py 2015-09-29 20:58:03 +0000
28@@ -310,10 +310,10 @@
29 def parse_data_port_mappings(mappings, default_bridge='br-data'):
30 """Parse data port mappings.
31
32- Mappings must be a space-delimited list of port:bridge mappings.
33+ Mappings must be a space-delimited list of bridge:port.
34
35- Returns dict of the form {port:bridge} where port may be an mac address or
36- interface name.
37+ Returns dict of the form {port:bridge} where ports may be mac addresses or
38+ interface names.
39 """
40
41 # NOTE(dosaboy): we use rvalue for key to allow multiple values to be
42
43=== modified file 'tests/contrib/openstack/test_os_contexts.py'
44--- tests/contrib/openstack/test_os_contexts.py 2015-09-28 09:36:02 +0000
45+++ tests/contrib/openstack/test_os_contexts.py 2015-09-29 20:58:03 +0000
46@@ -2604,7 +2604,7 @@
47 'phybr1:eth1011'})
48 mock_resolve.side_effect = lambda ports: ['eth1010']
49 self.assertEquals(context.DataPortContext()(),
50- {'phybr1': 'eth1010'})
51+ {'eth1010': 'phybr1'})
52
53 @patch.object(context, 'get_nic_hwaddr')
54 @patch.object(context.NeutronPortContext, 'resolve_ports')
55@@ -2627,7 +2627,7 @@
56 mock_resolve.side_effect = fake_resolve
57
58 self.assertEquals(context.DataPortContext()(),
59- {'phybr1': 'eth1010'})
60+ {'eth1010': 'phybr1'})
61
62 @patch.object(context.NeutronAPIContext, '__call__', lambda *args:
63 {'network_device_mtu': 5000})
64@@ -2653,6 +2653,30 @@
65 ctxt = context.PhyNICMTUContext()()
66 self.assertEqual(ctxt, {'devs': 'eth0\\neth0.100', 'mtu': 5000})
67
68+ @patch.object(context.glob, 'glob')
69+ @patch.object(context.NeutronAPIContext, '__call__', lambda *args:
70+ {'network_device_mtu': 5000})
71+ @patch.object(context, 'get_nic_hwaddr', lambda inst, port: port)
72+ @patch.object(context.NeutronPortContext, 'resolve_ports',
73+ lambda inst, ports: ports)
74+ def test_phy_nic_mtu_context_vlan_w_duplicate_raw(self, mock_glob):
75+ self.config.side_effect = fake_config({'data-port':
76+ 'phybr1:eth0.100 '
77+ 'phybr1:eth0.200'})
78+
79+ def fake_glob(wcard):
80+ if 'eth0.100' in wcard:
81+ return ['/sys/class/net/eth0.100/lower_eth0']
82+ elif 'eth0.200' in wcard:
83+ return ['/sys/class/net/eth0.200/lower_eth0']
84+
85+ raise Exception("Unexpeced key '%s'" % (wcard))
86+
87+ mock_glob.side_effect = fake_glob
88+ ctxt = context.PhyNICMTUContext()()
89+ self.assertEqual(ctxt, {'devs': 'eth0\\neth0.100\\neth0.200',
90+ 'mtu': 5000})
91+
92 def test_neutronapicontext_defaults(self):
93 self.relation_ids.return_value = []
94 expected_keys = [

Subscribers

People subscribed via source and target branches