-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new markers for bucket_versioning and bucket_versioning_cli * Create tests for versioning * add some docs to versioning tests * update mgc_path to accept params.example.yaml without mgc_path * create versioning cli tests * update pull-resquest-test.yml to run versioning tests * fix category name of versioning tests * change if cmd[0] == "mgc" to if cmd[0] != "mgc" * change assertions to use parametrize and add cli class * add cli class to locking_cli_test * Add cli mark * Melhorando algumas coisas de docs * update mgc * update mgc_path to looking mgc path if mgc_path isn't in params.yaml * fix mgc_attribute e melhorando a doc
- Loading branch information
1 parent
8aeb6cf
commit 8bae286
Showing
10 changed files
with
269 additions
and
19 deletions.
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
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
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
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,68 @@ | ||
# + {"jupyter": {"source_hidden": true}} | ||
import logging | ||
import pytest | ||
from s3_helpers import run_example | ||
from botocore.exceptions import ClientError | ||
from shlex import split, quote | ||
import subprocess | ||
|
||
config = "../params/br-se1.yaml" | ||
|
||
|
||
# + {"jupyter": {"source_hidden": true}} | ||
pytestmark = [pytest.mark.bucket_versioning, pytest.mark.cli] | ||
|
||
|
||
commands = [ | ||
("mgc object-storage objects delete {bucket_name}/{object_key} --no-confirm", ""), | ||
("aws --profile {profile_name} s3 rm s3://{bucket_name}/{object_key}", "delete: s3://{bucket_name}/{object_key}\n"), | ||
("rclone delete {profile_name}:{bucket_name}/{object_key}", "") | ||
] | ||
|
||
@pytest.mark.parametrize("cmd_template, expected", commands) | ||
def test_delete_object_with_versions(cmd_template, expected, s3_client, versioned_bucket_with_one_object, profile_name, active_mgc_workspace): | ||
bucket_name, object_key, _ = versioned_bucket_with_one_object | ||
|
||
#Adicionando uma segunda versão deste objeto | ||
s3_client.put_object( | ||
Bucket = bucket_name, | ||
Key = object_key, | ||
Body = b"second version of this object" | ||
) | ||
|
||
|
||
cmd = split(cmd_template.format(bucket_name=bucket_name, profile_name=profile_name, object_key=object_key)) | ||
result = subprocess.run(cmd, capture_output=True, text=True) | ||
|
||
assert result.returncode == 0, f"Command failed with error: {result.stderr}" | ||
logging.info(f"Output from {cmd_template}: {result.stdout}") | ||
|
||
|
||
assert result.stdout == expected.format(bucket_name=bucket_name, object_key=object_key) | ||
|
||
run_example(__name__, "test_delete_bucket_with_objects_with_versions", config=config) | ||
|
||
commands = [ | ||
("mgc object-storage buckets delete {bucket_name} --no-confirm --recursive --raw", "the bucket may not be empty"), | ||
("aws --profile {profile_name} s3 rb s3://{bucket_name}", "BucketNotEmpty"), | ||
("rclone rmdir {profile_name}:{bucket_name}", "BucketNotEmpty") | ||
] | ||
|
||
@pytest.mark.parametrize("cmd_template, expected", commands) | ||
def test_delete_bucket_with_objects_with_versions(cmd_template, expected, s3_client, versioned_bucket_with_one_object, profile_name, active_mgc_workspace): | ||
bucket_name, object_key, _ = versioned_bucket_with_one_object | ||
|
||
s3_client.put_object( | ||
Bucket = bucket_name, | ||
Key = object_key, | ||
Body = b"v2" | ||
) | ||
|
||
cmd = split(cmd_template.format(bucket_name=bucket_name, profile_name=profile_name, object_key=object_key)) | ||
result = subprocess.run(cmd, capture_output=True, text=True) | ||
|
||
assert result.returncode != 0, f"Command failed with error: {result.stderr}" | ||
logging.info(f"Output from {cmd_template}: {result.stdout}") | ||
assert expected in result.stderr | ||
|
||
run_example(__name__, "test_delete_bucket_with_objects_with_versions", config=config) |
Oops, something went wrong.