]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/rados/test_large_omap_detection.py
3 # vim: ts=4 sw=4 smarttab expandtab
5 # Copyright (C) 2017 Red Hat <contact@redhat.com>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Library Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Library Public License for more details.
25 cluster
.delete_pool('large-omap-test-pool')
30 #cluster = rados.Rados(conffile='./ceph.conf')
31 cluster
= rados
.Rados(conffile
='/etc/ceph/ceph.conf')
33 print("\nCluster ID: " + cluster
.get_fsid())
34 cluster
.create_pool('large-omap-test-pool')
35 ioctx
= cluster
.open_ioctx('large-omap-test-pool')
36 ioctx
.write_full('large-omap-test-object1', "Lorem ipsum")
37 op
= ioctx
.create_write_op()
41 for x
in range(20001):
45 ioctx
.set_omap(op
, tuple(keys
), tuple(values
))
46 ioctx
.operate_write_op(op
, 'large-omap-test-object1', 0)
47 ioctx
.release_write_op(op
)
49 ioctx
.write_full('large-omap-test-object2', "Lorem ipsum dolor")
50 op
= ioctx
.create_write_op()
52 buffer = ("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
53 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut "
54 "enim ad minim veniam, quis nostrud exercitation ullamco laboris "
55 "nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in "
56 "reprehenderit in voluptate velit esse cillum dolore eu fugiat "
57 "nulla pariatur. Excepteur sint occaecat cupidatat non proident, "
58 "sunt in culpa qui officia deserunt mollit anim id est laborum.")
62 for x
in xrange(20000):
66 ioctx
.set_omap(op
, tuple(keys
), tuple(values
))
67 ioctx
.operate_write_op(op
, 'large-omap-test-object2', 0)
68 ioctx
.release_write_op(op
)
72 def get_deep_scrub_timestamp(pgid
):
73 cmd
= ['ceph', 'pg', 'dump', '--format=json-pretty']
74 proc
= subprocess
.Popen(cmd
, stdout
=subprocess
.PIPE
)
75 out
= proc
.communicate()[0]
76 for stat
in json
.loads(out
)['pg_stats']:
77 if stat
['pgid'] == pgid
:
78 return stat
['last_deep_scrub_stamp']
83 cmd
= ['ceph', 'osd', 'map', 'large-omap-test-pool',
84 'large-omap-test-object1', '--format=json-pretty']
85 proc
= subprocess
.Popen(cmd
, stdout
=subprocess
.PIPE
)
86 out
= proc
.communicate()[0]
87 osds
.add(json
.loads(out
)['acting_primary'])
88 pgs
[json
.loads(out
)['pgid']] = get_deep_scrub_timestamp(json
.loads(out
)['pgid'])
89 cmd
= ['ceph', 'osd', 'map', 'large-omap-test-pool',
90 'large-omap-test-object2', '--format=json-pretty']
91 proc
= subprocess
.Popen(cmd
, stdout
=subprocess
.PIPE
)
92 out
= proc
.communicate()[0]
93 osds
.add(json
.loads(out
)['acting_primary'])
94 pgs
[json
.loads(out
)['pgid']] = get_deep_scrub_timestamp(json
.loads(out
)['pgid'])
97 command
= "ceph pg deep-scrub " + str(pg
)
98 subprocess
.check_call(shlex
.split(command
))
102 while RETRIES
< 60 and pgs
[pg
] == get_deep_scrub_timestamp(pg
):
106 def check_health_output():
109 while RETRIES
< 6 and result
!= 2:
112 output
= subprocess
.check_output(["ceph", "health", "detail"])
113 for line
in output
.splitlines():
114 result
+= int(line
.find('2 large omap objects') != -1)
118 print("Error, got invalid output:")
125 check_health_output()
129 if __name__
== '__main__':