Skip to content

Commit

Permalink
add fail msg
Browse files Browse the repository at this point in the history
  • Loading branch information
emyl3 committed Feb 19, 2025
1 parent 7b27ed7 commit 3f3983e
Showing 1 changed file with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import gov.cdc.usds.simplereport.api.converter.FhirConverter;
import gov.cdc.usds.simplereport.db.model.auxiliary.FHIRBundleRecord;
import gov.cdc.usds.simplereport.service.ResultsUploaderCachingService;
import gov.cdc.usds.simplereport.service.SRProductionClient;
import gov.cdc.usds.simplereport.test_util.TestDataBuilder;
import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -46,12 +45,11 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.stubbing.Answer;
import org.springframework.boot.info.GitProperties;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@ExtendWith(SpringExtension.class)
@ExtendWith(MockitoExtension.class)
public class BulkUploadResultsToFhirTest {
private static GitProperties gitProperties;
private static ResultsUploaderCachingService resultsUploaderCachingService;
Expand All @@ -62,8 +60,6 @@ public class BulkUploadResultsToFhirTest {
private final DateGenerator dateGenerator = new DateGenerator();
BulkUploadResultsToFhir sut;

@MockBean SRProductionClient _mockSRProductionClient;

@BeforeAll
public static void init() throws SmartyException, IOException, InterruptedException {
gitProperties = mock(GitProperties.class);
Expand Down Expand Up @@ -477,29 +473,24 @@ void convertExistingCsv_matchesFhir_NDJson() throws IOException {

@Test
void convertExistingCsv_meetsProcessingSpeed() {
try (InputStream inputStream =
BulkUploadResultsToFhirTest.class
.getClassLoader()
.getResourceAsStream("testResultUpload/test-results-upload-valid-5000-rows.csv")) {
var startTime = System.currentTimeMillis();

sut.convertToFhirBundles(inputStream, UUID.randomUUID());

var endTime = System.currentTimeMillis();
var elapsedTime = endTime - startTime;

// The processing is threaded so the elapsed time is closely tied to available CPU cores.
// GitHub
// action runners
// will require more time because they have less cores than our dev or prod machines.
assertTrue(
elapsedTime < 30000,
"Bundle processing took more than 30 seconds for 5000 rows. It took "
+ elapsedTime
+ " milliseconds.");
} catch (IOException e) {
fail("IOException when loading csv");
}
InputStream input = loadCsv("testResultUpload/test-results-upload-valid-5000-rows.csv");

var startTime = System.currentTimeMillis();

sut.convertToFhirBundles(input, UUID.randomUUID());

var endTime = System.currentTimeMillis();
var elapsedTime = endTime - startTime;

// The processing is threaded so the elapsed time is closely tied to available CPU cores. GitHub
// action runners
// will require more time because they have less cores than our dev or prod machines.
String msg =
"Bundle processing took more than 30 seconds for 5000 rows. It took "
+ elapsedTime
+ " milliseconds.";
fail(msg);
assertTrue(elapsedTime < 30000, msg);
}

@Test
Expand Down

0 comments on commit 3f3983e

Please sign in to comment.