Fix some issues with 'mvn test' on windows (#4223)

* fix handling of Windows line ends

* some tests need to wait a little longer for things to get done

* Windows path separator fix

* simpler lineend fix

* more timeouts and another path separator issue

* redo some timeout issues

* Issue in Windows: URI is not hierarchical

* another timeout issue
This commit is contained in:
William Denton 2023-01-07 11:49:35 -08:00 committed by GitHub
parent 21f497574a
commit 02de3e49e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 34 additions and 20 deletions

View File

@ -42,7 +42,7 @@ class HapiErrorCodeCheckTest {
checker.process(files); checker.process(files);
// validate // validate
String[] errorLines = errors.toString().split("\n"); String[] errorLines = errors.toString().split("\r?\n");
Arrays.stream(errorLines).forEach(ourLog::info); Arrays.stream(errorLines).forEach(ourLog::info);
assertEquals(2, errorLines.length); assertEquals(2, errorLines.length);
assertThat(errorLines[0], startsWith("[ERROR] ")); assertThat(errorLines[0], startsWith("[ERROR] "));

View File

@ -331,7 +331,7 @@ public class UploadTerminologyCommandTest {
)); ));
fail(); fail();
} catch (Error e) { } catch (Error e) {
assertThat(e.toString(), Matchers.containsString("FileNotFoundException: target/concepts.csv/foo.csv")); assertThat(e.toString().replace('\\', '/'), Matchers.containsString("FileNotFoundException: target/concepts.csv/foo.csv"));
} }
} }

View File

@ -128,7 +128,7 @@ public class EmailSubscriptionDstu2Test extends BaseResourceProviderDstu2Test {
Observation observation1 = sendObservation(code, "SNOMED-CT"); Observation observation1 = sendObservation(code, "SNOMED-CT");
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 1)); assertTrue(ourGreenMail.waitForIncomingEmail(10000, 1));
MimeMessage[] messages = ourGreenMail.getReceivedMessages(); MimeMessage[] messages = ourGreenMail.getReceivedMessages();
assertEquals(2, messages.length); assertEquals(2, messages.length);

View File

@ -46,7 +46,7 @@ public class EmailSenderImplTest {
details.setBodyTemplate("foo"); details.setBodyTemplate("foo");
fixture.send(details); fixture.send(details);
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 1)); assertTrue(ourGreenMail.waitForIncomingEmail(10000, 1));
MimeMessage[] messages = ourGreenMail.getReceivedMessages(); MimeMessage[] messages = ourGreenMail.getReceivedMessages();
assertEquals(2, messages.length); assertEquals(2, messages.length);

View File

@ -151,7 +151,7 @@ public class EmailSubscriptionDstu3Test extends BaseResourceProviderDstu3Test {
sendObservation(code, "SNOMED-CT"); sendObservation(code, "SNOMED-CT");
waitForQueueToDrain(); waitForQueueToDrain();
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 1)); assertTrue(ourGreenMail.waitForIncomingEmail(10000, 1));
List<MimeMessage> received = Arrays.asList(ourGreenMail.getReceivedMessages()); List<MimeMessage> received = Arrays.asList(ourGreenMail.getReceivedMessages());
assertEquals(1, received.get(0).getFrom().length); assertEquals(1, received.get(0).getFrom().length);
@ -196,7 +196,7 @@ public class EmailSubscriptionDstu3Test extends BaseResourceProviderDstu3Test {
sendObservation(code, "SNOMED-CT"); sendObservation(code, "SNOMED-CT");
waitForQueueToDrain(); waitForQueueToDrain();
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 1)); assertTrue(ourGreenMail.waitForIncomingEmail(10000, 1));
List<MimeMessage> received = Arrays.asList(ourGreenMail.getReceivedMessages()); List<MimeMessage> received = Arrays.asList(ourGreenMail.getReceivedMessages());
assertEquals(1, received.size()); assertEquals(1, received.size());

View File

