Intermittent test fix

This commit is contained in:
James Agnew 2020-02-03 18:06:29 -05:00
parent d7b45ff65c
commit b06105d970
2 changed files with 14 additions and 5 deletions

View File

@ -66,7 +66,13 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.*; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider.RESOURCE_ID; import static ca.uhn.fhir.jpa.provider.SubscriptionTriggeringProvider.RESOURCE_ID;
@ -136,8 +142,8 @@ public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc
SubscriptionTriggeringJobDetails jobDetails = new SubscriptionTriggeringJobDetails(); SubscriptionTriggeringJobDetails jobDetails = new SubscriptionTriggeringJobDetails();
jobDetails.setJobId(UUID.randomUUID().toString()); jobDetails.setJobId(UUID.randomUUID().toString());
jobDetails.setRemainingResourceIds(resourceIds.stream().map(t->t.getValue()).collect(Collectors.toList())); jobDetails.setRemainingResourceIds(resourceIds.stream().map(t -> t.getValue()).collect(Collectors.toList()));
jobDetails.setRemainingSearchUrls(searchUrls.stream().map(t->t.getValue()).collect(Collectors.toList())); jobDetails.setRemainingSearchUrls(searchUrls.stream().map(t -> t.getValue()).collect(Collectors.toList()));
if (theSubscriptionId != null) { if (theSubscriptionId != null) {
jobDetails.setSubscriptionId(theSubscriptionId.getIdPart()); jobDetails.setSubscriptionId(theSubscriptionId.getIdPart());
} }
@ -391,6 +397,10 @@ public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc
mySchedulerService.scheduleLocalJob(5 * DateUtils.MILLIS_PER_SECOND, jobDetail); mySchedulerService.scheduleLocalJob(5 * DateUtils.MILLIS_PER_SECOND, jobDetail);
} }
public int getActiveJobCount() {
return myActiveJobs.size();
}
public static class Job implements HapiJob { public static class Job implements HapiJob {
@Autowired @Autowired
private ISubscriptionTriggeringSvc myTarget; private ISubscriptionTriggeringSvc myTarget;

View File

@ -264,8 +264,6 @@ public class SubscriptionTriggeringDstu3Test extends BaseResourceProviderDstu3Te
@Test @Test
public void testTriggerUsingOrSeparatedList_MultipleStrings() throws Exception { public void testTriggerUsingOrSeparatedList_MultipleStrings() throws Exception {
myDaoConfig.setSearchPreFetchThresholds(Lists.newArrayList(13, 22, 100));
String payload = "application/fhir+json"; String payload = "application/fhir+json";
IdType sub2id = createSubscription("Patient?", payload, ourListenerServerBase).getIdElement(); IdType sub2id = createSubscription("Patient?", payload, ourListenerServerBase).getIdElement();
@ -299,6 +297,7 @@ public class SubscriptionTriggeringDstu3Test extends BaseResourceProviderDstu3Te
mySubscriptionTriggeringSvc.runDeliveryPass(); mySubscriptionTriggeringSvc.runDeliveryPass();
mySubscriptionTriggeringSvc.runDeliveryPass(); mySubscriptionTriggeringSvc.runDeliveryPass();
mySubscriptionTriggeringSvc.runDeliveryPass(); mySubscriptionTriggeringSvc.runDeliveryPass();
assertEquals(0, mySubscriptionTriggeringSvc.getActiveJobCount());
assertEquals(0, ourCreatedPatients.size()); assertEquals(0, ourCreatedPatients.size());
assertEquals(ourUpdatedPatients.stream().map(t->t.getId()).collect(Collectors.joining(", ")), 3, ourUpdatedPatients.size()); assertEquals(ourUpdatedPatients.stream().map(t->t.getId()).collect(Collectors.joining(", ")), 3, ourUpdatedPatients.size());