mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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.
This commit is contained in:
1 parent
73b034aa18
commit
f3562af70f
2 files changed
+20
-6
No files matched your search
+14
-1
@@ -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 ? "<ChecksumCRC32C>" + crc32c + "</ChecksumCRC32C>" : "") + "</Part>";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
* <p>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
|
||||
|
||||
Reference in new issue
Block a user