From ab500db1ca1dbd6fb336f0ef9de4e21a672d8351 Mon Sep 17 00:00:00 2001 From: nkumar2 Date: Tue, 23 Jan 2024 14:58:20 +0000 Subject: [PATCH 1/2] removing retry mechanism --- .../ac/ebi/eva/contigalias/scheduler/Md5ChecksumRetriever.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/uk/ac/ebi/eva/contigalias/scheduler/Md5ChecksumRetriever.java b/src/main/java/uk/ac/ebi/eva/contigalias/scheduler/Md5ChecksumRetriever.java index 1077f38b..912e5d6c 100644 --- a/src/main/java/uk/ac/ebi/eva/contigalias/scheduler/Md5ChecksumRetriever.java +++ b/src/main/java/uk/ac/ebi/eva/contigalias/scheduler/Md5ChecksumRetriever.java @@ -4,8 +4,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.retry.annotation.Backoff; -import org.springframework.retry.annotation.Retryable; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; @@ -22,7 +20,6 @@ public Md5ChecksumRetriever(RestTemplate restTemplate) { this.restTemplate = restTemplate; } - @Retryable(value = Exception.class, maxAttempts = 5, backoff = @Backoff(delay = 2000, multiplier = 2)) public String retrieveMd5Checksum(String insdcAccession) { String apiURL = INSDC_CHECKSUM_URL.replace(INSDC_ACCESSION_PLACE_HOLDER, insdcAccession); JsonNode jsonResponse = restTemplate.getForObject(apiURL, JsonNode.class); From 151ac07a243498b5d86980f453b10aae65f43ebf Mon Sep 17 00:00:00 2001 From: nkumar2 Date: Tue, 23 Jan 2024 15:02:50 +0000 Subject: [PATCH 2/2] removing retry test --- .../eva/contigalias/datasource/RetryTest.java | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/src/test/java/uk/ac/ebi/eva/contigalias/datasource/RetryTest.java b/src/test/java/uk/ac/ebi/eva/contigalias/datasource/RetryTest.java index 8c8440df..79ee4bb8 100644 --- a/src/test/java/uk/ac/ebi/eva/contigalias/datasource/RetryTest.java +++ b/src/test/java/uk/ac/ebi/eva/contigalias/datasource/RetryTest.java @@ -1,6 +1,5 @@ package uk.ac.ebi.eva.contigalias.datasource; -import com.fasterxml.jackson.databind.JsonNode; import org.apache.commons.net.ftp.FTPFile; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -8,13 +7,10 @@ import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.retry.annotation.EnableRetry; import org.springframework.test.context.TestPropertySource; -import org.springframework.web.client.RestTemplate; import uk.ac.ebi.eva.contigalias.dus.NCBIBrowser; import uk.ac.ebi.eva.contigalias.exception.DownloadFailedException; -import uk.ac.ebi.eva.contigalias.scheduler.Md5ChecksumRetriever; import java.io.IOException; import java.nio.file.Path; @@ -24,8 +20,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -44,13 +38,6 @@ public class RetryTest { @Autowired private NCBIAssemblyDataSource dataSource; - @Autowired - private Md5ChecksumRetriever md5ChecksumRetriever; - - @MockBean - private RestTemplate restTemplate; - - @Test public void fileDownloadSuccessfulTest() throws IOException { String mockAccession = "GCA_000012345.1"; @@ -120,20 +107,4 @@ public void fileDownloadFailedRetryTest2() throws IOException { verify(ncbiBrowser, times(5)).getGenomeReportDirectory(mockAccession); } - - @Test - public void retrieveMd5ChecksumRetry() { - String insdcAccession = "TEST_ACCESSION"; - when(restTemplate.getForObject(anyString(), eq(JsonNode.class))) - .thenThrow(new RuntimeException("Simulated network issue")); - - Md5ChecksumRetriever anotherObjSpy = Mockito.spy(md5ChecksumRetriever); - RuntimeException thrown = Assertions.assertThrows(RuntimeException.class, () -> { - anotherObjSpy.retrieveMd5Checksum(insdcAccession); - }); - - assertEquals("Simulated network issue", thrown.getMessage()); - verify(restTemplate, times(5)).getForObject(anyString(), eq(JsonNode.class)); - } - }