From: Casey Bodley Date: Fri, 4 Aug 2023 16:11:15 +0000 (-0400) Subject: qa/s3tests: create_users() takes all yaml config X-Git-Tag: v18.2.5~53^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=aa94f8ba90aff8153051930af31484a397180d36;p=ceph.git qa/s3tests: create_users() takes all yaml config Signed-off-by: Casey Bodley (cherry picked from commit ff590c5ae467d3fb3cff920a1c3a04cf060097ec) --- diff --git a/qa/tasks/s3tests.py b/qa/tasks/s3tests.py index 3856f8fadcd4..bfedf23dcebe 100644 --- a/qa/tasks/s3tests.py +++ b/qa/tasks/s3tests.py @@ -90,22 +90,21 @@ def _config_user(s3tests_conf, section, user): @contextlib.contextmanager -def create_users(ctx, config): +def create_users(ctx, config, s3tests_conf): """ Create a main and an alternate s3 user. """ - assert isinstance(config, dict) log.info('Creating rgw users...') testdir = teuthology.get_testdir(ctx) users = {'s3 main': 'foo', 's3 alt': 'bar', 's3 tenant': 'testx$tenanteduser', 'iam': 'foobar'} - for client in config['clients']: - s3tests_conf = config['s3tests_conf'][client] - s3tests_conf.setdefault('fixtures', {}) - s3tests_conf['fixtures'].setdefault('bucket prefix', 'test-' + client + '-{random}-') + for client, cconfig in config.items(): + conf = s3tests_conf[client] + conf.setdefault('fixtures', {}) + conf['fixtures'].setdefault('bucket prefix', 'test-' + client + '-{random}-') for section, user in users.items(): - _config_user(s3tests_conf, section, '{user}.{client}'.format(user=user, client=client)) - log.debug('Creating user {user} on {host}'.format(user=s3tests_conf[section]['user_id'], host=client)) + _config_user(conf, section, '{user}.{client}'.format(user=user, client=client)) + log.debug('Creating user {user} on {host}'.format(user=conf[section]['user_id'], host=client)) cluster_name, daemon_type, client_id = teuthology.split_role(client) client_with_id = daemon_type + '.' + client_id # create user @@ -117,12 +116,12 @@ def create_users(ctx, config): 'radosgw-admin', '-n', client_with_id, 'user', 'create', - '--uid', s3tests_conf[section]['user_id'], - '--display-name', s3tests_conf[section]['display_name'], - '--email', s3tests_conf[section]['email'], + '--uid', conf[section]['user_id'], + '--display-name', conf[section]['display_name'], + '--email', conf[section]['email'], '--caps', 'user-policy=*', - '--access-key', s3tests_conf[section]['access_key'], - '--secret', s3tests_conf[section]['secret_key'], + '--access-key', conf[section]['access_key'], + '--secret', conf[section]['secret_key'], '--cluster', cluster_name, ], ) @@ -136,10 +135,10 @@ def create_users(ctx, config): 'radosgw-admin', '-n', client_with_id, 'mfa', 'create', - '--uid', s3tests_conf[section]['user_id'], - '--totp-serial', s3tests_conf[section]['totp_serial'], - '--totp-seed', s3tests_conf[section]['totp_seed'], - '--totp-seconds', s3tests_conf[section]['totp_seconds'], + '--uid', conf[section]['user_id'], + '--totp-serial', conf[section]['totp_serial'], + '--totp-seed', conf[section]['totp_seed'], + '--totp-seconds', conf[section]['totp_seconds'], '--totp-window', '8', '--totp-seed-type', 'base32', '--cluster', cluster_name, @@ -156,7 +155,7 @@ def create_users(ctx, config): 'radosgw-admin', '-n', client_with_id, 'caps', 'add', - '--uid', s3tests_conf[section]['user_id'], + '--uid', conf[section]['user_id'], '--caps', 'roles=*', '--cluster', cluster_name, ], @@ -169,26 +168,26 @@ def create_users(ctx, config): 'radosgw-admin', '-n', client_with_id, 'caps', 'add', - '--uid', s3tests_conf[section]['user_id'], + '--uid', conf[section]['user_id'], '--caps', 'oidc-provider=*', '--cluster', cluster_name, ], ) if "TOKEN" in os.environ: - s3tests_conf.setdefault('webidentity', {}) - s3tests_conf['webidentity'].setdefault('token',os.environ['TOKEN']) - s3tests_conf['webidentity'].setdefault('aud',os.environ['AUD']) - s3tests_conf['webidentity'].setdefault('sub',os.environ['SUB']) - s3tests_conf['webidentity'].setdefault('azp',os.environ['AZP']) - s3tests_conf['webidentity'].setdefault('user_token',os.environ['USER_TOKEN']) - s3tests_conf['webidentity'].setdefault('thumbprint',os.environ['THUMBPRINT']) - s3tests_conf['webidentity'].setdefault('KC_REALM',os.environ['KC_REALM']) + conf.setdefault('webidentity', {}) + conf['webidentity'].setdefault('token',os.environ['TOKEN']) + conf['webidentity'].setdefault('aud',os.environ['AUD']) + conf['webidentity'].setdefault('sub',os.environ['SUB']) + conf['webidentity'].setdefault('azp',os.environ['AZP']) + conf['webidentity'].setdefault('user_token',os.environ['USER_TOKEN']) + conf['webidentity'].setdefault('thumbprint',os.environ['THUMBPRINT']) + conf['webidentity'].setdefault('KC_REALM',os.environ['KC_REALM']) try: yield finally: - for client in config['clients']: + for client in config.keys(): for user in users.values(): uid = '{user}.{client}'.format(user=user, client=client) cluster_name, daemon_type, client_id = teuthology.split_role(client) @@ -633,10 +632,7 @@ def task(ctx, config): with contextutil.nested( lambda: download(ctx=ctx, config=config), - lambda: create_users(ctx=ctx, config=dict( - clients=clients, - s3tests_conf=s3tests_conf, - )), + lambda: create_users(ctx=ctx, config=config, s3tests_conf=s3tests_conf), lambda: configure(ctx=ctx, config=dict( clients=config, s3tests_conf=s3tests_conf,