]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: add tests for reduce_vg()
authorMohamad Gebai <mgebai@suse.com>
Mon, 1 Apr 2019 23:27:41 +0000 (19:27 -0400)
committerJan Fajerski <jfajerski@suse.com>
Wed, 8 Jan 2020 09:33:37 +0000 (10:33 +0100)
Signed-off-by: Mohamad Gebai <mgebai@suse.com>
(cherry picked from commit 1f07776615b7bba5eacf34a8c9fa62c06a57eb4b)

src/ceph-volume/ceph_volume/tests/api/test_lvm.py

index fe4c6b30761f28e535972c38d3e06f85565fc2be..5a8af8279d9cc444ba144b6131f918e623394f23 100644 (file)
@@ -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):