From f78ad4e52d1b07141e5d078f435ce7b23b34b443 Mon Sep 17 00:00:00 2001 From: Mohamad Gebai Date: Mon, 1 Apr 2019 19:27:41 -0400 Subject: [PATCH] ceph-volume: add tests for reduce_vg() Signed-off-by: Mohamad Gebai (cherry picked from commit 1f07776615b7bba5eacf34a8c9fa62c06a57eb4b) --- .../ceph_volume/tests/api/test_lvm.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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 fe4c6b30761f2..5a8af8279d9cc 100644 --- a/src/ceph-volume/ceph_volume/tests/api/test_lvm.py +++ b/src/ceph-volume/ceph_volume/tests/api/test_lvm.py @@ -618,6 +618,30 @@ class TestExtendVG(object): assert fake_run.calls[0]['args'][0] == expected +class TestReduceVG(object): + + def setup(self): + self.foo_volume = api.VolumeGroup(vg_name='foo', lv_tags='') + + def test_uses_single_device_in_list(self, monkeypatch, fake_run): + monkeypatch.setattr(api, 'get_vg', lambda **kw: True) + api.reduce_vg(self.foo_volume, ['/dev/sda']) + expected = ['vgreduce', '--force', '--yes', 'foo', '/dev/sda'] + assert fake_run.calls[0]['args'][0] == expected + + def test_uses_single_device(self, monkeypatch, fake_run): + monkeypatch.setattr(api, 'get_vg', lambda **kw: True) + api.reduce_vg(self.foo_volume, '/dev/sda') + expected = ['vgreduce', '--force', '--yes', 'foo', '/dev/sda'] + assert fake_run.calls[0]['args'][0] == expected + + def test_uses_multiple_devices(self, monkeypatch, fake_run): + monkeypatch.setattr(api, 'get_vg', lambda **kw: True) + api.reduce_vg(self.foo_volume, ['/dev/sda', '/dev/sdb']) + expected = ['vgreduce', '--force', '--yes', 'foo', '/dev/sda', '/dev/sdb'] + assert fake_run.calls[0]['args'][0] == expected + + class TestCreateVG(object): def setup(self): -- 2.39.5