From 77d40d0713385dcb54b8aa1d0d5a2e1f8386609c Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 2 Feb 2018 08:12:51 -0500 Subject: [PATCH] ceph-volume tests for validate_devices Signed-off-by: Alfredo Deza (cherry picked from commit bece7af0523b04d39c26011990cb1fe323aecdd8) --- .../tests/devices/simple/test_activate.py | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/ceph-volume/ceph_volume/tests/devices/simple/test_activate.py b/src/ceph-volume/ceph_volume/tests/devices/simple/test_activate.py index bae3276a9b768..da3b955a05471 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/simple/test_activate.py +++ b/src/ceph-volume/ceph_volume/tests/devices/simple/test_activate.py @@ -21,3 +21,67 @@ class TestActivate(object): activate.Activate([]).main() stdout, stderr = capsys.readouterr() assert 'Activate OSDs by mounting devices previously configured' in stdout + + +class TestValidateDevices(object): + + def test_filestore_missing_journal(self): + activation = activate.Activate([]) + with pytest.raises(RuntimeError) as error: + activation.validate_devices({'type': 'filestore', 'data': {}}) + assert 'Unable to activate filestore OSD due to missing devices' in str(error) + + def test_filestore_missing_data(self): + activation = activate.Activate([]) + with pytest.raises(RuntimeError) as error: + activation.validate_devices({'type': 'filestore', 'journal': {}}) + assert 'Unable to activate filestore OSD due to missing devices' in str(error) + + def test_filestore_journal_device_found(self, capsys): + activation = activate.Activate([]) + with pytest.raises(RuntimeError): + activation.validate_devices({'type': 'filestore', 'journal': {}}) + stdout, stderr = capsys.readouterr() + assert "devices found: ['journal']" in stdout + + def test_filestore_data_device_found(self, capsys): + activation = activate.Activate([]) + with pytest.raises(RuntimeError): + activation.validate_devices({'type': 'filestore', 'data': {}}) + stdout, stderr = capsys.readouterr() + assert "devices found: ['data']" in stdout + + def test_filestore_with_all_devices(self): + activation = activate.Activate([]) + result = activation.validate_devices({'type': 'filestore', 'journal': {}, 'data': {}}) + assert result is True + + def test_bluestore_with_all_devices(self): + activation = activate.Activate([]) + result = activation.validate_devices({'type': 'bluestore', 'data': {}, 'block': {}}) + assert result is True + + def test_bluestore_is_default(self): + activation = activate.Activate([]) + result = activation.validate_devices({'data': {}, 'block': {}}) + assert result is True + + def test_bluestore_data_device_found(self, capsys): + activation = activate.Activate([]) + with pytest.raises(RuntimeError): + activation.validate_devices({'data': {}}) + stdout, stderr = capsys.readouterr() + assert "devices found: ['data']" in stdout + + def test_bluestore_missing_data(self): + activation = activate.Activate([]) + with pytest.raises(RuntimeError) as error: + activation.validate_devices({'type': 'bluestore', 'block': {}}) + assert 'Unable to activate bluestore OSD due to missing devices' in str(error) + + def test_bluestore_block_device_found(self, capsys): + activation = activate.Activate([]) + with pytest.raises(RuntimeError): + activation.validate_devices({'block': {}}) + stdout, stderr = capsys.readouterr() + assert "devices found: ['block']" in stdout -- 2.39.5