From d7144c65bfde5fb7020c69af555a78b4bbabc8f4 Mon Sep 17 00:00:00 2001 From: Andrey Berezin Date: Wed, 1 Nov 2023 19:20:15 +0300 Subject: [PATCH] Skip teardown if sanity in markexpr --- pytest_tests/testsuites/conftest.py | 15 ++++++++------- .../testsuites/services/s3_gate/test_s3_ACL.py | 17 ++++------------- .../services/s3_gate/test_s3_bucket.py | 1 - .../testsuites/services/s3_gate/test_s3_gate.py | 1 + .../services/s3_gate/test_s3_locking.py | 1 - .../services/s3_gate/test_s3_multipart.py | 1 - .../services/s3_gate/test_s3_object.py | 1 - .../services/s3_gate/test_s3_policy.py | 1 - .../services/s3_gate/test_s3_tagging.py | 1 - .../services/s3_gate/test_s3_versioning.py | 1 - 10 files changed, 13 insertions(+), 27 deletions(-) diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index 1be5d3c1..6705bb51 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -246,7 +246,8 @@ def versioning_status(request: pytest.FixtureRequest) -> VersioningStatus: @allure.step("Create/delete bucket") @pytest.fixture -def bucket(s3_client: S3ClientWrapper, versioning_status: VersioningStatus): +def bucket(s3_client: S3ClientWrapper, versioning_status: VersioningStatus, request: pytest.FixtureRequest): + bucket_name = s3_client.create_bucket() if versioning_status: @@ -254,20 +255,20 @@ def bucket(s3_client: S3ClientWrapper, versioning_status: VersioningStatus): yield bucket_name - -# s3_helper.delete_bucket_with_objects(s3_client, bucket_name) + if "sanity" not in request.config.option.markexpr: + s3_helper.delete_bucket_with_objects(s3_client, bucket_name) @allure.step("Create two buckets") @pytest.fixture -def two_buckets(s3_client: S3ClientWrapper): +def two_buckets(s3_client: S3ClientWrapper, request: pytest.FixtureRequest): bucket_1 = s3_client.create_bucket() bucket_2 = s3_client.create_bucket() yield bucket_1, bucket_2 - -# for bucket_name in [bucket_1, bucket_2]: -# s3_helper.delete_bucket_with_objects(s3_client, bucket_name) + if "sanity" not in request.config.option.markexpr: + for bucket_name in [bucket_1, bucket_2]: + s3_helper.delete_bucket_with_objects(s3_client, bucket_name) @allure.step("[Autouse/Session] Check binary versions") diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_ACL.py b/pytest_tests/testsuites/services/s3_gate/test_s3_ACL.py index 7cb66749..6040aea0 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_ACL.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_ACL.py @@ -6,15 +6,12 @@ from frostfs_testlib.storage.dataclasses.object_size import ObjectSize from frostfs_testlib.utils.file_utils import generate_file -@pytest.mark.sanity @pytest.mark.acl @pytest.mark.s3_gate class TestS3GateACL: @allure.title("Object ACL (s3_client={s3_client})") @pytest.mark.parametrize("s3_client", [AwsCliClient], indirect=True) - def test_s3_object_ACL( - self, s3_client: S3ClientWrapper, bucket: str, simple_object_size: ObjectSize - ): + def test_s3_object_ACL(self, s3_client: S3ClientWrapper, bucket: str, simple_object_size: ObjectSize): file_path = generate_file(simple_object_size.value) file_name = s3_helper.object_key_from_file_path(file_path) @@ -33,9 +30,7 @@ class TestS3GateACL: obj_acl = s3_client.get_object_acl(bucket, file_name) s3_helper.assert_s3_acl(acl_grants=obj_acl, permitted_users="CanonicalUser") - with allure.step( - "Put object with grant-read uri=http://acs.amazonaws.com/groups/global/AllUsers" - ): + with allure.step("Put object with grant-read uri=http://acs.amazonaws.com/groups/global/AllUsers"): s3_client.put_object_acl( bucket, file_name, @@ -48,9 +43,7 @@ class TestS3GateACL: @pytest.mark.parametrize("s3_client", [AwsCliClient, Boto3ClientWrapper], indirect=True) def test_s3_bucket_ACL(self, s3_client: S3ClientWrapper): with allure.step("Create bucket with ACL = public-read-write"): - bucket = s3_client.create_bucket( - object_lock_enabled_for_bucket=True, acl="public-read-write" - ) + bucket = s3_client.create_bucket(object_lock_enabled_for_bucket=True, acl="public-read-write") bucket_acl = s3_client.get_bucket_acl(bucket) s3_helper.assert_s3_acl(acl_grants=bucket_acl, permitted_users="AllUsers") @@ -59,9 +52,7 @@ class TestS3GateACL: bucket_acl = s3_client.get_bucket_acl(bucket) s3_helper.assert_s3_acl(acl_grants=bucket_acl, permitted_users="CanonicalUser") - with allure.step( - "Change bucket acl to --grant-write uri=http://acs.amazonaws.com/groups/global/AllUsers" - ): + with allure.step("Change bucket acl to --grant-write uri=http://acs.amazonaws.com/groups/global/AllUsers"): s3_client.put_bucket_acl( bucket, grant_write="uri=http://acs.amazonaws.com/groups/global/AllUsers", diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_bucket.py b/pytest_tests/testsuites/services/s3_gate/test_s3_bucket.py index 8b9b42d1..beded527 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_bucket.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_bucket.py @@ -8,7 +8,6 @@ from frostfs_testlib.storage.dataclasses.object_size import ObjectSize from frostfs_testlib.utils.file_utils import generate_file -@pytest.mark.sanity @pytest.mark.s3_gate @pytest.mark.s3_gate_bucket class TestS3GateBucket: diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_gate.py b/pytest_tests/testsuites/services/s3_gate/test_s3_gate.py index 6cdc29d4..ce170470 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_gate.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_gate.py @@ -23,6 +23,7 @@ logger = logging.getLogger("NeoLogger") @allure.link("https://github.com/TrueCloudLab/frostfs-s3-gw#frostfs-s3-gw", name="frostfs-s3-gateway") +@pytest.mark.sanity @pytest.mark.s3_gate @pytest.mark.s3_gate_base class TestS3Gate: diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_locking.py b/pytest_tests/testsuites/services/s3_gate/test_s3_locking.py index c5b95777..9e1857b4 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_locking.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_locking.py @@ -9,7 +9,6 @@ from frostfs_testlib.storage.dataclasses.object_size import ObjectSize from frostfs_testlib.utils.file_utils import generate_file, generate_file_with_content -@pytest.mark.sanity @pytest.mark.s3_gate @pytest.mark.s3_gate_locking @pytest.mark.parametrize("version_id", [None, "second"]) diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_multipart.py b/pytest_tests/testsuites/services/s3_gate/test_s3_multipart.py index 22c7f01e..12f1e93d 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_multipart.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_multipart.py @@ -10,7 +10,6 @@ from frostfs_testlib.utils.file_utils import generate_file, get_file_hash, split PART_SIZE = 5 * 1024 * 1024 -@pytest.mark.sanity @pytest.mark.s3_gate @pytest.mark.s3_gate_multipart class TestS3GateMultipart(ClusterTestBase): diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_object.py b/pytest_tests/testsuites/services/s3_gate/test_s3_object.py index 49aeb815..8ed41b7e 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_object.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_object.py @@ -17,7 +17,6 @@ from frostfs_testlib.utils import wallet_utils from frostfs_testlib.utils.file_utils import concat_files, generate_file, generate_file_with_content, get_file_hash -@pytest.mark.sanity @pytest.mark.s3_gate @pytest.mark.s3_gate_object class TestS3GateObject: diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_policy.py b/pytest_tests/testsuites/services/s3_gate/test_s3_policy.py index 7d1ca840..387cdfa3 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_policy.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_policy.py @@ -12,7 +12,6 @@ from frostfs_testlib.testing.test_control import expect_not_raises from frostfs_testlib.utils.file_utils import generate_file -@pytest.mark.sanity @pytest.mark.s3_gate @pytest.mark.parametrize("s3_policy", ["pytest_tests/resources/files/policy.json"], indirect=True) class TestS3GatePolicy(ClusterTestBase): diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_tagging.py b/pytest_tests/testsuites/services/s3_gate/test_s3_tagging.py index ad8c0e0a..fb3f44e8 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_tagging.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_tagging.py @@ -10,7 +10,6 @@ from frostfs_testlib.storage.dataclasses.object_size import ObjectSize from frostfs_testlib.utils.file_utils import generate_file -@pytest.mark.sanity @pytest.mark.s3_gate @pytest.mark.s3_gate_tagging class TestS3GateTagging: diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_versioning.py b/pytest_tests/testsuites/services/s3_gate/test_s3_versioning.py index 2f894130..57fc3c05 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_versioning.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_versioning.py @@ -6,7 +6,6 @@ from frostfs_testlib.storage.dataclasses.object_size import ObjectSize from frostfs_testlib.utils.file_utils import generate_file, generate_file_with_content -@pytest.mark.sanity @pytest.mark.s3_gate @pytest.mark.s3_gate_versioning class TestS3GateVersioning: