]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/librbd/rbdrw.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / test / librbd / rbdrw.py
CommitLineData
9f95a23c 1#!/usr/bin/env python3
7c673cae
FG
2"""
3Loop writing/reading the first 4k of image argv[1] in pool rbd,
4after acquiring exclusive lock named argv[2]. When an exception
5happens, split off the last number in the exception 'args' string
6and use it as the process exit code, if it's convertible to a number.
7
f67539c2 8Designed to run against a blocklist operation and verify the
7c673cae
FG
9ESHUTDOWN expected from the image operation.
10
11Note: this cannot be run with writeback caching on, currently, as
12writeback errors cause reads be marked dirty rather than error, and
13even if they were marked as errored, ObjectCacher would retry them
14rather than note them as errored.
15"""
16
17import rados, rbd, sys
18
19with rados.Rados(conffile='') as r:
20 with r.open_ioctx('rbd') as ioctx:
21 try:
22 with rbd.Image(ioctx, sys.argv[1]) as image:
23 image.lock_exclusive(sys.argv[2])
24 while True:
25 image.write(b'A' * 4096, 0)
26 r = image.read(0, 4096)
27 except rbd.ConnectionShutdown:
28 # it so happens that the errno here is 108, but
29 # anything recognizable would do
30 exit(108)