diff --git a/src/main/java/org/gridsuite/computation/s3/ComputationS3Service.java b/src/main/java/org/gridsuite/computation/s3/ComputationS3Service.java index 92882e4..fe9d6b8 100644 --- a/src/main/java/org/gridsuite/computation/s3/ComputationS3Service.java +++ b/src/main/java/org/gridsuite/computation/s3/ComputationS3Service.java @@ -38,13 +38,12 @@ public ComputationS3Service(S3Client s3Client, String bucketName) { this.bucketName = bucketName; } - public void uploadFile(Path filePath, String s3Key, String fileName, Integer expireAfterMinutes) throws IOException { + public void uploadFile(Path filePath, String s3Key, String fileName) throws IOException { try { PutObjectRequest putRequest = PutObjectRequest.builder() .bucket(bucketName) .key(s3Key) .metadata(Map.of(METADATA_FILE_NAME, fileName)) - .tagging(expireAfterMinutes != null ? "expire-after-minutes=" + expireAfterMinutes : null) .build(); s3Client.putObject(putRequest, RequestBody.fromFile(filePath)); } catch (SdkException e) { diff --git a/src/main/java/org/gridsuite/computation/service/AbstractWorkerService.java b/src/main/java/org/gridsuite/computation/service/AbstractWorkerService.java index 2becdc9..e71cf07 100644 --- a/src/main/java/org/gridsuite/computation/service/AbstractWorkerService.java +++ b/src/main/java/org/gridsuite/computation/service/AbstractWorkerService.java @@ -230,7 +230,7 @@ protected void processDebug(AbstractResultContext resultContext) { resultService.saveDebugFileLocation(resultContext.getResultUuid(), s3Key); // upload zip file to s3 storage - computationS3Service.uploadFile(debugFilePath, s3Key, fileName, 30); + computationS3Service.uploadFile(debugFilePath, s3Key, fileName); // notify to study-server sendDebugMessage(resultContext, null); diff --git a/src/test/java/org/gridsuite/computation/ComputationTest.java b/src/test/java/org/gridsuite/computation/ComputationTest.java index 8eff721..d3b110f 100644 --- a/src/test/java/org/gridsuite/computation/ComputationTest.java +++ b/src/test/java/org/gridsuite/computation/ComputationTest.java @@ -392,7 +392,7 @@ void testProcessDebugWithS3Service() throws IOException { // Verify interactions verify(resultService).saveDebugFileLocation(eq(RESULT_UUID), anyString()); - verify(computationS3Service).uploadFile(any(Path.class), anyString(), anyString(), eq(30)); + verify(computationS3Service).uploadFile(any(Path.class), anyString(), anyString()); verify(notificationService.getPublisher(), times(1 /* for result message */)) .send(eq("publishResult-out-0"), isA(Message.class)); verify(notificationService.getPublisher(), times(1 /* for debug message */)) @@ -459,7 +459,7 @@ void testProcessDebugWithIOException() throws IOException { workerService.consumeRun().accept(message); // Verify interactions - verify(computationS3Service, never()).uploadFile(any(), any(), any(), anyInt()); + verify(computationS3Service, never()).uploadFile(any(), any(), any()); verify(resultService, never()).saveDebugFileLocation(any(), any()); verify(notificationService.getPublisher()).send(eq("publishDebug-out-0"), argThat((Message msg) -> msg.getHeaders().get(HEADER_ERROR_MESSAGE).equals("Zip error"))); diff --git a/src/test/java/org/gridsuite/computation/s3/ComputationS3ServiceTest.java b/src/test/java/org/gridsuite/computation/s3/ComputationS3ServiceTest.java index a88fe56..eea1970 100644 --- a/src/test/java/org/gridsuite/computation/s3/ComputationS3ServiceTest.java +++ b/src/test/java/org/gridsuite/computation/s3/ComputationS3ServiceTest.java @@ -53,7 +53,7 @@ void uploadFileShouldSendSuccessful() throws IOException { Files.writeString(tempFile, "Normal case"); // perform test - computationS3Service.uploadFile(tempFile, PATH_IN_S3, "test.txt", 30); + computationS3Service.uploadFile(tempFile, PATH_IN_S3, "test.txt"); // check result ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(PutObjectRequest.class); @@ -63,7 +63,6 @@ void uploadFileShouldSendSuccessful() throws IOException { assertThat(actualRequest.bucket()).isEqualTo("ws-bucket"); assertThat(actualRequest.key()).isEqualTo(PATH_IN_S3); assertThat(actualRequest.metadata()).containsEntry(ComputationS3Service.METADATA_FILE_NAME, "test.txt"); - assertThat(actualRequest.tagging()).isEqualTo("expire-after-minutes=30"); } @Test @@ -77,7 +76,7 @@ void uploadFileShouldThrowException() throws IOException { .thenThrow(S3Exception.builder().message(UPLOAD_FAILED_MESSAGE).build()); // perform test and check - assertThatThrownBy(() -> computationS3Service.uploadFile(tempFile, "key", "name.txt", null)) + assertThatThrownBy(() -> computationS3Service.uploadFile(tempFile, "key", "name.txt")) .isInstanceOf(IOException.class) .hasMessageContaining(UPLOAD_FAILED_MESSAGE); }