From fafa183d8f13fa769eaab5f865f6592b89225901 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Thu, 18 Jan 2018 12:04:38 -0600 Subject: [PATCH] ceph-volume: tests for lvm zap --destroy Signed-off-by: Andrew Schoen --- .../ceph_volume/tests/api/test_lvm.py | 19 ++++++++++++++----- .../ceph_volume/tests/devices/test_zap.py | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/ceph-volume/ceph_volume/tests/api/test_lvm.py b/src/ceph-volume/ceph_volume/tests/api/test_lvm.py index 1a2dff9598945..a56582b3574e9 100644 --- a/src/ceph-volume/ceph_volume/tests/api/test_lvm.py +++ b/src/ceph-volume/ceph_volume/tests/api/test_lvm.py @@ -131,13 +131,13 @@ class TestGetPV(object): assert api.get_pv() is None def test_single_pv_is_not_matched(self, pvolumes, monkeypatch): - FooPVolume = api.PVolume(pv_name='/dev/sda', pv_uuid="0000", pv_tags={}) + FooPVolume = api.PVolume(pv_name='/dev/sda', pv_uuid="0000", pv_tags={}, vg_name="vg") pvolumes.append(FooPVolume) monkeypatch.setattr(api, 'PVolumes', lambda: pvolumes) assert api.get_pv(pv_uuid='foo') is None def test_single_pv_is_matched(self, pvolumes, monkeypatch): - FooPVolume = api.PVolume(pv_name='/dev/sda', pv_uuid="0000", pv_tags={}) + FooPVolume = api.PVolume(vg_name="vg", pv_name='/dev/sda', pv_uuid="0000", pv_tags={}) pvolumes.append(FooPVolume) monkeypatch.setattr(api, 'PVolumes', lambda: pvolumes) assert api.get_pv(pv_uuid='0000') == FooPVolume @@ -145,11 +145,20 @@ class TestGetPV(object): def test_single_pv_is_matched_by_uuid(self, pvolumes, monkeypatch): FooPVolume = api.PVolume( pv_name='/dev/vg/foo', - pv_uuid='1111', pv_tags="ceph.type=data") + pv_uuid='1111', pv_tags="ceph.type=data", vg_name="vg") pvolumes.append(FooPVolume) monkeypatch.setattr(api, 'PVolumes', lambda: pvolumes) assert api.get_pv(pv_uuid='1111') == FooPVolume + def test_vg_name_is_set(self, pvolumes, monkeypatch): + FooPVolume = api.PVolume( + pv_name='/dev/vg/foo', + pv_uuid='1111', pv_tags="ceph.type=data", vg_name="vg") + pvolumes.append(FooPVolume) + monkeypatch.setattr(api, 'PVolumes', lambda: pvolumes) + pv = api.get_pv(pv_name="/dev/vg/foo") + assert pv.vg_name == "vg" + class TestPVolumes(object): @@ -157,7 +166,7 @@ class TestPVolumes(object): pv_tags = "ceph.type=journal,ceph.osd_id=1,ceph.fsid=000-aaa" FooPVolume = api.PVolume( pv_name='/dev/vg/foo', - pv_uuid='1111', pv_tags=pv_tags) + pv_uuid='1111', pv_tags=pv_tags, vg_name='vg') pvolumes.append(FooPVolume) pvolumes.filter(pv_tags={'ceph.type': 'journal', 'ceph.osd_id': '2'}) assert pvolumes == [] @@ -166,7 +175,7 @@ class TestPVolumes(object): pv_tags = "ceph.type=journal,ceph.osd_id=1" FooPVolume = api.PVolume( pv_name='/dev/vg/foo', - pv_uuid='1111', pv_tags=pv_tags) + pv_uuid='1111', pv_tags=pv_tags, vg_name="vg") pvolumes.append(FooPVolume) pvolumes.filter(pv_tags={'ceph.type': 'journal', 'ceph.osd_id': '1'}) assert pvolumes == [FooPVolume] diff --git a/src/ceph-volume/ceph_volume/tests/devices/test_zap.py b/src/ceph-volume/ceph_volume/tests/devices/test_zap.py index bc26e33da5c33..5e267fca77e59 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/test_zap.py +++ b/src/ceph-volume/ceph_volume/tests/devices/test_zap.py @@ -7,7 +7,7 @@ class TestZap(object): def test_main_spits_help_with_no_arguments(self, capsys): lvm.zap.Zap([]).main() stdout, stderr = capsys.readouterr() - assert 'Zaps the given logical volume or partition' in stdout + assert 'Zaps the given logical volume, raw device or partition' in stdout def test_main_shows_full_help(self, capsys): with pytest.raises(SystemExit): -- 2.39.5