]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-daemon: Add basic unittest infrastructure and cmake integration 31467/head
authorThomas Bechtold <tbechtold@suse.com>
Thu, 7 Nov 2019 16:47:02 +0000 (17:47 +0100)
committerThomas Bechtold <tbechtold@suse.com>
Fri, 8 Nov 2019 16:05:57 +0000 (17:05 +0100)
To be able to write unittests, add a tox.ini (for testing in venvs)
and a first single test case as example.
Tests can be executed with eg:

$ tox

Or by running the usual:

$ ./run-make-check.sh

Signed-off-by: Thomas Bechtold <tbechtold@suse.com>
src/CMakeLists.txt
src/ceph-daemon/CMakeLists.txt [new file with mode: 0644]
src/ceph-daemon/tests/__init__.py [new file with mode: 0644]
src/ceph-daemon/tests/test_ceph_daemon.py [new file with mode: 0644]
src/ceph-daemon/tox.ini [new file with mode: 0644]

index 2f902ec365070c4f021290c644e268e0147612f9..8109e3af0f3292a24563147dd770e8edc8ba6f56 100644 (file)
@@ -491,6 +491,7 @@ endif()
 add_subdirectory(pybind)
 add_subdirectory(ceph-volume)
 add_subdirectory(python-common)
+add_subdirectory(ceph-daemon)
 
 # Monitor
 add_subdirectory(mon)
diff --git a/src/ceph-daemon/CMakeLists.txt b/src/ceph-daemon/CMakeLists.txt
new file mode 100644 (file)
index 0000000..40e74ba
--- /dev/null
@@ -0,0 +1,4 @@
+if(WITH_TESTS)
+  include(AddCephTest)
+  add_tox_test(ceph-daemon TOX_ENVS)
+endif()
diff --git a/src/ceph-daemon/tests/__init__.py b/src/ceph-daemon/tests/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/ceph-daemon/tests/test_ceph_daemon.py b/src/ceph-daemon/tests/test_ceph_daemon.py
new file mode 100644 (file)
index 0000000..65f98e4
--- /dev/null
@@ -0,0 +1,10 @@
+import imp
+import unittest
+
+
+cd = imp.load_source("ceph-daemon", "ceph-daemon")
+
+
+class TestCephDaemon(unittest.TestCase):
+    def test_is_fsid(self):
+        self.assertFalse(cd.is_fsid('no-uuid'))
diff --git a/src/ceph-daemon/tox.ini b/src/ceph-daemon/tox.ini
new file mode 100644 (file)
index 0000000..931aee1
--- /dev/null
@@ -0,0 +1,8 @@
+[tox]
+envlist = py27, py3
+
+[testenv]
+skipsdist=true
+skip_install=true
+deps = pytest
+commands=pytest {posargs}