Edward Haas has uploaded a new change for review.

Change subject: net: Relocate sysfs_bond_permission to nettestlib
......................................................................

net: Relocate sysfs_bond_permission to nettestlib

CI does not always allow access to sysfs and will fail the tests when
such access is attempted.

Linux bonds driver is using sysfs to configure bonds.
This patch locates the sysfs bond access permission check under
nettestlib in order to allow several test modules to use it when bonbs
are involved.

Change-Id: I8f5016d8453d021d663fe293e17edf87b24c215d
Signed-off-by: Edward Haas <edwa...@redhat.com>
---
M tests/network/link_bond_test.py
M tests/network/nettestlib.py
2 files changed, 20 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/31/64131/1

diff --git a/tests/network/link_bond_test.py b/tests/network/link_bond_test.py
index a610f63..021fda8 100644
--- a/tests/network/link_bond_test.py
+++ b/tests/network/link_bond_test.py
@@ -21,21 +21,18 @@
 from contextlib import contextmanager
 
 from nose.plugins.attrib import attr
-from nose.plugins.skip import SkipTest
 
 from testlib import VdsmTestCase as TestCaseBase
 
-from .nettestlib import dummy_devices
+from .nettestlib import dummy_devices, check_sysfs_bond_permission
 
 from vdsm.network.link import iface
 from vdsm.network.link.bond import Bond
-from vdsm.network.link.bond import BondSysFS
 from vdsm.utils import random_iface_name
 
 
 def setup_module():
-    if not _has_sysfs_bond_permission():
-        raise SkipTest("This test requires sysfs bond write access")
+    check_sysfs_bond_permission()
 
 
 @attr(type='integration')
@@ -112,13 +109,3 @@
         yield bond
     finally:
         bond.destroy()
-
-
-def _has_sysfs_bond_permission():
-    bond = BondSysFS(random_iface_name('check_', max_length=11))
-    try:
-        bond.create()
-        bond.destroy()
-    except IOError:
-        return False
-    return True
diff --git a/tests/network/nettestlib.py b/tests/network/nettestlib.py
index df66d53..42673af 100644
--- a/tests/network/nettestlib.py
+++ b/tests/network/nettestlib.py
@@ -38,10 +38,10 @@
 from vdsm.network.ipwrapper import (
     addrAdd, linkSet, linkAdd, linkDel, IPRoute2Error, netns_add, netns_delete,
     netns_exec)
-from vdsm.network.link import iface as linkiface
+from vdsm.network.link import iface as linkiface, bond as linkbond
 from vdsm.network.netlink import monitor
 from vdsm.commands import execCmd
-from vdsm.utils import CommandPath, random_iface_name
+from vdsm.utils import CommandPath, memoized, random_iface_name
 
 from . import dhcp
 from . import firewall
@@ -480,3 +480,19 @@
         yield
     finally:
         shutil.copy2(RESOLV_CONF_BACKUP, RESOLV_CONF)
+
+
+def check_sysfs_bond_permission():
+    if not _has_sysfs_bond_permission():
+        raise SkipTest("This test requires sysfs bond write access")
+
+
+@memoized
+def _has_sysfs_bond_permission():
+    bond = linkbond.BondSysFS(random_iface_name('check_', max_length=11))
+    try:
+        bond.create()
+        bond.destroy()
+    except IOError:
+        return False
+    return True


-- 
To view, visit https://gerrit.ovirt.org/64131
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f5016d8453d021d663fe293e17edf87b24c215d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <edwa...@redhat.com>
_______________________________________________
vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org
To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org

Reply via email to