From f3562af70f79b2d9505b4ec2e47f68bb52c92f5e Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Tue, 13 Oct 2026 23:28:25 -0400 Subject: [PATCH] test(s3): remove the buckets S3GetObjectPartIntegrationTest creates (#5601) Every test in the class created a bucket and left it, with its object, in the emulator that all @QuarkusTest classes share: about 30 MiB, since six of them upload a 5 MiB first part. Each bucket now has its removal registered with PartitionCleanup as it is created, through the shared EnforcementFixtures.removeBucket, which empties the bucket before deleting it and does nothing for a bucket that was never made. This is the first test outside the enforcement tests to use EnforcementFixtures, so its description now says it takes back what any test created, while the users it makes are still the ones an enforcement test signs as. --- .../s3/S3GetObjectPartIntegrationTest.java | 15 ++++++++++++++- .../floci/testing/EnforcementFixtures.java | 11 ++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/test/java/io/github/hectorvent/floci/services/s3/S3GetObjectPartIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/s3/S3GetObjectPartIntegrationTest.java index d101f0db63..d82e9ccf8e 100644 --- a/src/test/java/io/github/hectorvent/floci/services/s3/S3GetObjectPartIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/s3/S3GetObjectPartIntegrationTest.java @@ -1,14 +1,20 @@ package io.github.hectorvent.floci.services.s3; import io.github.hectorvent.floci.services.s3.model.S3Checksum; +import io.github.hectorvent.floci.testing.EnforcementFixtures; +import io.github.hectorvent.floci.testing.PartitionCleanup; +import io.quarkus.test.common.http.TestHTTPResource; import io.quarkus.test.junit.QuarkusTest; import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.UUID; +import static io.github.hectorvent.floci.testing.EnforcementFixtures.auth; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.emptyString; @@ -29,6 +35,12 @@ class S3GetObjectPartIntegrationTest { private static final String SECOND_PART = "test content 123"; private static final long OBJECT_SIZE = FIRST_PART.length + SECOND_PART.length(); + @TestHTTPResource("/") + static URI baseUri; + + @RegisterExtension + final PartitionCleanup cleanup = new PartitionCleanup(); + @Test void getObject_partOfAMultipartObject_isServedLikeItsRange() { String bucket = createBucket("part-get"); @@ -324,8 +336,9 @@ class S3GetObjectPartIntegrationTest { + (crc32c != null ? "" + crc32c + "" : "") + ""; } - private static String createBucket(String prefix) { + private String createBucket(String prefix) { String bucket = prefix + "-" + UUID.randomUUID().toString().substring(0, 8); + cleanup.register(() -> EnforcementFixtures.removeBucket(baseUri.getPort(), auth("test", "s3"), bucket)); given().when().put("/" + bucket).then().statusCode(200); return bucket; } diff --git a/src/test/java/io/github/hectorvent/floci/testing/EnforcementFixtures.java b/src/test/java/io/github/hectorvent/floci/testing/EnforcementFixtures.java index c34c8b26e5..e3789e9043 100644 --- a/src/test/java/io/github/hectorvent/floci/testing/EnforcementFixtures.java +++ b/src/test/java/io/github/hectorvent/floci/testing/EnforcementFixtures.java @@ -12,11 +12,12 @@ import java.util.List; import static io.restassured.RestAssured.given; /** - * Takes an IAM user or an S3 bucket that an enforcement test created back out of the shared - * application, and makes the users such a test signs as ({@link #createUser}, {@link #auth}), - * registering each one's removal as it goes. A {@code @QuarkusTest} shares one application with every other test class, so a - * fixture left behind outlives the class that made it and is visible to the next class that lists - * users or buckets unscoped. Registered with {@link PartitionCleanup} as each fixture is made. + * Takes an IAM user or an S3 bucket that a test created back out of the shared application, and + * makes the users an enforcement test signs as ({@link #createUser}, {@link #auth}), registering + * each one's removal as it goes. A {@code @QuarkusTest} shares one application with every other + * test class, so a fixture left behind outlives the class that made it and is visible to the next + * class that lists users or buckets unscoped. Registered with {@link PartitionCleanup} as each + * fixture is made. * *

Both read back what is attached rather than taking it as an argument, and both return * quietly when the thing is not there. That is what makes them safe to register before the create