Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,11 @@ void deleteObjectAtPath(Path f,
String key,
boolean isFile)
throws SdkException, IOException {
deleteObject(key);
mock.getS3AInternals()
.getAmazonS3Client("test")
.deleteObject(getRequestFactory()
.newDeleteObjectRequestBuilder(key)
.build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
import software.amazon.awssdk.services.s3.model.MultipartUpload;
import software.amazon.awssdk.services.s3.model.UploadPartRequest;
import software.amazon.awssdk.services.s3.model.UploadPartResponse;

import org.apache.hadoop.fs.s3a.S3AInternals;
import org.apache.hadoop.fs.s3a.S3AStore;
import org.apache.hadoop.util.Lists;
import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
import org.junit.AfterClass;
Expand Down Expand Up @@ -129,9 +132,10 @@ protected StagingTestBase() {
* @throws IOException IO problems.
*/
protected static S3AFileSystem createAndBindMockFSInstance(Configuration conf,
Pair<StagingTestBase.ClientResults, StagingTestBase.ClientErrors> outcome)
Pair<StagingTestBase.ClientResults, StagingTestBase.ClientErrors> outcome,
S3Client mockS3Client)
throws IOException {
S3AFileSystem mockFs = mockS3AFileSystemRobustly();
S3AFileSystem mockFs = mockS3AFileSystemRobustly(mockS3Client);
MockS3AFileSystem wrapperFS = new MockS3AFileSystem(mockFs, outcome);
URI uri = RAW_BUCKET_URI;
wrapperFS.initialize(uri, conf);
Expand All @@ -142,8 +146,13 @@ protected static S3AFileSystem createAndBindMockFSInstance(Configuration conf,
return mockFs;
}

private static S3AFileSystem mockS3AFileSystemRobustly() {
private static S3AFileSystem mockS3AFileSystemRobustly(S3Client mockS3Client) {
S3AFileSystem mockFS = mock(S3AFileSystem.class);
S3AInternals s3AInternals = mock(S3AInternals.class);
when(mockFS.getS3AInternals()).thenReturn(s3AInternals);
when(s3AInternals.getStore()).thenReturn(mock(S3AStore.class));
when(s3AInternals.getAmazonS3Client(anyString()))
.thenReturn(mockS3Client);
doNothing().when(mockFS).incrementReadOperations();
doNothing().when(mockFS).incrementWriteOperations();
doNothing().when(mockFS).incrementWriteOperations();
Expand Down Expand Up @@ -350,7 +359,7 @@ public void setupJob() throws Exception {
this.errors = new StagingTestBase.ClientErrors();
this.mockClient = newMockS3Client(results, errors);
this.mockFS = createAndBindMockFSInstance(jobConf,
Pair.of(results, errors));
Pair.of(results, errors), mockClient);
this.wrapperFS = lookupWrapperFS(jobConf);
// and bind the FS
wrapperFS.setAmazonS3Client(mockClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void setupCommitter() throws Exception {
this.errors = new StagingTestBase.ClientErrors();
this.mockClient = newMockS3Client(results, errors);
this.mockFS = createAndBindMockFSInstance(jobConf,
Pair.of(results, errors));
Pair.of(results, errors), mockClient);
this.wrapperFS = lookupWrapperFS(jobConf);
// and bind the FS
wrapperFS.setAmazonS3Client(mockClient);
Expand Down