From 5407e898a6d36cd5aecdc32f1c3d054003574973 Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Tue, 31 Mar 2020 16:51:55 -0400 Subject: [PATCH] tests/library: parametrize ceph_volume objecstore This adds the objectstore testing for both filestore and bluestore on the ceph_volume module. Signed-off-by: Dimitri Savineau --- tests/library/test_ceph_volume.py | 80 +++++++++++++------------------ 1 file changed, 33 insertions(+), 47 deletions(-) diff --git a/tests/library/test_ceph_volume.py b/tests/library/test_ceph_volume.py index 783de9874..53a6d929b 100644 --- a/tests/library/test_ceph_volume.py +++ b/tests/library/test_ceph_volume.py @@ -3,6 +3,7 @@ sys.path.append('./library') import ceph_volume import mock import os +import pytest # Python 3 @@ -161,10 +162,11 @@ class TestCephVolumeModule(object): result = ceph_volume.list_storage_inventory(fake_module, fake_container_image) assert result == expected_command_list - def test_create_osd_container(self): + @pytest.mark.parametrize('objectstore', ['bluestore','filestore']) + def test_create_osd_container(self, objectstore): fake_module = MagicMock() fake_module.params = {'data': '/dev/sda', - 'objectstore': 'filestore', + 'objectstore': objectstore, 'cluster': 'ceph', } fake_action = "create" @@ -174,17 +176,18 @@ class TestCephVolumeModule(object): 'ceph', 'lvm', 'create', - '--filestore', + '--%s' % objectstore, '--data', '/dev/sda'] result = ceph_volume.prepare_or_create_osd( fake_module, fake_action, fake_container_image) assert result == expected_command_list - def test_create_osd(self): + @pytest.mark.parametrize('objectstore', ['bluestore','filestore']) + def test_create_osd(self, objectstore): fake_module = MagicMock() fake_module.params = {'data': '/dev/sda', - 'objectstore': 'filestore', + 'objectstore': objectstore, 'cluster': 'ceph', } fake_container_image = None @@ -194,17 +197,18 @@ class TestCephVolumeModule(object): 'ceph', 'lvm', 'create', - '--filestore', + '--%s' % objectstore, '--data', '/dev/sda'] result = ceph_volume.prepare_or_create_osd( fake_module, fake_action, fake_container_image) assert result == expected_command_list - def test_prepare_osd_container(self): + @pytest.mark.parametrize('objectstore', ['bluestore','filestore']) + def test_prepare_osd_container(self, objectstore): fake_module = MagicMock() fake_module.params = {'data': '/dev/sda', - 'objectstore': 'filestore', + 'objectstore': objectstore, 'cluster': 'ceph', } fake_action = "prepare" @@ -214,17 +218,18 @@ class TestCephVolumeModule(object): 'ceph', 'lvm', 'prepare', - '--filestore', + '--%s' % objectstore, '--data', '/dev/sda'] result = ceph_volume.prepare_or_create_osd( fake_module, fake_action, fake_container_image) assert result == expected_command_list - def test_prepare_osd(self): + @pytest.mark.parametrize('objectstore', ['bluestore','filestore']) + def test_prepare_osd(self, objectstore): fake_module = MagicMock() fake_module.params = {'data': '/dev/sda', - 'objectstore': 'filestore', + 'objectstore': objectstore, 'cluster': 'ceph', } fake_container_image = None @@ -234,18 +239,20 @@ class TestCephVolumeModule(object): 'ceph', 'lvm', 'prepare', - '--filestore', + '--%s' % objectstore, '--data', '/dev/sda'] result = ceph_volume.prepare_or_create_osd( fake_module, fake_action, fake_container_image) assert result == expected_command_list - def test_batch_osd_container(self): + @pytest.mark.parametrize('objectstore', ['bluestore','filestore']) + def test_batch_osd_container(self, objectstore): fake_module = MagicMock() fake_module.params = {'data': '/dev/sda', - 'objectstore': 'filestore', - 'journal_size': '100', + 'objectstore': objectstore, + 'block_db_size': '4096', + 'journal_size': '4096', 'cluster': 'ceph', 'batch_devices': ["/dev/sda", "/dev/sdb"]} @@ -255,22 +262,24 @@ class TestCephVolumeModule(object): 'ceph', 'lvm', 'batch', - '--filestore', + '--%s' % objectstore, '--yes', '--prepare', - '--journal-size', - '100', + '--journal-size' if objectstore == 'filestore' else '--block-db-size', # noqa E501 + '4096', '/dev/sda', '/dev/sdb'] result = ceph_volume.batch( fake_module, fake_container_image) assert result == expected_command_list - def test_batch_osd(self): + @pytest.mark.parametrize('objectstore', ['bluestore','filestore']) + def test_batch_osd(self, objectstore): fake_module = MagicMock() fake_module.params = {'data': '/dev/sda', - 'objectstore': 'filestore', - 'journal_size': '100', + 'objectstore': objectstore, + 'block_db_size': '4096', + 'journal_size': '4096', 'cluster': 'ceph', 'batch_devices': ["/dev/sda", "/dev/sdb"]} @@ -280,10 +289,10 @@ class TestCephVolumeModule(object): 'ceph', 'lvm', 'batch', - '--filestore', + '--%s' % objectstore, '--yes', - '--journal-size', - '100', + '--journal-size' if objectstore == 'filestore' else '--block-db-size', # noqa E501 + '4096', '/dev/sda', '/dev/sdb'] result = ceph_volume.batch( @@ -366,26 +375,3 @@ class TestCephVolumeModule(object): result = ceph_volume.batch( fake_module, fake_container_image) assert result == expected_command_list - - def test_batch_bluestore_with_custom_db_size(self): - fake_module = MagicMock() - fake_module.params = {'objectstore': 'bluestore', - 'cluster': 'ceph', - 'block_db_size': '4096', - 'batch_devices': ["/dev/sda", "/dev/sdb"]} - - fake_container_image = None - expected_command_list = ['ceph-volume', - '--cluster', - 'ceph', - 'lvm', - 'batch', - '--bluestore', - '--yes', - '--block-db-size', - '4096', - '/dev/sda', - '/dev/sdb'] - result = ceph_volume.batch( - fake_module, fake_container_image) - assert result == expected_command_list -- 2.39.5