diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/test/librbd/rbdrw.py | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/librbd/rbdrw.py')
-rw-r--r-- | src/test/librbd/rbdrw.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/librbd/rbdrw.py b/src/test/librbd/rbdrw.py new file mode 100644 index 000000000..a4b36d3cb --- /dev/null +++ b/src/test/librbd/rbdrw.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +""" +Loop writing/reading the first 4k of image argv[1] in pool rbd, +after acquiring exclusive lock named argv[2]. When an exception +happens, split off the last number in the exception 'args' string +and use it as the process exit code, if it's convertible to a number. + +Designed to run against a blocklist operation and verify the +ESHUTDOWN expected from the image operation. + +Note: this cannot be run with writeback caching on, currently, as +writeback errors cause reads be marked dirty rather than error, and +even if they were marked as errored, ObjectCacher would retry them +rather than note them as errored. +""" + +import rados, rbd, sys + +with rados.Rados(conffile='') as r: + with r.open_ioctx('rbd') as ioctx: + try: + with rbd.Image(ioctx, sys.argv[1]) as image: + image.lock_exclusive(sys.argv[2]) + while True: + image.write(b'A' * 4096, 0) + r = image.read(0, 4096) + except rbd.ConnectionShutdown: + # it so happens that the errno here is 108, but + # anything recognizable would do + exit(108) |