ceph-volume tests check for mount/format usage from ceph.conf

Signed-off-by: Alfredo Deza <adeza@redhat.com>
This commit is contained in:
Alfredo Deza 2018-02-12 16:46:06 -05:00
parent a8eecc6471
commit 676c93fcf3

View 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]