mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-24 14:58:35 +00:00
Add a bit more logging for occasional failing test
This commit is contained in:
parent
7f87def432
commit
d52c1ed090
@ -609,13 +609,6 @@
|
|||||||
<artifactId>jaxb-impl</artifactId>
|
<artifactId>jaxb-impl</artifactId>
|
||||||
<version>${jaxb_core_version}</version>
|
<version>${jaxb_core_version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.glassfish.jaxb</groupId>
|
|
||||||
<artifactId>jaxb-runtime</artifactId>
|
|
||||||
<version>${jaxb_runtime_version}</version>
|
|
||||||
</dependency>
|
|
||||||
-->
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.dao;
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.dao;
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@ -87,6 +87,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchBuilder.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchBuilder.class);
|
||||||
private static Long NO_MORE = -1L;
|
private static Long NO_MORE = -1L;
|
||||||
private static HandlerTypeEnum ourLastHandlerMechanismForUnitTest;
|
private static HandlerTypeEnum ourLastHandlerMechanismForUnitTest;
|
||||||
|
private static SearchParameterMap ourLastHandlerParamsForUnitTest;
|
||||||
private List<Long> myAlsoIncludePids;
|
private List<Long> myAlsoIncludePids;
|
||||||
private CriteriaBuilder myBuilder;
|
private CriteriaBuilder myBuilder;
|
||||||
private BaseHapiFhirDao<?> myCallingDao;
|
private BaseHapiFhirDao<?> myCallingDao;
|
||||||
@ -1017,6 +1018,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||||||
num = builder.or(lowPred, highPred);
|
num = builder.or(lowPred, highPred);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ENDS_BEFORE:
|
||||||
|
case STARTS_AFTER:
|
||||||
default:
|
default:
|
||||||
String msg = myContext.getLocalizer().getMessage(SearchBuilder.class, invalidMessageName, thePrefix.getValue(), theParam.getValueAsQueryToken(myContext));
|
String msg = myContext.getLocalizer().getMessage(SearchBuilder.class, invalidMessageName, thePrefix.getValue(), theParam.getValueAsQueryToken(myContext));
|
||||||
throw new InvalidRequestException(msg);
|
throw new InvalidRequestException(msg);
|
||||||
@ -1302,6 +1305,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Set<String> uniqueQueryStrings = BaseHapiFhirDao.extractCompositeStringUniquesValueChains(myResourceName, params);
|
Set<String> uniqueQueryStrings = BaseHapiFhirDao.extractCompositeStringUniquesValueChains(myResourceName, params);
|
||||||
|
ourLastHandlerParamsForUnitTest = theParams;
|
||||||
ourLastHandlerMechanismForUnitTest = HandlerTypeEnum.UNIQUE_INDEX;
|
ourLastHandlerMechanismForUnitTest = HandlerTypeEnum.UNIQUE_INDEX;
|
||||||
return new UniqueIndexIterator(uniqueQueryStrings);
|
return new UniqueIndexIterator(uniqueQueryStrings);
|
||||||
|
|
||||||
@ -1313,6 +1317,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ourLastHandlerParamsForUnitTest = theParams;
|
||||||
ourLastHandlerMechanismForUnitTest = HandlerTypeEnum.STANDARD_QUERY;
|
ourLastHandlerMechanismForUnitTest = HandlerTypeEnum.STANDARD_QUERY;
|
||||||
return new QueryIterator();
|
return new QueryIterator();
|
||||||
}
|
}
|
||||||
@ -1526,6 +1531,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||||||
sortAttrName = new String[] {"myValue"};
|
sortAttrName = new String[] {"myValue"};
|
||||||
joinType = JoinEnum.QUANTITY;
|
joinType = JoinEnum.QUANTITY;
|
||||||
break;
|
break;
|
||||||
|
case COMPOSITE:
|
||||||
|
case HAS:
|
||||||
default:
|
default:
|
||||||
throw new InvalidRequestException("This server does not support _sort specifications of type " + param.getParamType() + " - Can't serve _sort=" + theSort.getParamName());
|
throw new InvalidRequestException("This server does not support _sort specifications of type " + param.getParamType() + " - Can't serve _sort=" + theSort.getParamName());
|
||||||
}
|
}
|
||||||
@ -1698,7 +1705,6 @@ public class SearchBuilder implements ISearchBuilder {
|
|||||||
roundCounts++;
|
roundCounts++;
|
||||||
|
|
||||||
HashSet<Long> pidsToInclude = new HashSet<>();
|
HashSet<Long> pidsToInclude = new HashSet<>();
|
||||||
Set<Long> nextRoundOmit = new HashSet<>();
|
|
||||||
|
|
||||||
for (Iterator<Include> iter = includes.iterator(); iter.hasNext(); ) {
|
for (Iterator<Include> iter = includes.iterator(); iter.hasNext(); ) {
|
||||||
Include nextInclude = iter.next();
|
Include nextInclude = iter.next();
|
||||||
@ -1793,8 +1799,6 @@ public class SearchBuilder implements ISearchBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pidsToInclude.removeAll(nextRoundOmit);
|
|
||||||
|
|
||||||
addedSomeThisRound = allAdded.addAll(pidsToInclude);
|
addedSomeThisRound = allAdded.addAll(pidsToInclude);
|
||||||
nextRoundMatches = pidsToInclude;
|
nextRoundMatches = pidsToInclude;
|
||||||
} while (includes.size() > 0 && nextRoundMatches.size() > 0 && addedSomeThisRound);
|
} while (includes.size() > 0 && nextRoundMatches.size() > 0 && addedSomeThisRound);
|
||||||
@ -1970,6 +1974,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||||||
case REFERENCE:
|
case REFERENCE:
|
||||||
qp = new ReferenceParam();
|
qp = new ReferenceParam();
|
||||||
break;
|
break;
|
||||||
|
case URI:
|
||||||
|
case HAS:
|
||||||
default:
|
default:
|
||||||
throw new InternalErrorException("Don't know how to convert param type: " + theParam.getParamType());
|
throw new InternalErrorException("Don't know how to convert param type: " + theParam.getParamType());
|
||||||
}
|
}
|
||||||
@ -2068,14 +2074,18 @@ public class SearchBuilder implements ISearchBuilder {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static HandlerTypeEnum getLastHandlerMechanismForUnitTest() {
|
public static HandlerTypeEnum getLastHandlerMechanismForUnitTest() {
|
||||||
ourLog.info("Retrieving last handler mechanism: {}", ourLastHandlerMechanismForUnitTest);
|
|
||||||
return ourLastHandlerMechanismForUnitTest;
|
return ourLastHandlerMechanismForUnitTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public static SearchParameterMap getLastHandlerParamsForUnitTest() {
|
||||||
|
return ourLastHandlerParamsForUnitTest;
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static void resetLastHandlerMechanismForUnitTest() {
|
public static void resetLastHandlerMechanismForUnitTest() {
|
||||||
ourLog.info("Clearing last handler mechanism (was {})", ourLastHandlerMechanismForUnitTest);
|
|
||||||
ourLastHandlerMechanismForUnitTest = null;
|
ourLastHandlerMechanismForUnitTest = null;
|
||||||
|
ourLastHandlerParamsForUnitTest = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Predicate[] toArray(List<Predicate> thePredicates) {
|
static Predicate[] toArray(List<Predicate> thePredicates) {
|
||||||
|
@ -75,13 +75,13 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||||||
mySearchEntity = null;
|
mySearchEntity = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<IBaseResource> doHistoryInTransaction(int theFromIndex, int theToIndex) {
|
private List<IBaseResource> doHistoryInTransaction(int theFromIndex, int theToIndex) {
|
||||||
List<ResourceHistoryTable> results;
|
List<ResourceHistoryTable> results;
|
||||||
|
|
||||||
CriteriaBuilder cb = myEntityManager.getCriteriaBuilder();
|
CriteriaBuilder cb = myEntityManager.getCriteriaBuilder();
|
||||||
CriteriaQuery<ResourceHistoryTable> q = cb.createQuery(ResourceHistoryTable.class);
|
CriteriaQuery<ResourceHistoryTable> q = cb.createQuery(ResourceHistoryTable.class);
|
||||||
Root<ResourceHistoryTable> from = q.from(ResourceHistoryTable.class);
|
Root<ResourceHistoryTable> from = q.from(ResourceHistoryTable.class);
|
||||||
List<Predicate> predicates = new ArrayList<Predicate>();
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
|
||||||
if (mySearchEntity.getResourceType() == null) {
|
if (mySearchEntity.getResourceType() == null) {
|
||||||
// All resource types
|
// All resource types
|
||||||
@ -215,6 +215,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
return myUuid;
|
return myUuid;
|
||||||
}
|
}
|
||||||
@ -223,7 +224,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||||||
return myCacheHit;
|
return myCacheHit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCacheHit(boolean theCacheHit) {
|
void setCacheHit(boolean theCacheHit) {
|
||||||
myCacheHit = theCacheHit;
|
myCacheHit = theCacheHit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +254,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||||||
mySearchDao = theSearchDao;
|
mySearchDao = theSearchDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setSearchEntity(Search theSearchEntity) {
|
void setSearchEntity(Search theSearchEntity) {
|
||||||
mySearchEntity = theSearchEntity;
|
mySearchEntity = theSearchEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,8 +270,8 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||||||
return Math.max(0, size);
|
return Math.max(0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<IBaseResource> toResourceList(ISearchBuilder sb, List<Long> pidsSubList) {
|
List<IBaseResource> toResourceList(ISearchBuilder sb, List<Long> pidsSubList) {
|
||||||
Set<Long> includedPids = new HashSet<Long>();
|
Set<Long> includedPids = new HashSet<>();
|
||||||
if (mySearchEntity.getSearchType() == SearchTypeEnum.SEARCH) {
|
if (mySearchEntity.getSearchType() == SearchTypeEnum.SEARCH) {
|
||||||
includedPids.addAll(sb.loadReverseIncludes(myDao, myContext, myEntityManager, pidsSubList, mySearchEntity.toRevIncludesList(), true, mySearchEntity.getLastUpdated()));
|
includedPids.addAll(sb.loadReverseIncludes(myDao, myContext, myEntityManager, pidsSubList, mySearchEntity.toRevIncludesList(), true, mySearchEntity.getLastUpdated()));
|
||||||
includedPids.addAll(sb.loadReverseIncludes(myDao, myContext, myEntityManager, pidsSubList, mySearchEntity.toIncludesList(), false, mySearchEntity.getLastUpdated()));
|
includedPids.addAll(sb.loadReverseIncludes(myDao, myContext, myEntityManager, pidsSubList, mySearchEntity.toIncludesList(), false, mySearchEntity.getLastUpdated()));
|
||||||
|
@ -752,7 +752,7 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||||||
params.add("birthdate", new DateParam("2011-01-01"));
|
params.add("birthdate", new DateParam("2011-01-01"));
|
||||||
IBundleProvider results = myPatientDao.search(params);
|
IBundleProvider results = myPatientDao.search(params);
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(results), containsInAnyOrder(id1.getValue()));
|
assertThat(toUnqualifiedVersionlessIdValues(results), containsInAnyOrder(id1.getValue()));
|
||||||
assertEquals(SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -777,7 +777,7 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||||||
IBundleProvider results = myPatientDao.search(params);
|
IBundleProvider results = myPatientDao.search(params);
|
||||||
String searchId = results.getUuid();
|
String searchId = results.getUuid();
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(results), containsInAnyOrder(id1));
|
assertThat(toUnqualifiedVersionlessIdValues(results), containsInAnyOrder(id1));
|
||||||
assertEquals(SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||||
|
|
||||||
// Other order
|
// Other order
|
||||||
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
||||||
@ -796,14 +796,14 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||||||
params.add("birthdate", new DateParam("2011-01-03"));
|
params.add("birthdate", new DateParam("2011-01-03"));
|
||||||
results = myPatientDao.search(params);
|
results = myPatientDao.search(params);
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(results), empty());
|
assertThat(toUnqualifiedVersionlessIdValues(results), empty());
|
||||||
assertEquals(SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||||
|
|
||||||
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
||||||
params = new SearchParameterMap();
|
params = new SearchParameterMap();
|
||||||
params.add("birthdate", new DateParam("2011-01-03"));
|
params.add("birthdate", new DateParam("2011-01-03"));
|
||||||
results = myPatientDao.search(params);
|
results = myPatientDao.search(params);
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(results), empty());
|
assertThat(toUnqualifiedVersionlessIdValues(results), empty());
|
||||||
assertEquals(SearchBuilder.HandlerTypeEnum.STANDARD_QUERY, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.STANDARD_QUERY, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -869,7 +869,7 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||||||
|
|
||||||
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
||||||
IIdType id1 = myPatientDao.update(pt1, "Patient?name=FAMILY1&organization:Organization=ORG").getId().toUnqualifiedVersionless();
|
IIdType id1 = myPatientDao.update(pt1, "Patient?name=FAMILY1&organization:Organization=ORG").getId().toUnqualifiedVersionless();
|
||||||
assertEquals(SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||||
uniques = myResourceIndexedCompositeStringUniqueDao.findAll();
|
uniques = myResourceIndexedCompositeStringUniqueDao.findAll();
|
||||||
assertEquals(1, uniques.size());
|
assertEquals(1, uniques.size());
|
||||||
assertEquals("Patient/" + id1.getIdPart(), uniques.get(0).getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
assertEquals("Patient/" + id1.getIdPart(), uniques.get(0).getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
||||||
@ -883,7 +883,7 @@ public class FhirResourceDaoR4UniqueSearchParamTest extends BaseJpaR4Test {
|
|||||||
|
|
||||||
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
SearchBuilder.resetLastHandlerMechanismForUnitTest();
|
||||||
id1 = myPatientDao.update(pt1, "Patient?name=FAMILY1&organization:Organization=ORG").getId().toUnqualifiedVersionless();
|
id1 = myPatientDao.update(pt1, "Patient?name=FAMILY1&organization:Organization=ORG").getId().toUnqualifiedVersionless();
|
||||||
assertEquals(SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
assertEquals(SearchBuilder.getLastHandlerParamsForUnitTest().toString(), SearchBuilder.HandlerTypeEnum.UNIQUE_INDEX, SearchBuilder.getLastHandlerMechanismForUnitTest());
|
||||||
uniques = myResourceIndexedCompositeStringUniqueDao.findAll();
|
uniques = myResourceIndexedCompositeStringUniqueDao.findAll();
|
||||||
assertEquals(1, uniques.size());
|
assertEquals(1, uniques.size());
|
||||||
assertEquals("Patient/" + id1.getIdPart(), uniques.get(0).getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
assertEquals("Patient/" + id1.getIdPart(), uniques.get(0).getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user