From ab42b8dd5bbeaaf3d177d43ca8fd5ed1deac8cd5 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 19 Jun 2012 14:30:00 -0700 Subject: [PATCH] add usage log tests to radosgw-admin tasks tests 'usage show' and 'usage trim' Signed-off-by: Yehuda Sadeh --- teuthology/task/radosgw-admin.py | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/teuthology/task/radosgw-admin.py b/teuthology/task/radosgw-admin.py index 3580a66acb..7ae12753be 100644 --- a/teuthology/task/radosgw-admin.py +++ b/teuthology/task/radosgw-admin.py @@ -12,6 +12,8 @@ import boto.exception import boto.s3.connection import boto.s3.acl +import time + from teuthology import misc as teuthology log = logging.getLogger(__name__) @@ -309,6 +311,41 @@ def task(ctx, config): # TODO: show log by bucket+date + # need to wait for all usage data to get flushed, should take up to 30 seconds + timestamp = time.time() + while time.time() - timestamp <= 45: + (err, out) = rgwadmin(ctx, client, ['usage', 'show']) + if len(out['entries']) > 0: + break; + time.sleep(1) + + assert time.time() - timestamp <= 45 + + # TESTCASE 'usage-show' 'usage' 'show' 'all usage' 'succeeds' + (err, out) = rgwadmin(ctx, client, ['usage', 'show']) + assert not err + assert len(out['entries']) > 0 + assert len(out['summary']) > 0 + for entry in out['summary']: + assert entry['successful_ops'] > 0 + + # TESTCASE 'usage-show2' 'usage' 'show' 'user usage' 'succeeds' + (err, out) = rgwadmin(ctx, client, ['usage', 'show', '--uid', user]) + assert not err + assert len(out['entries']) > 0 + assert len(out['summary']) > 0 + for entry in out['summary']: + assert entry['successful_ops'] > 0 + assert entry['user'] == user + + # TESTCASE 'usage-trim' 'usage' 'trim' 'user usage' 'succeeds, usage removed' + (err, out) = rgwadmin(ctx, client, ['usage', 'trim', '--uid', user]) + assert not err + (err, out) = rgwadmin(ctx, client, ['usage', 'show', '--uid', user]) + assert not err + assert len(out['entries']) == 0 + assert len(out['summary']) == 0 + # TESTCASE 'user-suspend2','user','suspend','existing user','succeeds' (err, out) = rgwadmin(ctx, client, ['user', 'suspend', '--uid', user]) assert not err -- 2.39.5