From 3b795cc2c33c7ce5724ec2b2acb3ee3d114979cb Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 26 Jul 2018 09:59:10 -0400 Subject: [PATCH] qa/rgw: radosgw_admin_rest task tolerates empty responses result.json() throws a 'JSONDecodeError: Expecting value: line 1 column 1' for requests that return no body, such as 'user rm' 'key rm' 'subuser rm', 'bucket unlink', etc Signed-off-by: Casey Bodley --- qa/tasks/radosgw_admin_rest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qa/tasks/radosgw_admin_rest.py b/qa/tasks/radosgw_admin_rest.py index 401e0002254ba..c54e1bf394b16 100644 --- a/qa/tasks/radosgw_admin_rest.py +++ b/qa/tasks/radosgw_admin_rest.py @@ -104,8 +104,12 @@ def rgwadmin_rest(connection, cmd, params=None, headers=None, raw=False): result = handler(url, params=params, headers=request.headers) if raw: - log.info(' text result: %s' % result.txt) - return result.status_code, result.txt + log.info(' text result: %s' % result.text) + return result.status_code, result.text + elif len(result.content) == 0: + # many admin requests return no body, so json() throws a JSONDecodeError + log.info(' empty result') + return result.status_code, None else: log.info(' json result: %s' % result.json()) return result.status_code, result.json() -- 2.39.5