Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: avoid leaks into host system checking of ovs-vsctl cmd #4275

Merged
merged 1 commit into from
Jul 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions tests/unittests/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -4291,11 +4291,16 @@ def test_device_driver_v2(
}
self.assertEqual(expected, network_cfg)

@mock.patch("cloudinit.net.openvswitch_is_installed", return_value=False)
@mock.patch("cloudinit.net.sys_dev_path")
@mock.patch("cloudinit.net.read_sys_net")
@mock.patch("cloudinit.net.get_devicelist")
def test_device_driver(
self, mock_get_devicelist, mock_read_sys_net, mock_sys_dev_path
self,
mock_get_devicelist,
mock_read_sys_net,
mock_sys_dev_path,
_ovs_is_installed,
):
devices = {
"eth0": {
Expand Down Expand Up @@ -4375,11 +4380,16 @@ def test_device_driver(
]
self.assertEqual(", ".join(expected_rule) + "\n", contents.lstrip())

@mock.patch("cloudinit.net.openvswitch_is_installed", return_value=False)
@mock.patch("cloudinit.net.sys_dev_path")
@mock.patch("cloudinit.net.read_sys_net")
@mock.patch("cloudinit.net.get_devicelist")
def test_hv_netvsc_vf_filter(
self, mock_get_devicelist, mock_read_sys_net, mock_sys_dev_path
self,
mock_get_devicelist,
mock_read_sys_net,
mock_sys_dev_path,
_ovs_installed,
):
devices = {
"eth1": {
Expand Down Expand Up @@ -6556,6 +6566,7 @@ class TestNetplanNetRendering:
)
@mock.patch("cloudinit.net.util.get_cmdline", return_value="root=myroot")
@mock.patch("cloudinit.net.netplan._clean_default")
@mock.patch("cloudinit.net.openvswitch_is_installed", return_value=False)
@mock.patch("cloudinit.net.sys_dev_path")
@mock.patch("cloudinit.net.read_sys_net")
@mock.patch("cloudinit.net.get_devicelist")
Expand All @@ -6564,6 +6575,7 @@ def test_render(
mock_get_devicelist,
mock_read_sys_net,
mock_sys_dev_path,
_openvswitch_is_installed,
mock_clean_default,
m_get_cmdline,
m_renderer_features,
Expand Down
Loading