Skip to content

Commit

Permalink
Merge pull request #753 from XcrigX/fix-cds-test-race
Browse files Browse the repository at this point in the history
fix intermittent error with CDS test
  • Loading branch information
dotasek authored Oct 31, 2024
2 parents 48a141b + 85aab81 commit 02e4de7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/test/java/ca/uhn/fhir/jpa/starter/CdsHooksServletIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ void beforeEach() {

private Boolean hasCdsServices() throws IOException {
var response = callCdsServicesDiscovery();
return response.getEntity().getContentLength() > 21 || response.getEntity().isChunked();

// NOTE: this is looking for a repsonse that indicates there are CDS services availalble.
// And empty response looks like: {"services": []}
// Looking at the actual response string consumes the InputStream which has side-effects, making it tricky to compare the actual contents.
// Hence the test just looks at the length to make this determination.
// The actual response has newlines in it which vary in size on some systems, but a value of 25 seems to work across linux/mac/windows
// to ensure the repsonse actually contains CDS services in it
return response.getEntity().getContentLength() > 25 || response.getEntity().isChunked();
}

private CloseableHttpResponse callCdsServicesDiscovery() {
Expand Down

0 comments on commit 02e4de7

Please sign in to comment.