]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/util/rgw.py
5 from six
import StringIO
7 from teuthology
import misc
as teuthology
9 log
= logging
.getLogger(__name__
)
11 def rgwadmin(ctx
, client
, cmd
, stdin
=StringIO(), check_status
=False,
12 format
='json', decode
=True, log_level
=logging
.DEBUG
):
13 log
.info('rgwadmin: {client} : {cmd}'.format(client
=client
,cmd
=cmd
))
14 testdir
= teuthology
.get_testdir(ctx
)
15 cluster_name
, daemon_type
, client_id
= teuthology
.split_role(client
)
16 client_with_id
= daemon_type
+ '.' + client_id
20 '{tdir}/archive/coverage'.format(tdir
=testdir
),
25 '--cluster', cluster_name
,
28 log
.log(log_level
, 'rgwadmin: cmd=%s' % pre
)
29 (remote
,) = ctx
.cluster
.only(client
).remotes
.keys()
32 check_status
=check_status
,
38 out
= proc
.stdout
.getvalue()
42 if not r
and out
!= '':
45 log
.log(log_level
, ' json result: %s' % j
)
48 log
.log(log_level
, ' raw result: %s' % j
)
51 def get_user_summary(out
, user
):
52 """Extract the summary for a given user"""
54 for summary
in out
['summary']:
55 if summary
.get('user') == user
:
56 user_summary
= summary
59 raise AssertionError('No summary info found for user: %s' % user
)
63 def get_user_successful_ops(out
, user
):
64 summary
= out
['summary']
67 return get_user_summary(out
, user
)['total']['successful_ops']
69 def wait_for_radosgw(url
, remote
):
70 """ poll the given url until it starts accepting connections
72 add_daemon() doesn't wait until radosgw finishes startup, so this is used
73 to avoid racing with later tasks that expect radosgw to be up and listening
75 # TODO: use '--retry-connrefused --retry 8' when teuthology is running on
76 # Centos 8 and other OS's with an updated version of curl
81 for seconds
in range(num_retries
):
89 exit_status
= proc
.exitstatus
92 time
.sleep(2**seconds
)
94 assert exit_status
== 0