From fd432fee81a9b2cd34bc6d9770b7310197786ef9 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 31 Oct 2016 19:47:40 +0100 Subject: [PATCH] test/pybind: Add tests for aio_execute Signed-off-by: Iain Buclaw --- src/test/pybind/test_rados.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/test/pybind/test_rados.py b/src/test/pybind/test_rados.py index cda8e200e98fa..6a70f12daaf64 100644 --- a/src/test/pybind/test_rados.py +++ b/src/test/pybind/test_rados.py @@ -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) -- 2.39.5