]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests.util update tests for mount flags 20543/head
authorAlfredo Deza <adeza@redhat.com>
Thu, 22 Feb 2018 18:47:53 +0000 (13:47 -0500)
committerAlfredo Deza <adeza@redhat.com>
Thu, 22 Feb 2018 21:19:54 +0000 (16:19 -0500)
Include parametrized flags for ensuring a combination of values will
still be normalized regardless on how they are on ceph.conf

Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/util/test_prepare.py

index 2524f0eb128c1c37abe8c13fd92f36c02bd21d9e..c65e51f6b5d6bc76ae78c1f1e043b28756a996ea 100644 (file)
@@ -150,7 +150,7 @@ class TestMountOSD(object):
         prepare.mount_osd('/dev/sda1', 1)
         expected = [
             'mount', '-t', 'xfs', '-o',
-            'rw', 'noatime', 'inode64', # default flags
+            'rw,noatime,inode64', # default flags
             '/dev/sda1', '/var/lib/ceph/osd/ceph-1']
         assert expected == fake_run.calls[0]['args'][0]
 
@@ -167,7 +167,7 @@ class TestMountOSD(object):
             '/dev/sda1', '/var/lib/ceph/osd/ceph-1']
         assert expected == fake_run.calls[0]['args'][0]
 
-    def test_multiple_options_are_used(self, conf_ceph_stub, fake_run):
+    def test_multiple_whitespace_options_are_used(self, conf_ceph_stub, fake_run):
         conf_ceph_stub(dedent("""[global]
         fsid = 1234lkjh1234
         [osd]
@@ -176,7 +176,20 @@ class TestMountOSD(object):
         prepare.mount_osd('/dev/sda1', 1)
         expected = [
             'mount', '-t', 'xfs', '-o',
-            'rw', 'auto', 'exec',
+            'rw,auto,exec',
+            '/dev/sda1', '/var/lib/ceph/osd/ceph-1']
+        assert expected == fake_run.calls[0]['args'][0]
+
+    def test_multiple_comma_whitespace_options_are_used(self, conf_ceph_stub, fake_run):
+        conf_ceph_stub(dedent("""[global]
+        fsid = 1234lkjh1234
+        [osd]
+        osd mount options xfs = rw, auto, exec"""))
+        conf.cluster = 'ceph'
+        prepare.mount_osd('/dev/sda1', 1)
+        expected = [
+            'mount', '-t', 'xfs', '-o',
+            'rw,auto,exec',
             '/dev/sda1', '/var/lib/ceph/osd/ceph-1']
         assert expected == fake_run.calls[0]['args'][0]
 
@@ -192,3 +205,40 @@ class TestMountOSD(object):
             'rw',
             '/dev/sda1', '/var/lib/ceph/osd/ceph-1']
         assert expected == fake_run.calls[0]['args'][0]
+
+
+ceph_conf_mount_values = [
+    ['rw,', 'auto,' 'exec'],
+    ['rw', 'auto', 'exec'],
+    [' rw ', ' auto ', ' exec '],
+    ['rw,', 'auto,', 'exec,'],
+    [',rw ', ',auto ', ',exec,'],
+    [',rw,', ',auto,', ',exec,'],
+]
+
+string_mount_values = [
+    'rw, auto exec ',
+    'rw  auto exec',
+    ',rw, auto, exec,',
+    ' rw  auto exec ',
+    ' rw,auto,exec ',
+    'rw,auto,exec',
+    ',rw,auto,exec,',
+    'rw,auto,exec ',
+    'rw, auto, exec ',
+]
+
+
+class TestNormalizeFlags(object):
+    # a bit overkill since most of this is already tested in prepare.mount_osd
+    # tests
+
+    @pytest.mark.parametrize("flags", ceph_conf_mount_values)
+    def test_normalize_lists(self, flags):
+        result = prepare._normalize_mount_flags(flags)
+        assert result == 'rw,auto,exec'
+
+    @pytest.mark.parametrize("flags", string_mount_values)
+    def test_normalize_strings(self, flags):
+        result = prepare._normalize_mount_flags(flags)
+        assert result == 'rw,auto,exec'