]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Properly handle empty before/after notifications in l2pop code
authorEugene Nikanorov <enikanorov@mirantis.com>
Fri, 12 Sep 2014 05:05:39 +0000 (09:05 +0400)
committerEugene Nikanorov <enikanorov@mirantis.com>
Fri, 12 Sep 2014 05:05:39 +0000 (09:05 +0400)
Change-Id: I8644bb7cc2afb3b181397a478f96927990c0a4ca
Closes-Bug: #1367881

neutron/agent/l2population_rpc.py
neutron/tests/unit/agent/test_l2population_rpc.py

index 93f6395dd9f62111cfeeb8f627eb38be8f0d5d88..4a485c4ce10baf13a51efe7d3ad14701a838c4d6 100644 (file)
@@ -246,12 +246,12 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
                 if agent_ip == local_ip:
                     continue
 
-                after = state.get('after')
+                after = state.get('after', [])
                 for mac, ip in after:
                     self.setup_entry_for_arp_reply(br, 'add', lvm.vlan, mac,
                                                    ip)
 
-                before = state.get('before')
+                before = state.get('before', [])
                 for mac, ip in before:
                     self.setup_entry_for_arp_reply(br, 'remove', lvm.vlan, mac,
                                                    ip)
index 7b1e053449702e1dd8a857a661a37c57ff23b819..563c53b19db4a4cf3bdc77cf0df2bacd4ed2cdde 100644 (file)
@@ -234,3 +234,17 @@ class TestL2populationRpcCallBackTunnelMixin(
                                       upd_fdb_entry_val, self.local_ip,
                                       self.local_vlan_map1)
         self.assertFalse(m_setup_entry_for_arp_reply.call_count)
+
+    def test_fdb_chg_ip_tun_empty_before_after(self):
+        upd_fdb_entry_val = {
+            self.lvms[0].net: {
+                self.local_ip: {},
+            },
+        }
+        m_setup_entry_for_arp_reply = mock.Mock()
+        self.fakeagent.setup_entry_for_arp_reply = m_setup_entry_for_arp_reply
+        # passing non-local ip
+        self.fakeagent.fdb_chg_ip_tun('context', self.fakebr,
+                                      upd_fdb_entry_val, "8.8.8.8",
+                                      self.local_vlan_map1)
+        self.assertFalse(m_setup_entry_for_arp_reply.call_count)