]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Add a couple unit tests for teuthology.parallel
authorZack Cerza <zack@cerza.org>
Wed, 2 Jul 2014 16:08:11 +0000 (10:08 -0600)
committerZack Cerza <zack@cerza.org>
Wed, 2 Jul 2014 16:08:11 +0000 (10:08 -0600)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/test/test_parallel.py [new file with mode: 0644]

diff --git a/teuthology/test/test_parallel.py b/teuthology/test/test_parallel.py
new file mode 100644 (file)
index 0000000..526b0a7
--- /dev/null
@@ -0,0 +1,28 @@
+from ..parallel import parallel
+
+
+def identity(item, input_set=None, remove=False):
+    if input_set is not None:
+        assert item in input_set
+        if remove:
+            input_set.remove(item)
+    return item
+
+
+class TestParallel(object):
+    def test_basic(self):
+        in_set = set(range(10))
+        with parallel() as para:
+            for i in in_set:
+                para.spawn(identity, i, in_set, remove=True)
+                assert para.any_spawned is True
+            assert para.count == len(in_set)
+
+    def test_result(self):
+        in_set = set(range(10))
+        with parallel() as para:
+            for i in in_set:
+                para.spawn(identity, i, in_set)
+            for result in para:
+                in_set.remove(result)
+