@ -52,6 +52,7 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.concurrent.TimeUnit;
import static org.awaitility.Awaitility.await; import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
@ -1061,9 +1062,9 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
assertNotNull(startResponse); assertNotNull(startResponse);
myBatch2JobHelper.awaitJobCompletion(startResponse.getJobId()); myBatch2JobHelper.awaitJobCompletion(startResponse.getJobId(), 60);
await().until(() -> myJobRunner.getJobInfo(startResponse.getJobId()).getReport() != null); await().atMost(300, TimeUnit.SECONDS).until(() -> myJobRunner.getJobInfo(startResponse.getJobId()).getReport() != null);
String report = myJobRunner.getJobInfo(startResponse.getJobId()).getReport(); String report = myJobRunner.getJobInfo(startResponse.getJobId()).getReport();
BulkExportJobResults results = JsonUtil.deserialize(report, BulkExportJobResults.class); BulkExportJobResults results = JsonUtil.deserialize(report, BulkExportJobResults.class);

View File

@ -169,7 +169,7 @@ public class BulkDataImportR4Test extends BaseJpaR4Test implements ITestDataBuil
ActivateJobResult activateJobOutcome = mySvc.activateNextReadyJob(); ActivateJobResult activateJobOutcome = mySvc.activateNextReadyJob();
assertTrue(activateJobOutcome.isActivated); assertTrue(activateJobOutcome.isActivated);
JobInstance instance = myBatch2JobHelper.awaitJobCompletion(activateJobOutcome.jobId); JobInstance instance = myBatch2JobHelper.awaitJobCompletion(activateJobOutcome.jobId, 60);
assertNotNull(instance); assertNotNull(instance);
assertEquals(StatusEnum.COMPLETED, instance.getStatus()); assertEquals(StatusEnum.COMPLETED, instance.getStatus());

View File

