-
Notifications
You must be signed in to change notification settings - Fork 19
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
fix(s3 dataplane): Fix transfer of empty objects #417
Changes from 12 commits
b9dfaa4
a975f89
64e84ca
bce5f6a
326153e
e52cd56
0f1a0ec
628c084
0730a0e
6f11324
62ef21a
50cc04f
a6645ac
6a1d444
900004a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,9 +35,11 @@ | |
import software.amazon.awssdk.core.ResponseBytes; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.s3.model.GetObjectResponse; | ||
import software.amazon.awssdk.services.s3.model.NoSuchKeyException; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.Executors; | ||
import java.util.stream.Stream; | ||
|
||
|
@@ -105,6 +107,12 @@ void should_copy_using_destination_object_name_case_single_transfer(List<String> | |
var objectNameInDestination = "object-name-in-destination"; | ||
var objectContent = UUID.randomUUID().toString(); | ||
|
||
//Put folder 0 byte size file marker. AWS does this when a folder is created via the console. | ||
if (!isSingleObject) { | ||
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. I know the test was already structured like this, but it's not a good practice to have conditionals into a test, better to have 2 distinct tests. It could also be solved in a different PR 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. I agree these test class deserve some attention. The conditionals are there because the argument provider is the same for both test cases. I maintained it the same way to avoid refactoring the thing since it seems to be better done in another PR. I can create the issue. |
||
sourceClient.putStringOnBucket(sourceBucketName, OBJECT_PREFIX, ""); | ||
sourceClient.putStringOnBucket(sourceBucketName, OBJECT_PREFIX + "testFolder/", ""); | ||
} | ||
|
||
for (var objectName : objectNames) { | ||
sourceClient.putStringOnBucket(sourceBucketName, objectName, objectContent); | ||
} | ||
|
@@ -152,6 +160,11 @@ void should_copy_using_destination_object_name_case_single_transfer(List<String> | |
.extracting(Long::intValue) | ||
.isEqualTo(objectContent.length()); | ||
} | ||
|
||
assertThat(destinationClient.getObject(destinationBucketName, | ||
OBJECT_PREFIX)).failsWithin(5, SECONDS) | ||
.withThrowableOfType(ExecutionException.class) | ||
.withCauseInstanceOf(NoSuchKeyException.class); | ||
} | ||
} | ||
|
||
|
@@ -164,6 +177,12 @@ void should_copy_to_folder_case_property_is_present(List<String> objectNames) { | |
var folderNameInDestination = "folder-name-in-destination/"; | ||
var objectBody = UUID.randomUUID().toString(); | ||
|
||
//Put folder 0 byte size file marker. AWS does this when a folder is created via the console. | ||
if (!isSingleObject) { | ||
sourceClient.putStringOnBucket(sourceBucketName, OBJECT_PREFIX, ""); | ||
sourceClient.putStringOnBucket(sourceBucketName, OBJECT_PREFIX + "testFolder/", ""); | ||
} | ||
|
||
for (var objectToTransfer : objectNames) { | ||
sourceClient.putStringOnBucket(sourceBucketName, objectToTransfer, objectBody); | ||
} | ||
|
@@ -212,7 +231,13 @@ void should_copy_to_folder_case_property_is_present(List<String> objectNames) { | |
.extracting(Long::intValue) | ||
.isEqualTo(objectBody.length()); | ||
} | ||
assertThat(destinationClient.getObject(destinationBucketName, folderNameInDestination + | ||
OBJECT_PREFIX)).failsWithin(5, SECONDS) | ||
.withThrowableOfType(ExecutionException.class) | ||
.withCauseInstanceOf(NoSuchKeyException.class); | ||
} | ||
|
||
|
||
} | ||
|
||
private DataAddress createDataAddress(List<String> assetNames, boolean isSingleObject) { | ||
|
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 can be a class field or constant, so it won't be recreated each time
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.
addressed in a6645ac