]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: tests add an lvm trigger for the systemd argument parsing
authorAlfredo Deza <adeza@redhat.com>
Wed, 2 Aug 2017 17:06:04 +0000 (13:06 -0400)
committerAlfredo Deza <adeza@redhat.com>
Fri, 4 Aug 2017 14:25:58 +0000 (10:25 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/devices/lvm/test_trigger.py [new file with mode: 0644]

diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_trigger.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_trigger.py
new file mode 100644 (file)
index 0000000..f1dff2d
--- /dev/null
@@ -0,0 +1,39 @@
+import pytest
+from ceph_volume import exceptions
+from ceph_volume.devices.lvm import trigger
+
+
+class TestParseOSDid(object):
+
+    def test_no_id_found_if_no_digit(self):
+        with pytest.raises(exceptions.SuffixParsingError):
+            trigger.parse_osd_id('asdlj-ljahsdfaslkjhdfa')
+
+    def test_no_id_found(self):
+        with pytest.raises(exceptions.SuffixParsingError):
+            trigger.parse_osd_id('ljahsdfaslkjhdfa')
+
+    def test_id_found(self):
+        result = trigger.parse_osd_id('1-ljahsdfaslkjhdfa')
+        assert result == '1'
+
+
+class TestParseOSDUUID(object):
+
+    def test_uuid_is_parsed(self):
+        result = trigger.parse_osd_uuid('1-asdf-ljkh-asdf-ljkh-asdf')
+        assert result == 'asdf-ljkh-asdf-ljkh-asdf'
+
+    def test_uuid_is_parsed_longer_sha1(self):
+        result = trigger.parse_osd_uuid('1-foo-bar-asdf-ljkh-asdf-ljkh-asdf')
+        assert result == 'foo-bar-asdf-ljkh-asdf-ljkh-asdf'
+
+    def test_uuid_is_not_found(self):
+        with pytest.raises(exceptions.SuffixParsingError):
+            trigger.parse_osd_uuid('ljahsdfaslkjhdfa')
+
+    def test_uuid_is_not_found_missing_id(self):
+        with pytest.raises(exceptions.SuffixParsingError):
+            trigger.parse_osd_uuid('ljahs-dfa-slkjhdfa-foo')
+
+