]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: update tests after removing the LVPath arg validator 25104/head
authorAndrew Schoen <aschoen@redhat.com>
Wed, 14 Nov 2018 16:35:32 +0000 (10:35 -0600)
committerAlfredo Deza <adeza@redhat.com>
Wed, 14 Nov 2018 20:07:08 +0000 (15:07 -0500)
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
Resolves: rm#27062
(cherry picked from commit 0cb95ace88a731f7c30adf3f2286691fa3b2c49c)

src/ceph-volume/ceph_volume/tests/devices/lvm/test_create.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py
src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py
src/ceph-volume/ceph_volume/tests/util/test_device.py

index a08564c2694f06239d3e5494fbfdf0b96c602420..62790c9eb76302ce49ea5da45ce170465c59793c 100644 (file)
@@ -17,14 +17,16 @@ class TestCreate(object):
         assert 'Use the bluestore objectstore' in stdout
         assert 'A physical device or logical' in stdout
 
-    def test_excludes_filestore_bluestore_flags(self, capsys):
+    def test_excludes_filestore_bluestore_flags(self, capsys, device_info):
+        device_info()
         with pytest.raises(SystemExit):
             lvm.create.Create(argv=['--data', '/dev/sdfoo', '--filestore', '--bluestore']).main()
         stdout, sterr = capsys.readouterr()
         expected = 'Cannot use --filestore (filestore) with --bluestore (bluestore)'
         assert expected in stdout
 
-    def test_excludes_other_filestore_bluestore_flags(self, capsys):
+    def test_excludes_other_filestore_bluestore_flags(self, capsys, device_info):
+        device_info()
         with pytest.raises(SystemExit):
             lvm.create.Create(argv=[
                 '--bluestore', '--data', '/dev/sdfoo',
@@ -34,7 +36,8 @@ class TestCreate(object):
         expected = 'Cannot use --bluestore (bluestore) with --journal (filestore)'
         assert expected in stdout
 
-    def test_excludes_block_and_journal_flags(self, capsys):
+    def test_excludes_block_and_journal_flags(self, capsys, device_info):
+        device_info()
         with pytest.raises(SystemExit):
             lvm.create.Create(argv=[
                 '--bluestore', '--data', '/dev/sdfoo', '--block.db', 'vg/ceph1',
index ab0115e959baf7663e9cc5abdfc1b7ea6d983579..a6516c4455d958c12693b9b96cb1db2792876ea0 100644 (file)
@@ -47,14 +47,16 @@ class TestPrepare(object):
         assert 'Use the bluestore objectstore' in stdout
         assert 'A physical device or logical' in stdout
 
-    def test_excludes_filestore_bluestore_flags(self, capsys):
+    def test_excludes_filestore_bluestore_flags(self, capsys, device_info):
+        device_info()
         with pytest.raises(SystemExit):
             lvm.prepare.Prepare(argv=['--data', '/dev/sdfoo', '--filestore', '--bluestore']).main()
         stdout, stderr = capsys.readouterr()
         expected = 'Cannot use --filestore (filestore) with --bluestore (bluestore)'
         assert expected in stdout
 
-    def test_excludes_other_filestore_bluestore_flags(self, capsys):
+    def test_excludes_other_filestore_bluestore_flags(self, capsys, device_info):
+        device_info()
         with pytest.raises(SystemExit):
             lvm.prepare.Prepare(argv=[
                 '--bluestore', '--data', '/dev/sdfoo',
@@ -64,7 +66,8 @@ class TestPrepare(object):
         expected = 'Cannot use --bluestore (bluestore) with --journal (filestore)'
         assert expected in stdout
 
-    def test_excludes_block_and_journal_flags(self, capsys):
+    def test_excludes_block_and_journal_flags(self, capsys, device_info):
+        device_info()
         with pytest.raises(SystemExit):
             lvm.prepare.Prepare(argv=[
                 '--bluestore', '--data', '/dev/sdfoo', '--block.db', 'vg/ceph1',
@@ -74,8 +77,9 @@ class TestPrepare(object):
         expected = 'Cannot use --block.db (bluestore) with --journal (filestore)'
         assert expected in stdout
 
-    def test_journal_is_required_with_filestore(self, is_root, monkeypatch):
-        monkeypatch.setattr('os.path.exists', lambda x: True)
+    def test_journal_is_required_with_filestore(self, is_root, monkeypatch, device_info):
+        monkeypatch.setattr("os.path.exists", lambda path: True)
+        device_info()
         with pytest.raises(SystemExit) as error:
             lvm.prepare.Prepare(argv=['--filestore', '--data', '/dev/sdfoo']).main()
         expected = '--journal is required when using --filestore'
index 9f20edbf724c077808c3f9862cdf57f11cfcc16f..2167aeac1469b53ff6e963402229b9f6c3357f70 100644 (file)
@@ -4,31 +4,6 @@ from ceph_volume import exceptions
 from ceph_volume.util import arg_validators
 
 
-invalid_lv_paths = [
-    '', 'lv_name', '/lv_name', 'lv_name/',
-    '/dev/lv_group/lv_name'
-]
-
-
-class TestLVPath(object):
-
-    def setup(self):
-        self.validator = arg_validators.LVPath()
-
-    @pytest.mark.parametrize('path', invalid_lv_paths)
-    def test_no_slash_is_an_error(self, path):
-        with pytest.raises(argparse.ArgumentError):
-            self.validator(path)
-
-    def test_is_valid(self):
-        path = 'vg/lv'
-        assert self.validator(path) == path
-
-    def test_abspath_is_valid(self):
-        path = '/'
-        assert self.validator(path) == path
-
-
 class TestOSDPath(object):
 
     def setup(self):
index 74e817c6a5dfc741053642b1d9fadbdcd6e39dcc..e941370244d0f4ff302c896c43f33dbef734e20e 100644 (file)
@@ -13,7 +13,7 @@ class TestDevice(object):
         assert "foo" in disk.sys_api
 
     def test_is_lv(self, device_info):
-        data = {"lv_path": "vg/lv", "vg_name": "vg"}
+        data = {"lv_path": "vg/lv", "vg_name": "vg", "name": "lv"}
         device_info(lv=data)
         disk = device.Device("vg/lv")
         assert disk.is_lv