Skip to content

Commit

Permalink
Adjust namespace_bucket_update to the new schema (#8235) (#8426)
Browse files Browse the repository at this point in the history
release-4.12 backport of #8235: Adjust namespace_bucket_update to the new schema 

Signed-off-by: Sagi Hirshfeld <[email protected]>
  • Loading branch information
sagihirshfeld authored Oct 20, 2023
1 parent 667ceee commit a9fd25c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
17 changes: 14 additions & 3 deletions ocs_ci/ocs/bucket_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,10 +1232,21 @@ def namespace_bucket_update(mcg_obj, bucket_name, read_resource, write_resource)
Args:
mcg_obj (obj): An MCG object containing the MCG S3 connection credentials
bucket_name (str): Name of the bucket
read_resource (list): Resource names to provide read access
write_resource (str): Resource name to provide write access
read_resource (list): Resource dicts or names to provide read access
write_resource (str or dict): Resource dict or name to provide write access
"""
read_resource = [
{"resource": resource}
for resource in read_resource
if isinstance(resource, str)
]
write_resource = (
{"resource": write_resource}
if isinstance(write_resource, str)
else write_resource
)

"""
mcg_obj.send_rpc_query(
"bucket_api",
"update_bucket",
Expand Down
24 changes: 20 additions & 4 deletions tests/e2e/lifecycle/mcg/test_mcg_namespace_lifecyle_crd.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def test_mcg_namespace_lifecycle_crd(
cld_mgr,
awscli_pod,
bucket_factory,
namespace_store_factory,
test_directory_setup,
bucketclass_dict,
):
Expand Down Expand Up @@ -257,13 +258,18 @@ def test_mcg_namespace_lifecycle_crd(
signed_request_creds=s3_creds,
)

alternative_namespacestore = namespace_store_factory(
bucketclass_dict["interface"],
bucketclass_dict["namespace_policy_dict"]["namespacestore_dict"],
)[0].name

# Edit namespace bucket
logger.info(f"Editing the namespace resource bucket: {ns_bucket.name}")
namespace_bucket_update(
mcg_obj,
bucket_name=ns_bucket.name,
read_resource=[aws_target_bucket],
write_resource=aws_target_bucket,
read_resource=[alternative_namespacestore],
write_resource=alternative_namespacestore,
)

# Verify Download after editing bucket
Expand All @@ -283,9 +289,19 @@ def test_mcg_namespace_lifecycle_crd(
)
rm_object_recursive(awscli_pod, ns_bucket.name, mcg_obj)

# Edit namespace bucket to use the previous namespace resource
original_namespacestore = ns_bucket.bucketclass.namespacestores[0].name
logger.info(f"Editing the namespace resource bucket: {ns_bucket.name}")
namespace_bucket_update(
mcg_obj,
bucket_name=ns_bucket.name,
read_resource=[original_namespacestore],
write_resource=original_namespacestore,
)

# Namespace resource delete
logger.info(f"Deleting the resource: {aws_target_bucket}")
mcg_obj.delete_ns_resource(ns_resource_name=aws_target_bucket)
logger.info(f"Deleting the resource: {alternative_namespacestore}")
mcg_obj.delete_ns_resource(ns_resource_name=alternative_namespacestore)

@pytest.mark.parametrize(
argnames=["bucketclass_dict"],
Expand Down

0 comments on commit a9fd25c

Please sign in to comment.