Change in vdsm[master]: storage: add tests for Mount.isMounted in mount.py

ishaby at redhat.com ishaby at redhat.com
Wed Apr 27 14:36:02 UTC 2016


Idan Shaby has uploaded a new change for review.

Change subject: storage: add tests for Mount.isMounted in mount.py
......................................................................

storage: add tests for Mount.isMounted in mount.py

Change-Id: Ic6a97e5dc537bf41897e05ec41d2b1cc9f42981c
Signed-off-by: Idan Shaby <ishaby at redhat.com>
---
M tests/mountTests.py
1 file changed, 35 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/04/56704/1

diff --git a/tests/mountTests.py b/tests/mountTests.py
index 7903e9e..2ea69d2 100644
--- a/tests/mountTests.py
+++ b/tests/mountTests.py
@@ -121,6 +121,7 @@
         self.assertNotEqual(hash(m1), hash(m2))
 
 
+ at expandPermutations
 class MountTests(TestCaseBase):
 
     @ValidateRunningAsRoot
@@ -162,6 +163,40 @@
                 with stopwatch("Wait for udev events"):
                     udevadm.settle(5)
 
+    @permutations([
+        # Only fs_spec matches
+        ("server:/", "other_file", False),
+
+        # Only fs_file matches
+        ("other_spec", "/rhev/data-center/mnt/server:_", False),
+
+        # Both fs_spec and fs_file don't match
+        ("other_spec", "other_file", False),
+
+        # Both match
+        ("server:/", "/rhev/data-center/mnt/server:_", True),
+    ])
+    def test_is_mounted(self, fs_spec, fs_file, equality):
+        """
+        Verifies that both fs_spec and fs_file match the mounted target.
+        """
+        with fake_mounts([b"server:/ "
+                          b"/rhev/data-center/mnt/server:_ "
+                          b"nfs4 defaults 0 0"]):
+            mnt = mount.Mount(fs_spec, fs_file)
+            self.assertEqual(mnt.isMounted(), equality)
+
+    def test_is_mounted_with_symlink(self):
+        with namedTemporaryDir() as dir:
+            with temporaryPath(dir=dir) as file:
+                link_to_file = os.path.join(dir, "link_to_file")
+                os.symlink(file, link_to_file)
+                mountpoint = "/tmp/mountpoint"
+                with fake_mounts([b"%s %s nfs4 defaults 0 0" %
+                                  (link_to_file, mountpoint)]):
+                    mnt = mount.Mount(link_to_file, mountpoint)
+                    self.assertTrue(mnt.isMounted())
+
 
 class IterMountsPerfTests(TestCaseBase):
     line_fmt = ('%(fs_spec)s\t%(fs_file)s\t%(fs_vfstype)s'


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6a97e5dc537bf41897e05ec41d2b1cc9f42981c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Idan Shaby <ishaby at redhat.com>


More information about the vdsm-patches mailing list