]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests ensure activate all behavior
authorAlfredo Deza <adeza@redhat.com>
Thu, 29 Mar 2018 18:03:00 +0000 (14:03 -0400)
committerAlfredo Deza <adeza@redhat.com>
Thu, 29 Mar 2018 19:12:40 +0000 (15:12 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/devices/lvm/test_activate.py

index ce623aac98f26f58b2e2bb48657bf2d1ed393adc..a8304b2e368d9e8ed2fbc9b8e4b25f0cf511f605 100644 (file)
@@ -76,3 +76,93 @@ class TestActivateFlags(object):
         parsed_args = capture.calls[0]['args'][0]
         assert parsed_args.filestore is False
         assert parsed_args.bluestore is True
+
+
+class TestActivateAll(object):
+
+    def test_does_not_detect_osds(self, capsys, is_root, capture, monkeypatch):
+        monkeypatch.setattr('ceph_volume.devices.lvm.activate.direct_report', lambda: {})
+        args = ['--all']
+        activation = activate.Activate(args)
+        activation.main()
+        out, err = capsys.readouterr()
+        assert 'Was unable to find any OSDs to activate' in out
+        assert 'Verify OSDs are present with ' in out
+
+    def test_detects_running_osds(self, capsys, is_root, capture, monkeypatch):
+        monkeypatch.setattr('ceph_volume.devices.lvm.activate.direct_report', lambda: direct_report)
+        monkeypatch.setattr('ceph_volume.devices.lvm.activate.systemctl.osd_is_active', lambda x: True)
+        args = ['--all']
+        activation = activate.Activate(args)
+        activation.main()
+        out, err = capsys.readouterr()
+        assert 'a8789a96ce8b process is active. Skipping activation' in out
+        assert 'b8218eaa1634 process is active. Skipping activation' in out
+
+    def test_detects_osds_to_activate(self, is_root, capture, monkeypatch):
+        monkeypatch.setattr('ceph_volume.devices.lvm.activate.direct_report', lambda: direct_report)
+        monkeypatch.setattr('ceph_volume.devices.lvm.activate.systemctl.osd_is_active', lambda x: False)
+        args = ['--all']
+        activation = activate.Activate(args)
+        activation.activate = capture
+        activation.main()
+        calls = sorted(capture.calls, key=lambda x: x['kwargs']['osd_id'])
+        assert calls[0]['kwargs']['osd_id'] == '0'
+        assert calls[0]['kwargs']['osd_fsid'] == '957d22b7-24ce-466a-9883-b8218eaa1634'
+        assert calls[1]['kwargs']['osd_id'] == '1'
+        assert calls[1]['kwargs']['osd_fsid'] == 'd0f3e4ad-e52a-4520-afc0-a8789a96ce8b'
+
+#
+# Activate All fixture
+#
+
+direct_report = {
+    "0": [
+        {
+            "lv_name": "osd-block-957d22b7-24ce-466a-9883-b8218eaa1634",
+            "lv_path": "/dev/ceph-d4962338-46ff-4cd5-8ea6-c033dbdc5b44/osd-block-957d22b7-24ce-466a-9883-b8218eaa1634",
+            "lv_tags": "ceph.block_device=/dev/ceph-d4962338-46ff-4cd5-8ea6-c033dbdc5b44/osd-block-957d22b7-24ce-466a-9883-b8218eaa1634,ceph.block_uuid=6MixOd-2Q1I-f8K3-PPOq-UJGV-L3A0-0XwUm4,ceph.cephx_lockbox_secret=,ceph.cluster_fsid=d4962338-46ff-4cd5-8ea6-c033dbdc5b44,ceph.cluster_name=ceph,ceph.crush_device_class=None,ceph.encrypted=0,ceph.osd_fsid=957d22b7-24ce-466a-9883-b8218eaa1634,ceph.osd_id=0,ceph.type=block",
+            "lv_uuid": "6MixOd-2Q1I-f8K3-PPOq-UJGV-L3A0-0XwUm4",
+            "name": "osd-block-957d22b7-24ce-466a-9883-b8218eaa1634",
+            "path": "/dev/ceph-d4962338-46ff-4cd5-8ea6-c033dbdc5b44/osd-block-957d22b7-24ce-466a-9883-b8218eaa1634",
+            "tags": {
+                "ceph.block_device": "/dev/ceph-d4962338-46ff-4cd5-8ea6-c033dbdc5b44/osd-block-957d22b7-24ce-466a-9883-b8218eaa1634",
+                "ceph.block_uuid": "6MixOd-2Q1I-f8K3-PPOq-UJGV-L3A0-0XwUm4",
+                "ceph.cephx_lockbox_secret": "",
+                "ceph.cluster_fsid": "d4962338-46ff-4cd5-8ea6-c033dbdc5b44",
+                "ceph.cluster_name": "ceph",
+                "ceph.crush_device_class": "None",
+                "ceph.encrypted": "0",
+                "ceph.osd_fsid": "957d22b7-24ce-466a-9883-b8218eaa1634",
+                "ceph.osd_id": "0",
+                "ceph.type": "block"
+            },
+            "type": "block",
+            "vg_name": "ceph-d4962338-46ff-4cd5-8ea6-c033dbdc5b44"
+        }
+    ],
+    "1": [
+        {
+            "lv_name": "osd-block-d0f3e4ad-e52a-4520-afc0-a8789a96ce8b",
+            "lv_path": "/dev/ceph-7538bcf0-f155-4d3f-a9fd-d8b15905e532/osd-block-d0f3e4ad-e52a-4520-afc0-a8789a96ce8b",
+            "lv_tags": "ceph.block_device=/dev/ceph-7538bcf0-f155-4d3f-a9fd-d8b15905e532/osd-block-d0f3e4ad-e52a-4520-afc0-a8789a96ce8b,ceph.block_uuid=1igwLb-ZlmV-eLgp-hapx-c1Hr-M5gz-sHjnyW,ceph.cephx_lockbox_secret=,ceph.cluster_fsid=d4962338-46ff-4cd5-8ea6-c033dbdc5b44,ceph.cluster_name=ceph,ceph.crush_device_class=None,ceph.encrypted=0,ceph.osd_fsid=d0f3e4ad-e52a-4520-afc0-a8789a96ce8b,ceph.osd_id=1,ceph.type=block",
+            "lv_uuid": "1igwLb-ZlmV-eLgp-hapx-c1Hr-M5gz-sHjnyW",
+            "name": "osd-block-d0f3e4ad-e52a-4520-afc0-a8789a96ce8b",
+            "path": "/dev/ceph-7538bcf0-f155-4d3f-a9fd-d8b15905e532/osd-block-d0f3e4ad-e52a-4520-afc0-a8789a96ce8b",
+            "tags": {
+                "ceph.block_device": "/dev/ceph-7538bcf0-f155-4d3f-a9fd-d8b15905e532/osd-block-d0f3e4ad-e52a-4520-afc0-a8789a96ce8b",
+                "ceph.block_uuid": "1igwLb-ZlmV-eLgp-hapx-c1Hr-M5gz-sHjnyW",
+                "ceph.cephx_lockbox_secret": "",
+                "ceph.cluster_fsid": "d4962338-46ff-4cd5-8ea6-c033dbdc5b44",
+                "ceph.cluster_name": "ceph",
+                "ceph.crush_device_class": "None",
+                "ceph.encrypted": "0",
+                "ceph.osd_fsid": "d0f3e4ad-e52a-4520-afc0-a8789a96ce8b",
+                "ceph.osd_id": "1",
+                "ceph.type": "block"
+            },
+            "type": "block",
+            "vg_name": "ceph-7538bcf0-f155-4d3f-a9fd-d8b15905e532"
+        }
+    ]
+}