]> git.proxmox.com Git - ceph.git/blame - ceph/src/ceph-volume/ceph_volume/tests/devices/lvm/test_activate.py
update sources to v12.2.1
[ceph.git] / ceph / src / ceph-volume / ceph_volume / tests / devices / lvm / test_activate.py
CommitLineData
181888fb
FG
1import pytest
2from ceph_volume.devices.lvm import activate, api
3
4
5class Args(object):
6
7 def __init__(self, **kw):
8 for k, v in kw.items():
9 setattr(self, k, v)
10
11
12class TestActivate(object):
13
14 # these tests are very functional, hence the heavy patching, it is hard to
15 # test the negative side effect with an actual functional run, so we must
16 # setup a perfect scenario for this test to check it can really work
17 # with/without osd_id
18 def test_no_osd_id_matches_fsid(self, is_root, volumes, monkeypatch, capture):
19 FooVolume = api.Volume(lv_name='foo', lv_path='/dev/vg/foo', lv_tags="ceph.osd_fsid=1234")
20 volumes.append(FooVolume)
21 monkeypatch.setattr(api, 'Volumes', lambda: volumes)
22 monkeypatch.setattr(activate, 'activate_filestore', capture)
23 args = Args(osd_id=None, osd_fsid='1234')
24 activate.Activate([]).activate(args)
25 assert capture.calls[0]['args'][0] == [FooVolume]
26
27 def test_no_osd_id_no_matching_fsid(self, is_root, volumes, monkeypatch, capture):
28 FooVolume = api.Volume(lv_name='foo', lv_path='/dev/vg/foo', lv_tags="ceph.osd_fsid=11234")
29 volumes.append(FooVolume)
30 monkeypatch.setattr(api, 'Volumes', lambda: volumes)
31 monkeypatch.setattr(activate, 'activate_filestore', capture)
32 args = Args(osd_id=None, osd_fsid='1234')
33 with pytest.raises(RuntimeError):
34 activate.Activate([]).activate(args)