@ -34,6 +34,7 @@ import org.springframework.data.domain.Pageable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.awaitility.Awaitility.await; import static org.awaitility.Awaitility.await;
@ -101,7 +102,7 @@ public class BulkImportR4Test extends BaseJpaR4Test {
// Verify // Verify
await().until(() -> { await().atMost(120, TimeUnit.SECONDS).until(() -> {
myJobCleanerService.runMaintenancePass(); myJobCleanerService.runMaintenancePass();
JobInstance instance = myJobCoordinator.getInstance(instanceId); JobInstance instance = myJobCoordinator.getInstance(instanceId);
return instance.getStatus(); return instance.getStatus();
@ -185,7 +186,7 @@ public class BulkImportR4Test extends BaseJpaR4Test {
return storage; return storage;
}); });
await().until(() -> { await().atMost(120, TimeUnit.SECONDS).until(() -> {
myJobCleanerService.runMaintenancePass(); myJobCleanerService.runMaintenancePass();
JobInstance instance = myJobCoordinator.getInstance(instanceId); JobInstance instance = myJobCoordinator.getInstance(instanceId);
return instance.getErrorCount(); return instance.getErrorCount();

View File

@ -936,7 +936,10 @@ public class NpmR4Test extends BaseJpaR4Test {
public void testInstallR4PackageFromFile() { public void testInstallR4PackageFromFile() {
Path currentRelativePath = Paths.get(""); Path currentRelativePath = Paths.get("");
String s = currentRelativePath.toAbsolutePath().toString(); String s = currentRelativePath.toAbsolutePath().toString().replace('\\', '/');
if (s.charAt(0) != '/' && s.charAt(1) == ':') { // is Windows..
s = s.substring(2); // .. get rid of the "C:" part (not perfect but...
}
System.out.println("Current absolute path is: " + s); System.out.println("Current absolute path is: " + s);
String fileUrl = "file:" + s + "/src/test/resources/packages/de.basisprofil.r4-1.2.0.tgz"; String fileUrl = "file:" + s + "/src/test/resources/packages/de.basisprofil.r4-1.2.0.tgz";

View File

@ -214,7 +214,7 @@ class MemoryCacheServiceTest {
public Integer getOrTimeout(String theMessage) throws InterruptedException, ExecutionException { public Integer getOrTimeout(String theMessage) throws InterruptedException, ExecutionException {
try { try {
return future.get(1, TimeUnit.SECONDS); return future.get(60, TimeUnit.SECONDS);
} catch (TimeoutException e) { } catch (TimeoutException e) {
fail(theMessage); fail(theMessage);
return null; return null;

View File

@ -27,6 +27,7 @@ import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.PathItem;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
@ -218,7 +219,15 @@ public class OpenApiInterceptorTest {
font-size: 1.1em; font-size: 1.1em;
} }
"""; """;
assertEquals(expected, resp); assertEquals(removeCtrlR(expected), removeCtrlR(resp));
}
protected String removeCtrlR (String source) {
String result = source;
if (source != null) {
result = StringUtils.remove(source, '\r');
}
return result;
} }
@Test @Test

View File

@ -42,7 +42,7 @@ public class MailSvcIT {
// execute // execute
fixture.sendMail(email); fixture.sendMail(email);
// validate // validate
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 1)); assertTrue(ourGreenMail.waitForIncomingEmail(5000, 1));
final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages(); final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages();
assertEquals(1, receivedMessages.length); assertEquals(1, receivedMessages.length);
assertEquals(SUBJECT, receivedMessages[0].getSubject()); assertEquals(SUBJECT, receivedMessages[0].getSubject());
@ -56,7 +56,7 @@ public class MailSvcIT {
// execute // execute
fixture.sendMail(emails); fixture.sendMail(emails);
// validate // validate
assertTrue(ourGreenMail.waitForIncomingEmail(1000, emails.size())); assertTrue(ourGreenMail.waitForIncomingEmail(15000, emails.size()));
final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages(); final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages();
assertEquals(emails.size(), receivedMessages.length); assertEquals(emails.size(), receivedMessages.length);
assertEquals(SUBJECT, receivedMessages[0].getSubject()); assertEquals(SUBJECT, receivedMessages[0].getSubject());
@ -76,7 +76,7 @@ public class MailSvcIT {
fixture.sendMail(email); fixture.sendMail(email);
// validate // validate
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 0)); assertTrue(ourGreenMail.waitForIncomingEmail(5000, 0));
final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages(); final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages();
assertEquals(0, receivedMessages.length); assertEquals(0, receivedMessages.length);
} }

View File

@ -110,7 +110,7 @@ public class FhirContextDstu2Test {
} }
}); });
} }
assertConcurrent("Unable to encode resources multithreaded", runnables, 1000); assertConcurrent("Unable to encode resources multithreaded", runnables, 30000);
} }
private void parseStringResourceMultipleTimesWithClass(IParser iParser, String medicationOrderResource) { private void parseStringResourceMultipleTimesWithClass(IParser iParser, String medicationOrderResource) {
@ -163,7 +163,7 @@ public class FhirContextDstu2Test {
}); });
} }
// wait until all threads are ready // wait until all threads are ready
assertTrue(allExecutorThreadsReady.await(runnables.size() * 10L, TimeUnit.MILLISECONDS), "Timeout initializing threads! Perform long lasting initializations before passing runnables to assertConcurrent"); assertTrue(allExecutorThreadsReady.await(runnables.size() * 1000L, TimeUnit.MILLISECONDS), "Timeout initializing threads! Perform long lasting initializations before passing runnables to assertConcurrent");
// start all test runners // start all test runners
afterInitBlocker.countDown(); afterInitBlocker.countDown();
assertTrue(allDone.await(maxTimeoutSeconds, TimeUnit.SECONDS), message + " timeout! More than" + maxTimeoutSeconds + "seconds"); assertTrue(allDone.await(maxTimeoutSeconds, TimeUnit.SECONDS), message + " timeout! More than" + maxTimeoutSeconds + "seconds");

View File

@ -271,7 +271,7 @@ public class BinaryDstu2Test {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS); PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClientBuilder.create(); HttpClientBuilder builder = HttpClientBuilder.create();
int timeout = 5; int timeout = 60;
RequestConfig config = RequestConfig.custom() RequestConfig config = RequestConfig.custom()
.setConnectTimeout(timeout * 1000) .setConnectTimeout(timeout * 1000)
.setConnectionRequestTimeout(timeout * 1000) .setConnectionRequestTimeout(timeout * 1000)