-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write file to rgw bucket from client #9680
Open
fbalak
wants to merge
9
commits into
red-hat-storage:master
Choose a base branch
from
fbalak:provider-client-rgw-write
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ccd5b51
Write file to rgw bucket from client
fbalak b55a038
fix unused imports
fbalak 5ecd946
add rgw interface to rgw_bucket_factory
fbalak 89a5446
get rgw credentials on provider
fbalak f71b28e
fix credentials
fbalak 018487a
get correct creds
fbalak d6d57f1
look for different fields in rgw bucket secret
fbalak ac853a7
fix attribute name
fbalak d98b1cd
add update_s3_creds function for rgw
fbalak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,76 @@ | ||||
import logging | ||||
import pytest | ||||
|
||||
from ocs_ci.framework import config | ||||
from ocs_ci.framework.pytest_customization.marks import ( | ||||
tier1, | ||||
red_squad, | ||||
rgw, | ||||
runs_on_provider, | ||||
provider_client_ms_platform_required, | ||||
) | ||||
from ocs_ci.ocs import constants | ||||
from ocs_ci.ocs.bucket_utils import sync_object_directory | ||||
|
||||
log = logging.getLogger(__name__) | ||||
|
||||
|
||||
@pytest.fixture | ||||
def return_to_original_context(): | ||||
""" | ||||
Make sure that original context is restored after the test. | ||||
""" | ||||
original_cluster = config.cluster_ctx.MULTICLUSTER["multicluster_index"] | ||||
return | ||||
log.info(f"Switching back to original cluster with index {original_cluster}") | ||||
config.switch_ctx(original_cluster) | ||||
|
||||
|
||||
@rgw | ||||
@red_squad | ||||
@tier1 | ||||
@runs_on_provider | ||||
@provider_client_ms_platform_required | ||||
@pytest.mark.polarion_id("OCS-5765") | ||||
def test_write_file_to_bucket_on_client( | ||||
rgw_bucket_factory, rgw_obj, awscli_pod_client_session, return_to_original_context | ||||
): | ||||
""" | ||||
Test object IO using the S3 SDK on rgw bucket created on provider and used on client. | ||||
""" | ||||
awscli_pod, client_cluster = awscli_pod_client_session | ||||
# Retrieve a list of all objects on the test-objects bucket and | ||||
# downloads them to the pod | ||||
bucketname = rgw_bucket_factory(1, "rgw-oc")[0].name | ||||
full_object_path = f"s3://{bucketname}" | ||||
credentials = rgw_obj.get_credentials( | ||||
secret_name=bucketname, | ||||
access_key_field="AWS_ACCESS_KEY_ID", | ||||
secret_key_field="AWS_SECRET_ACCESS_KEY", | ||||
) | ||||
rgw_obj.update_s3_creds(credentials[1], credentials[2]) | ||||
|
||||
config.switch_ctx(client_cluster) | ||||
log.info(f"Switched to client cluster with index {client_cluster}") | ||||
downloaded_files = awscli_pod.exec_cmd_on_pod( | ||||
f"ls -A1 {constants.AWSCLI_TEST_OBJ_DIR}" | ||||
).split(" ") | ||||
# create s3_creds structure with s3_endpoint so that s3_internal_endpoint is not used | ||||
# TODO(fbalak): remove ssl=False option and provide correct certificate | ||||
s3_creds = { | ||||
"access_key_id": credentials[1], | ||||
"access_key": credentials[2], | ||||
"endpoint": credentials[0], | ||||
"ssl": False, | ||||
} | ||||
# Write all downloaded objects to the new bucket | ||||
sync_object_directory( | ||||
awscli_pod, | ||||
constants.AWSCLI_TEST_OBJ_DIR, | ||||
full_object_path, | ||||
signed_request_creds=s3_creds, | ||||
) | ||||
|
||||
assert set(downloaded_files).issubset( | ||||
obj.key for obj in rgw_obj.s3_list_all_objects_in_bucket(bucketname) | ||||
) | ||||
Comment on lines
+74
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fbalak We can use Please refer below link: ocs-ci/ocs_ci/ocs/bucket_utils.py Line 137 in 9a688b5
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixture looks useful and generic, are you sure you want to use it only for rgw tests?