Merge "Only create one IPWrapper class instance in _arping()"

This commit is contained in:
Zuul 2017-11-10 15:53:40 +00:00 committed by Gerrit Code Review
commit bfa3ac7f18
2 changed files with 1 additions and 6 deletions

View File

@ -1083,6 +1083,7 @@ def _arping(ns_name, iface_name, address, count, log_exception):
# not expected. In some cases (no response) and with some
# platforms (>=Ubuntu 14.04), arping exit code can be 1.
extra_ok_codes = [1]
ip_wrapper = IPWrapper(namespace=ns_name)
for i in range(count):
if not first:
# hopefully enough for kernel to get out of locktime loop
@ -1107,7 +1108,6 @@ def _arping(ns_name, iface_name, address, count, log_exception):
# removed while running
'-w', 1.5, address]
try:
ip_wrapper = IPWrapper(namespace=ns_name)
ip_wrapper.netns.execute(arping_cmd,
extra_ok_codes=extra_ok_codes)
except Exception as exc:

View File

@ -1689,15 +1689,10 @@ class TestArpPing(TestIPCmdBase):
mIPWrapper.assert_has_calls([
mock.call(namespace=mock.sentinel.ns_name),
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1]),
mock.call(namespace=mock.sentinel.ns_name),
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1]),
mock.call(namespace=mock.sentinel.ns_name),
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1, 2]),
mock.call(namespace=mock.sentinel.ns_name),
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1, 2]),
mock.call(namespace=mock.sentinel.ns_name),
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1, 2]),
mock.call(namespace=mock.sentinel.ns_name),
mock.call().netns.execute(mock.ANY, extra_ok_codes=[1, 2])])
ip_wrapper = mIPWrapper(namespace=mock.sentinel.ns_name)