Skip to content

Commit

Permalink
Attempt to fix a weird lucene indexing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesagnew committed Jan 23, 2019
1 parent 707bf07 commit 7d1d5a1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,11 @@ public void testSuggestKeywords() throws Exception {
obs.getCode().setText("ZXCVBNM ASDFGHJKL QWERTYUIOPASDFGHJKL");
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");
CloseableHttpResponse http = ourHttpClient.execute(get);
try {
try (CloseableHttpResponse http = ourHttpClient.execute(get)) {
assertEquals(200, http.getStatusLine().getStatusCode());
String output = IOUtils.toString(http.getEntity().getContent(), StandardCharsets.UTF_8);
ourLog.info(output);
Expand All @@ -225,11 +227,21 @@ public void testSuggestKeywords() throws Exception {
assertEquals("score", parameters.getParameter().get(0).getPart().get(1).getName());
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
public void testSuggestKeywordsInvalid() throws Exception {
Patient patient = new Patient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ public void testSuggestKeywords() throws Exception {
obs.getCode().setText("ZXCVBNM ASDFGHJKL QWERTYUIOPASDFGHJKL");
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");
CloseableHttpResponse http = ourHttpClient.execute(get);
try {
Expand All @@ -298,6 +301,18 @@ public void testSuggestKeywords() throws Exception {
}
}

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
public void testSuggestKeywordsInvalid() throws Exception {
Patient patient = new Patient();
Expand Down

0 comments on commit 7d1d5a1

Please sign in to comment.