Skip to content
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

EVA-3454 removing retrying for MD5 checksum retriever #122

Merged
merged 2 commits into from
Jan 23, 2024
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 @@ -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;

Expand All @@ -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);
Expand Down
29 changes: 0 additions & 29 deletions src/test/java/uk/ac/ebi/eva/contigalias/datasource/RetryTest.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
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;
import org.mockito.Mock;
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;
Expand All @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -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));
}

}
Loading