]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests check for mount/format usage from ceph.conf
authorAlfredo Deza <adeza@redhat.com>
Mon, 12 Feb 2018 21:46:06 +0000 (16:46 -0500)
committerAlfredo Deza <adeza@redhat.com>
Thu, 15 Feb 2018 16:29:29 +0000 (11:29 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/util/test_prepare.py

index 6bcdfbabd72370d2b08c0219f61a39fc7a62bda4..67ee140abba174d6f9a2268551973c8cabc64f26 100644 (file)
@@ -1,8 +1,9 @@
 import pytest
+from textwrap import dedent
 import json
 from ceph_volume.util import prepare
 from ceph_volume.util.prepare import system
-from ceph_volume import conf
+from ceph_volume import conf, configuration
 from ceph_volume.tests.conftest import Factory
 
 
@@ -64,6 +65,56 @@ class TestFormatDevice(object):
         flags = fake_run.calls[0]['args'][0]
         assert '--why-yes' in flags
 
+    def test_default_options(self, conf_ceph_stub, fake_run):
+        conf_ceph_stub(dedent("""[global]
+        fsid = 1234lkjh1234"""))
+        conf.cluster = 'ceph'
+        prepare.format_device('/dev/sda1')
+        expected = [
+            'mkfs', '-t', 'xfs',
+            '-f', '-i', 'size=2048',  # default flags
+            '/dev/sda1']
+        assert expected == fake_run.calls[0]['args'][0]
+
+    def test_multiple_options_are_used(self, conf_ceph_stub, fake_run):
+        conf_ceph_stub(dedent("""[global]
+        fsid = 1234lkjh1234
+        [osd]
+        osd mkfs options xfs = -f -i size=1024"""))
+        conf.cluster = 'ceph'
+        prepare.format_device('/dev/sda1')
+        expected = [
+            'mkfs', '-t', 'xfs',
+            '-f', '-i', 'size=1024',
+            '/dev/sda1']
+        assert expected == fake_run.calls[0]['args'][0]
+
+    def test_multiple_options_will_get_the_force_flag(self, conf_ceph_stub, fake_run):
+        conf_ceph_stub(dedent("""[global]
+        fsid = 1234lkjh1234
+        [osd]
+        osd mkfs options xfs = -i size=1024"""))
+        conf.cluster = 'ceph'
+        prepare.format_device('/dev/sda1')
+        expected = [
+            'mkfs', '-t', 'xfs',
+            '-f', '-i', 'size=1024',
+            '/dev/sda1']
+        assert expected == fake_run.calls[0]['args'][0]
+
+    def test_underscore_options_are_used(self, conf_ceph_stub, fake_run):
+        conf_ceph_stub(dedent("""[global]
+        fsid = 1234lkjh1234
+        [osd]
+        osd_mkfs_options_xfs = -i size=128"""))
+        conf.cluster = 'ceph'
+        prepare.format_device('/dev/sda1')
+        expected = [
+            'mkfs', '-t', 'xfs',
+            '-f', '-i', 'size=128',
+            '/dev/sda1']
+        assert expected == fake_run.calls[0]['args'][0]
+
 
 class TestOsdMkfsBluestore(object):
 
@@ -88,3 +139,56 @@ class TestOsdMkfsBluestore(object):
         prepare.osd_mkfs_bluestore(1, 'asdf', db='/dev/smm2')
         assert '--bluestore-block-db-path' in fake_call.calls[0]['args'][0]
         assert '/dev/smm2' in fake_call.calls[0]['args'][0]
+
+
+class TestMountOSD(object):
+
+    def test_default_options(self, conf_ceph_stub, fake_run):
+        conf_ceph_stub(dedent("""[global]
+        fsid = 1234lkjh1234"""))
+        conf.cluster = 'ceph'
+        prepare.mount_osd('/dev/sda1', 1)
+        expected = [
+            'mount', '-t', 'xfs', '-o',
+            'rw', 'noatime', 'inode64', # default flags
+            '/dev/sda1', '/var/lib/ceph/osd/ceph-1']
+        assert expected == fake_run.calls[0]['args'][0]
+
+    def test_mount_options_are_used(self, conf_ceph_stub, fake_run):
+        conf_ceph_stub(dedent("""[global]
+        fsid = 1234lkjh1234
+        [osd]
+        osd mount options xfs = rw"""))
+        conf.cluster = 'ceph'
+        prepare.mount_osd('/dev/sda1', 1)
+        expected = [
+            'mount', '-t', 'xfs', '-o',
+            'rw',
+            '/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):
+        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]
+
+    def test_underscore_mount_options_are_used(self, conf_ceph_stub, fake_run):
+        conf_ceph_stub(dedent("""[global]
+        fsid = 1234lkjh1234
+        [osd]
+        osd mount options xfs = rw"""))
+        conf.cluster = 'ceph'
+        prepare.mount_osd('/dev/sda1', 1)
+        expected = [
+            'mount', '-t', 'xfs', '-o',
+            'rw',
+            '/dev/sda1', '/var/lib/ceph/osd/ceph-1']
+        assert expected == fake_run.calls[0]['args'][0]