]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-volume tests prove missing args.osd_id is fine
authorAlfredo Deza <adeza@redhat.com>
Thu, 7 Sep 2017 20:54:19 +0000 (16:54 -0400)
committerAlfredo Deza <adeza@redhat.com>
Mon, 11 Sep 2017 13:08:45 +0000 (09:08 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/devices/lvm/test_activate.py [new file with mode: 0644]

diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_activate.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_activate.py
new file mode 100644 (file)
index 0000000..40df775
--- /dev/null
@@ -0,0 +1,34 @@
+import pytest
+from ceph_volume.devices.lvm import activate, api
+
+
+class Args(object):
+
+    def __init__(self, **kw):
+        for k, v in kw.items():
+            setattr(self, k, v)
+
+
+class TestActivate(object):
+
+    # these tests are very functional, hence the heavy patching, it is hard to
+    # test the negative side effect with an actual functional run, so we must
+    # setup a perfect scenario for this test to check it can really work
+    # with/without osd_id
+    def test_no_osd_id_matches_fsid(self, is_root, volumes, monkeypatch, capture):
+        FooVolume = api.Volume(lv_name='foo', lv_path='/dev/vg/foo', lv_tags="ceph.osd_fsid=1234")
+        volumes.append(FooVolume)
+        monkeypatch.setattr(api, 'Volumes', lambda: volumes)
+        monkeypatch.setattr(activate, 'activate_filestore', capture)
+        args = Args(osd_id=None, osd_fsid='1234')
+        activate.Activate([]).activate(args)
+        assert capture.calls[0]['args'][0] == [FooVolume]
+
+    def test_no_osd_id_no_matching_fsid(self, is_root, volumes, monkeypatch, capture):
+        FooVolume = api.Volume(lv_name='foo', lv_path='/dev/vg/foo', lv_tags="ceph.osd_fsid=11234")
+        volumes.append(FooVolume)
+        monkeypatch.setattr(api, 'Volumes', lambda: volumes)
+        monkeypatch.setattr(activate, 'activate_filestore', capture)
+        args = Args(osd_id=None, osd_fsid='1234')
+        with pytest.raises(RuntimeError):
+            activate.Activate([]).activate(args)