Increase code coverage for floating_mangle_rules()
Don't mock this method out in the router_info tests, but instead verify it made the correct calls. TrivialFix Change-Id: Iad6df382b17c6e814c2431b4570aba6712f13797
This commit is contained in:
parent
2db8620523
commit
ca3c57308f
@ -370,21 +370,23 @@ class TestBasicRouterOperations(BasicRouterTestCaseFramework):
|
|||||||
ri.get_floating_ips = mock.Mock(return_value=fips)
|
ri.get_floating_ips = mock.Mock(return_value=fips)
|
||||||
ri._get_external_address_scope = mock.Mock(return_value='scope2')
|
ri._get_external_address_scope = mock.Mock(return_value='scope2')
|
||||||
ipv4_mangle = ri.iptables_manager.ipv4['mangle'] = mock.MagicMock()
|
ipv4_mangle = ri.iptables_manager.ipv4['mangle'] = mock.MagicMock()
|
||||||
ri.floating_mangle_rules = mock.Mock(
|
|
||||||
return_value=[(mock.sentinel.chain1, mock.sentinel.rule1)])
|
|
||||||
ri.get_external_device_name = mock.Mock()
|
ri.get_external_device_name = mock.Mock()
|
||||||
|
|
||||||
ri.process_floating_ip_address_scope_rules()
|
ri.process_floating_ip_address_scope_rules()
|
||||||
|
|
||||||
# Be sure that the rules are cleared first
|
internal_mark = ri.get_address_scope_mark_mask('scope1')
|
||||||
self.assertEqual(mock.call.clear_rules_by_tag('floating_ip'),
|
self.assertEqual(2, ipv4_mangle.add_rule.call_count)
|
||||||
ipv4_mangle.mock_calls[0])
|
expected_calls = [
|
||||||
# Be sure that add_rule is called somewhere in the middle
|
mock.call.clear_rules_by_tag('floating_ip'),
|
||||||
self.assertEqual(1, ipv4_mangle.add_rule.call_count)
|
mock.call.add_rule('floatingip',
|
||||||
self.assertEqual(mock.call.add_rule(mock.sentinel.chain1,
|
'-d %s/32 -j MARK --set-xmark %s' %
|
||||||
mock.sentinel.rule1,
|
(mock.sentinel.fip, internal_mark),
|
||||||
tag='floating_ip'),
|
tag='floating_ip'),
|
||||||
ipv4_mangle.mock_calls[1])
|
mock.call.add_rule('FORWARD',
|
||||||
|
'-s %s/32 -j $float-snat' % mock.sentinel.ip,
|
||||||
|
tag='floating_ip')
|
||||||
|
]
|
||||||
|
ipv4_mangle.assert_has_calls(expected_calls)
|
||||||
|
|
||||||
def test_process_floating_ip_address_scope_rules_same_scopes(self):
|
def test_process_floating_ip_address_scope_rules_same_scopes(self):
|
||||||
ri = self._create_router()
|
ri = self._create_router()
|
||||||
|
Loading…
Reference in New Issue
Block a user