]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/pybind: Add tests for aio_execute
authorIain Buclaw <iain.buclaw@sociomantic.com>
Mon, 31 Oct 2016 18:47:40 +0000 (19:47 +0100)
committerJosh Durgin <jdurgin@redhat.com>
Fri, 2 Dec 2016 00:32:26 +0000 (16:32 -0800)
Signed-off-by: Iain Buclaw <iain.buclaw@sociomantic.com>
src/test/pybind/test_rados.py

index cda8e200e98fa557179b6c07a72882909af4c57f..6a70f12daaf64d02a89a02d79be5bcf60bc1f549 100644 (file)
@@ -825,6 +825,37 @@ class TestIoctx(object):
         ret, buf = self.ioctx.execute("foo", "hello", "say_hello", b"nose")
         eq(buf, b"Hello, nose!")
 
+    def test_aio_execute(self):
+        count = [0]
+        retval = [None]
+        lock = threading.Condition()
+        def cb(_, buf):
+            with lock:
+                if retval[0] is None:
+                    retval[0] = buf
+                count[0] += 1
+                lock.notify()
+        self.ioctx.write("foo", b"") # ensure object exists
+
+        comp = self.ioctx.aio_execute("foo", "hello", "say_hello", b"", 32, cb, cb)
+        comp.wait_for_complete()
+        with lock:
+            while count[0] < 2:
+                lock.wait()
+        eq(comp.get_return_value(), 13)
+        eq(retval[0], b"Hello, world!")
+
+        retval[0] = None
+        comp = self.ioctx.aio_execute("foo", "hello", "say_hello", b"nose", 32, cb, cb)
+        comp.wait_for_complete()
+        with lock:
+            while count[0] < 4:
+                lock.wait()
+        eq(comp.get_return_value(), 12)
+        eq(retval[0], b"Hello, nose!")
+
+        [i.remove() for i in self.ioctx.list_objects()]
+
 class TestObject(object):
 
     def setUp(self):
@@ -935,4 +966,4 @@ class TestCommand(object):
         ret, buf, out = self.rados.mon_command(json.dumps(cmd), b'')
         eq(ret, 0)
         assert len(out) > 0
-        eq(u"pool '\u9ec5' created", out)
\ No newline at end of file
+        eq(u"pool '\u9ec5' created", out)