Skip to content

Commit 9cf49b7

Browse files
authored
Remove unused s3 file's expired tag (#9)
Signed-off-by: Thang PHAM <[email protected]>
1 parent 2414637 commit 9cf49b7

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

src/main/java/org/gridsuite/computation/s3/ComputationS3Service.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ public ComputationS3Service(S3Client s3Client, String bucketName) {
3838
this.bucketName = bucketName;
3939
}
4040

41-
public void uploadFile(Path filePath, String s3Key, String fileName, Integer expireAfterMinutes) throws IOException {
41+
public void uploadFile(Path filePath, String s3Key, String fileName) throws IOException {
4242
try {
4343
PutObjectRequest putRequest = PutObjectRequest.builder()
4444
.bucket(bucketName)
4545
.key(s3Key)
4646
.metadata(Map.of(METADATA_FILE_NAME, fileName))
47-
.tagging(expireAfterMinutes != null ? "expire-after-minutes=" + expireAfterMinutes : null)
4847
.build();
4948
s3Client.putObject(putRequest, RequestBody.fromFile(filePath));
5049
} catch (SdkException e) {

src/main/java/org/gridsuite/computation/service/AbstractWorkerService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ protected void processDebug(AbstractResultContext<C> resultContext) {
230230
resultService.saveDebugFileLocation(resultContext.getResultUuid(), s3Key);
231231

232232
// upload zip file to s3 storage
233-
computationS3Service.uploadFile(debugFilePath, s3Key, fileName, 30);
233+
computationS3Service.uploadFile(debugFilePath, s3Key, fileName);
234234

235235
// notify to study-server
236236
sendDebugMessage(resultContext, null);

src/test/java/org/gridsuite/computation/ComputationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ void testProcessDebugWithS3Service() throws IOException {
392392

393393
// Verify interactions
394394
verify(resultService).saveDebugFileLocation(eq(RESULT_UUID), anyString());
395-
verify(computationS3Service).uploadFile(any(Path.class), anyString(), anyString(), eq(30));
395+
verify(computationS3Service).uploadFile(any(Path.class), anyString(), anyString());
396396
verify(notificationService.getPublisher(), times(1 /* for result message */))
397397
.send(eq("publishResult-out-0"), isA(Message.class));
398398
verify(notificationService.getPublisher(), times(1 /* for debug message */))
@@ -459,7 +459,7 @@ void testProcessDebugWithIOException() throws IOException {
459459
workerService.consumeRun().accept(message);
460460

461461
// Verify interactions
462-
verify(computationS3Service, never()).uploadFile(any(), any(), any(), anyInt());
462+
verify(computationS3Service, never()).uploadFile(any(), any(), any());
463463
verify(resultService, never()).saveDebugFileLocation(any(), any());
464464
verify(notificationService.getPublisher()).send(eq("publishDebug-out-0"), argThat((Message<String> msg) ->
465465
msg.getHeaders().get(HEADER_ERROR_MESSAGE).equals("Zip error")));

src/test/java/org/gridsuite/computation/s3/ComputationS3ServiceTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void uploadFileShouldSendSuccessful() throws IOException {
5353
Files.writeString(tempFile, "Normal case");
5454

5555
// perform test
56-
computationS3Service.uploadFile(tempFile, PATH_IN_S3, "test.txt", 30);
56+
computationS3Service.uploadFile(tempFile, PATH_IN_S3, "test.txt");
5757

5858
// check result
5959
ArgumentCaptor<PutObjectRequest> requestCaptor = ArgumentCaptor.forClass(PutObjectRequest.class);
@@ -63,7 +63,6 @@ void uploadFileShouldSendSuccessful() throws IOException {
6363
assertThat(actualRequest.bucket()).isEqualTo("ws-bucket");
6464
assertThat(actualRequest.key()).isEqualTo(PATH_IN_S3);
6565
assertThat(actualRequest.metadata()).containsEntry(ComputationS3Service.METADATA_FILE_NAME, "test.txt");
66-
assertThat(actualRequest.tagging()).isEqualTo("expire-after-minutes=30");
6766
}
6867

6968
@Test
@@ -77,7 +76,7 @@ void uploadFileShouldThrowException() throws IOException {
7776
.thenThrow(S3Exception.builder().message(UPLOAD_FAILED_MESSAGE).build());
7877

7978
// perform test and check
80-
assertThatThrownBy(() -> computationS3Service.uploadFile(tempFile, "key", "name.txt", null))
79+
assertThatThrownBy(() -> computationS3Service.uploadFile(tempFile, "key", "name.txt"))
8180
.isInstanceOf(IOException.class)
8281
.hasMessageContaining(UPLOAD_FAILED_MESSAGE);
8382
}

0 commit comments

Comments
 (0)