Attempt to fix a weird lucene indexing issue

This commit is contained in:
James Agnew 2019-01-23 16:14:53 -05:00
parent 707bf07099
commit 7d1d5a102c
2 changed files with 31 additions and 4 deletions

View File

@ -211,9 +211,11 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test {
obs.getCode().setText("ZXCVBNM ASDFGHJKL QWERTYUIOPASDFGHJKL"); obs.getCode().setText("ZXCVBNM ASDFGHJKL QWERTYUIOPASDFGHJKL");
myObservationDao.update(obs, mySrd); myObservationDao.update(obs, mySrd);
// Try to wait for the indexing to complete
waitToParamsToIndex(ptId);
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + ptId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml"); HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + ptId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
CloseableHttpResponse http = ourHttpClient.execute(get); try (CloseableHttpResponse http = ourHttpClient.execute(get)) {
try {
assertEquals(200, http.getStatusLine().getStatusCode()); assertEquals(200, http.getStatusLine().getStatusCode());
String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8); String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(output); ourLog.info(output);
@ -225,11 +227,21 @@ public class SystemProviderDstu2Test extends BaseJpaDstu2Test {
assertEquals("score", parameters.getParameter().get(0).getPart().get(1).getName()); assertEquals("score", parameters.getParameter().get(0).getPart().get(1).getName());
assertEquals(new DecimalDt("1.0"), parameters.getParameter().get(0).getPart().get(1).getValue()); assertEquals(new DecimalDt("1.0"), parameters.getParameter().get(0).getPart().get(1).getValue());
} finally {
http.close();
} }
} }
private void waitToParamsToIndex(IIdType thePtId) throws Exception {
waitForSize(2, ()->{
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + thePtId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
try (CloseableHttpResponse http = ourHttpClient.execute(get)) {
assertEquals(200, http.getStatusLine().getStatusCode());
String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8);
Parameters parameters = ourCtx.newXmlParser().parseResource(Parameters.class, output);
return parameters.getParameter().size();
}
});
}
@Test @Test
public void testSuggestKeywordsInvalid() throws Exception { public void testSuggestKeywordsInvalid() throws Exception {
Patient patient = new Patient(); Patient patient = new Patient();

View File

@ -279,6 +279,9 @@ public class SystemProviderR4Test extends BaseJpaR4Test {
obs.getCode().setText("ZXCVBNM ASDFGHJKL QWERTYUIOPASDFGHJKL"); obs.getCode().setText("ZXCVBNM ASDFGHJKL QWERTYUIOPASDFGHJKL");
myObservationDao.update(obs, mySrd); myObservationDao.update(obs, mySrd);
// Try to wait for the indexing to complete
waitForParamsToIndex(ptId);
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + ptId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml"); HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + ptId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
CloseableHttpResponse http = ourHttpClient.execute(get); CloseableHttpResponse http = ourHttpClient.execute(get);
try { try {
@ -298,6 +301,18 @@ public class SystemProviderR4Test extends BaseJpaR4Test {
} }
} }
private void waitForParamsToIndex(IIdType thePtId) throws Exception {
waitForSize(2, ()->{
HttpGet get = new HttpGet(ourServerBase + "/$suggest-keywords?context=Patient/" + thePtId.getIdPart() + "/$everything&searchParam=_content&text=zxc&_pretty=true&_format=xml");
try (CloseableHttpResponse http = ourHttpClient.execute(get)) {
assertEquals(200, http.getStatusLine().getStatusCode());
String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8);
Parameters parameters = ourCtx.newXmlParser().parseResource(Parameters.class, output);
return parameters.getParameter().size();
}
});
}
@Test @Test
public void testSuggestKeywordsInvalid() throws Exception { public void testSuggestKeywordsInvalid() throws Exception {
Patient patient = new Patient(); Patient patient = new Patient();