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);
// validate
String[] errorLines = errors.toString().split("\n");
String[] errorLines = errors.toString().split("\r?\n");
Arrays.stream(errorLines).forEach(ourLog::info);
assertEquals(2, errorLines.length);
assertThat(errorLines[0], startsWith("[ERROR] "));

View File

@ -331,7 +331,7 @@ public class UploadTerminologyCommandTest {
));
fail();
} 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");
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 1));
assertTrue(ourGreenMail.waitForIncomingEmail(10000, 1));
MimeMessage[] messages = ourGreenMail.getReceivedMessages();
assertEquals(2, messages.length);

View File

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

View File

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

View File

@ -52,6 +52,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.concurrent.TimeUnit;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.is;
@ -1061,9 +1062,9 @@ public class BulkExportUseCaseTest extends BaseResourceProviderR4Test {
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();
BulkExportJobResults results = JsonUtil.deserialize(report, BulkExportJobResults.class);

View File

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

View File

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

View File

@ -936,7 +936,10 @@ public class NpmR4Test extends BaseJpaR4Test {
public void testInstallR4PackageFromFile() {
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);
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 {
try {
return future.get(1, TimeUnit.SECONDS);
return future.get(60, TimeUnit.SECONDS);
} catch (TimeoutException e) {
fail(theMessage);
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.PathItem;
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.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
@ -218,7 +219,15 @@ public class OpenApiInterceptorTest {
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

View File

@ -42,7 +42,7 @@ public class MailSvcIT {
// execute
fixture.sendMail(email);
// validate
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 1));
assertTrue(ourGreenMail.waitForIncomingEmail(5000, 1));
final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages();
assertEquals(1, receivedMessages.length);
assertEquals(SUBJECT, receivedMessages[0].getSubject());
@ -56,7 +56,7 @@ public class MailSvcIT {
// execute
fixture.sendMail(emails);
// validate
assertTrue(ourGreenMail.waitForIncomingEmail(1000, emails.size()));
assertTrue(ourGreenMail.waitForIncomingEmail(15000, emails.size()));
final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages();
assertEquals(emails.size(), receivedMessages.length);
assertEquals(SUBJECT, receivedMessages[0].getSubject());
@ -76,7 +76,7 @@ public class MailSvcIT {
fixture.sendMail(email);
// validate
assertTrue(ourGreenMail.waitForIncomingEmail(1000, 0));
assertTrue(ourGreenMail.waitForIncomingEmail(5000, 0));
final MimeMessage[] receivedMessages = ourGreenMail.getReceivedMessages();
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) {
@ -163,7 +163,7 @@ public class FhirContextDstu2Test {
});
}
// 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
afterInitBlocker.countDown();
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);
HttpClientBuilder builder = HttpClientBuilder.create();
int timeout = 5;
int timeout = 60;
RequestConfig config = RequestConfig.custom()
.setConnectTimeout(timeout * 1000)
.setConnectionRequestTimeout(timeout * 1000)