]>
git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/ceph_volume/tests/devices/simple/test_activate.py
da3b955a054713142ad8c8b954994b41e35fbe84
3 from ceph_volume
.devices
.simple
import activate
6 class TestActivate(object):
8 def test_no_data_uuid(self
, factory
, tmpfile
, is_root
, monkeypatch
, capture
):
9 json_config
= tmpfile(contents
='{}')
10 args
= factory(osd_id
='0', osd_fsid
='1234', json_config
=json_config
)
11 with pytest
.raises(RuntimeError):
12 activate
.Activate([]).activate(args
)
14 def test_invalid_json_path(self
):
15 os
.environ
['CEPH_VOLUME_SIMPLE_JSON_DIR'] = '/non/existing/path'
16 with pytest
.raises(RuntimeError) as error
:
17 activate
.Activate(['1', 'asdf']).main()
18 assert 'RuntimeError: Expected JSON config path not found' in str(error
)
20 def test_main_spits_help_with_no_arguments(self
, capsys
):
21 activate
.Activate([]).main()
22 stdout
, stderr
= capsys
.readouterr()
23 assert 'Activate OSDs by mounting devices previously configured' in stdout
26 class TestValidateDevices(object):
28 def test_filestore_missing_journal(self
):
29 activation
= activate
.Activate([])
30 with pytest
.raises(RuntimeError) as error
:
31 activation
.validate_devices({'type': 'filestore', 'data': {}})
32 assert 'Unable to activate filestore OSD due to missing devices' in str(error
)
34 def test_filestore_missing_data(self
):
35 activation
= activate
.Activate([])
36 with pytest
.raises(RuntimeError) as error
:
37 activation
.validate_devices({'type': 'filestore', 'journal': {}})
38 assert 'Unable to activate filestore OSD due to missing devices' in str(error
)
40 def test_filestore_journal_device_found(self
, capsys
):
41 activation
= activate
.Activate([])
42 with pytest
.raises(RuntimeError):
43 activation
.validate_devices({'type': 'filestore', 'journal': {}})
44 stdout
, stderr
= capsys
.readouterr()
45 assert "devices found: ['journal']" in stdout
47 def test_filestore_data_device_found(self
, capsys
):
48 activation
= activate
.Activate([])
49 with pytest
.raises(RuntimeError):
50 activation
.validate_devices({'type': 'filestore', 'data': {}})
51 stdout
, stderr
= capsys
.readouterr()
52 assert "devices found: ['data']" in stdout
54 def test_filestore_with_all_devices(self
):
55 activation
= activate
.Activate([])
56 result
= activation
.validate_devices({'type': 'filestore', 'journal': {}, 'data': {}})
59 def test_bluestore_with_all_devices(self
):
60 activation
= activate
.Activate([])
61 result
= activation
.validate_devices({'type': 'bluestore', 'data': {}, 'block': {}})
64 def test_bluestore_is_default(self
):
65 activation
= activate
.Activate([])
66 result
= activation
.validate_devices({'data': {}, 'block': {}})
69 def test_bluestore_data_device_found(self
, capsys
):
70 activation
= activate
.Activate([])
71 with pytest
.raises(RuntimeError):
72 activation
.validate_devices({'data': {}})
73 stdout
, stderr
= capsys
.readouterr()
74 assert "devices found: ['data']" in stdout
76 def test_bluestore_missing_data(self
):
77 activation
= activate
.Activate([])
78 with pytest
.raises(RuntimeError) as error
:
79 activation
.validate_devices({'type': 'bluestore', 'block': {}})
80 assert 'Unable to activate bluestore OSD due to missing devices' in str(error
)
82 def test_bluestore_block_device_found(self
, capsys
):
83 activation
= activate
.Activate([])
84 with pytest
.raises(RuntimeError):
85 activation
.validate_devices({'block': {}})
86 stdout
, stderr
= capsys
.readouterr()
87 assert "devices found: ['block']" in stdout