Simplify JPA Elasticsearch Test Configuration (#3345)
* Delete TestR4WithLuceneDisabledConfig * Split off the ES and ESClient test configs * move hibernate search config out to add-ins * Use addIn for all R4 * Finish R4 * Finish R3 * Finish dstu2 * R5 * Remove property override, and docs * Apply error code to error * Fix test to match new error code * Lighten test * Disabling broken test.
This commit is contained in:
parent
c42ecc5c08
commit
717ff71695
|
@ -25,7 +25,7 @@ public final class Msg {
|
|||
|
||||
/**
|
||||
* IMPORTANT: Please update the following comment after you add a new code
|
||||
* Last code value: 2018
|
||||
* Last code value: 2019
|
||||
*/
|
||||
|
||||
private Msg() {}
|
||||
|
|
|
@ -524,7 +524,8 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
|
|||
.map(Throwable::getMessage)
|
||||
.collect(Collectors.joining(", "));
|
||||
throw new InternalErrorException(
|
||||
"Tag get/create failed after "
|
||||
Msg.code(2019) +
|
||||
"Tag get/create failed after "
|
||||
+ TOTAL_TAG_READ_ATTEMPTS
|
||||
+ " attempts with error(s): "
|
||||
+ msg
|
||||
|
|
|
@ -750,7 +750,7 @@ public class ElasticsearchSvcImpl implements IElasticsearchSvc {
|
|||
public List<IBaseResource> getObservationResources(Collection<ResourcePersistentId> thePids) {
|
||||
SearchRequest searchRequest = buildObservationResourceSearchRequest(thePids);
|
||||
try {
|
||||
// wip mb what is the limit to an ES hit count? 10k? We may need to chunk this :-(
|
||||
// wipmb what is the limit to an ES hit count? 10k? We may need to chunk this :-(
|
||||
SearchResponse observationDocumentResponse = executeSearchRequest(searchRequest);
|
||||
SearchHit[] observationDocumentHits = observationDocumentResponse.getHits().getHits();
|
||||
IParser parser = TolerantJsonParser.createWithLenientErrorHandling(myContext, null);
|
||||
|
@ -759,16 +759,16 @@ public class ElasticsearchSvcImpl implements IElasticsearchSvc {
|
|||
* @see ca.uhn.fhir.jpa.dao.BaseHapiFhirDao#toResource(Class, IBaseResourceEntity, Collection, boolean) for
|
||||
* details about parsing raw json to BaseResource
|
||||
*/
|
||||
// WIP what do we do with partition?
|
||||
// WIP what do we do with deleted observation resources
|
||||
// WIP how do you handle provenance?
|
||||
// wipmb what do we do with partition?
|
||||
// wipmb what do we do with deleted observation resources
|
||||
// wipmb how do you handle provenance?
|
||||
// Parse using tolerant parser
|
||||
return Arrays.stream(observationDocumentHits)
|
||||
.map(this::parseObservationJson)
|
||||
.map(observationJson -> parser.parseResource(resourceType, observationJson.getResource()))
|
||||
.collect(Collectors.toList());
|
||||
} catch (IOException theE) {
|
||||
// WIP do we fallback to JPA search then?
|
||||
// wipmb do we fallback to JPA search then?
|
||||
throw new InvalidRequestException(Msg.code(2003) + "Unable to execute observation document query for provided IDs " + thePids, theE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ca.uhn.fhir.jpa.config;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener;
|
||||
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
|
||||
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||
|
@ -12,6 +11,7 @@ import org.apache.commons.dbcp2.BasicDataSource;
|
|||
import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
@ -23,14 +23,13 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Configuration
|
||||
@Import(TestJPAConfig.class)
|
||||
@Import({TestJPAConfig.class, TestHibernateSearchAddInConfig.DefaultLuceneHeap.class})
|
||||
@EnableTransactionManagement()
|
||||
public class TestDstu2Config extends BaseJavaConfigDstu2 {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(TestDstu2Config.class);
|
||||
|
@ -145,6 +144,9 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
|
|||
return ourMaxThreads;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
TestHibernateSearchAddInConfig.IHibernateSearchConfigurer hibernateSearchConfigurer;
|
||||
|
||||
private Properties jpaProperties() {
|
||||
Properties extraProperties = new Properties();
|
||||
extraProperties.put("hibernate.format_sql", "true");
|
||||
|
@ -152,9 +154,9 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
|
|||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||
extraProperties.put("hibernate.dialect", HapiFhirH2Dialect.class.getName());
|
||||
|
||||
boolean enableLucene = myEnv.getProperty(BaseJpaTest.CONFIG_ENABLE_LUCENE, Boolean.TYPE, BaseJpaTest.CONFIG_ENABLE_LUCENE_DEFAULT_VALUE);
|
||||
Map<String, String> hibernateSearchProperties = BaseJpaTest.buildHibernateSearchProperties(enableLucene);
|
||||
extraProperties.putAll(hibernateSearchProperties);
|
||||
hibernateSearchConfigurer.apply(extraProperties);
|
||||
|
||||
ourLog.info("jpaProperties: {}", extraProperties);
|
||||
|
||||
return extraProperties;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package ca.uhn.fhir.jpa.config;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.subscription.match.deliver.email.EmailSenderImpl;
|
||||
import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender;
|
||||
import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener;
|
||||
|
@ -13,6 +12,7 @@ import ca.uhn.fhir.validation.ResultSeverityEnum;
|
|||
import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
@ -25,14 +25,13 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Configuration
|
||||
@Import(TestJPAConfig.class)
|
||||
@Import({TestJPAConfig.class, TestHibernateSearchAddInConfig.DefaultLuceneHeap.class})
|
||||
@EnableTransactionManagement()
|
||||
public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
||||
|
||||
|
@ -150,6 +149,9 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
TestHibernateSearchAddInConfig.IHibernateSearchConfigurer hibernateSearchConfigurer;
|
||||
|
||||
private Properties jpaProperties() {
|
||||
Properties extraProperties = new Properties();
|
||||
extraProperties.put("hibernate.jdbc.batch_size", "50");
|
||||
|
@ -158,9 +160,9 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
|||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||
extraProperties.put("hibernate.dialect", HapiFhirH2Dialect.class.getName());
|
||||
|
||||
boolean enableLucene = myEnv.getProperty(BaseJpaTest.CONFIG_ENABLE_LUCENE, Boolean.TYPE, BaseJpaTest.CONFIG_ENABLE_LUCENE_DEFAULT_VALUE);
|
||||
Map<String, String> hibernateSearchProperties = BaseJpaTest.buildHibernateSearchProperties(enableLucene);
|
||||
extraProperties.putAll(hibernateSearchProperties);
|
||||
hibernateSearchConfigurer.apply(extraProperties);
|
||||
|
||||
ourLog.info("jpaProperties: {}", extraProperties);
|
||||
|
||||
return extraProperties;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
package ca.uhn.fhir.jpa.config;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl;
|
||||
import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer;
|
||||
import ca.uhn.fhir.jpa.search.elastic.ElasticsearchHibernatePropertiesBuilder;
|
||||
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
||||
import ca.uhn.fhir.jpa.search.lastn.config.TestElasticsearchContainerHelper;
|
||||
import ca.uhn.fhir.test.utilities.docker.RequiresDocker;
|
||||
import org.hibernate.search.backend.elasticsearch.index.IndexStatus;
|
||||
import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings;
|
||||
import org.hibernate.search.backend.lucene.cfg.LuceneIndexSettings;
|
||||
import org.hibernate.search.engine.cfg.BackendSettings;
|
||||
import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
|
||||
import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.testcontainers.elasticsearch.ElasticsearchContainer;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Configurations for Hibernate Search: off, lucene, or elastic.
|
||||
*
|
||||
* We use {@link DefaultLuceneHeap} by default in our JPA test configs.
|
||||
* Turn off by adding {@link NoFT} to the test Contexts.
|
||||
* Use Elasticsearch instead via docker by adding {@link Elasticsearch} to the test Contexts;
|
||||
*/
|
||||
public class TestHibernateSearchAddInConfig {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(TestHibernateSearchAddInConfig.class);
|
||||
|
||||
/**
|
||||
* Add Hibernate Search config to JPA properties.
|
||||
*/
|
||||
public interface IHibernateSearchConfigurer {
|
||||
void apply(Properties theJPAProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Our default config - Lucene in-memory.
|
||||
*
|
||||
* Override by adding {@link NoFT} or {@link Elasticsearch} to your test class contexts.
|
||||
*/
|
||||
@Configuration
|
||||
public static class DefaultLuceneHeap {
|
||||
|
||||
@Bean
|
||||
IHibernateSearchConfigurer hibernateSearchConfigurer() {
|
||||
ourLog.warn("Hibernate Search: using lucene - local-heap");
|
||||
|
||||
Map<String, String> luceneHeapProperties = new HashMap<>();
|
||||
luceneHeapProperties.put(BackendSettings.backendKey(BackendSettings.TYPE), "lucene");
|
||||
luceneHeapProperties.put(BackendSettings.backendKey(LuceneBackendSettings.ANALYSIS_CONFIGURER), HapiLuceneAnalysisConfigurer.class.getName());
|
||||
luceneHeapProperties.put(BackendSettings.backendKey(LuceneIndexSettings.DIRECTORY_TYPE), "local-heap");
|
||||
luceneHeapProperties.put(BackendSettings.backendKey(LuceneBackendSettings.LUCENE_VERSION), "LUCENE_CURRENT");
|
||||
luceneHeapProperties.put(HibernateOrmMapperSettings.ENABLED, "true");
|
||||
|
||||
return (theProperties) ->
|
||||
theProperties.putAll(luceneHeapProperties);
|
||||
}
|
||||
|
||||
|
||||
@Bean(name={"searchDao", "searchDaoDstu2", "searchDaoDstu3", "searchDaoR4", "searchDaoR5"})
|
||||
public IFulltextSearchSvc searchDao() {
|
||||
ourLog.info("Hibernate Search: FulltextSearchSvcImpl present");
|
||||
return new FulltextSearchSvcImpl();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable Hibernate Search, and do not provide a IFulltextSearchSvc bean.
|
||||
*/
|
||||
@Configuration
|
||||
public static class NoFT {
|
||||
@Bean
|
||||
IHibernateSearchConfigurer hibernateSearchConfigurer() {
|
||||
ourLog.info("Hibernate Search is disabled");
|
||||
return (theProperties) -> {
|
||||
theProperties.put("hibernate.search.enabled", "false");
|
||||
};
|
||||
}
|
||||
|
||||
@Primary // force override of default bean which might have a variety of names
|
||||
@Bean(name={"searchDao", "searchDaoDstu2", "searchDaoDstu3", "searchDaoR4", "searchDaoR5"})
|
||||
public IFulltextSearchSvc searchDao() {
|
||||
ourLog.info("Hibernate Search: FulltextSearchSvcImpl not available");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable our Fulltext search with an Elasticsearch container instead of our default Lucene heap.
|
||||
*
|
||||
* Make sure you add {@link RequiresDocker} annotation to any uses.
|
||||
*/
|
||||
@Configuration
|
||||
public static class Elasticsearch {
|
||||
@Bean
|
||||
@Primary // override the default
|
||||
IHibernateSearchConfigurer hibernateSearchConfigurer(ElasticsearchContainer theContainer) {
|
||||
return (theProperties) -> {
|
||||
int httpPort = theContainer.getMappedPort(9200);//9200 is the HTTP port
|
||||
String host = theContainer.getHost();
|
||||
|
||||
ourLog.info("Hibernate Search: using elasticsearch - host {} {}", host, httpPort);
|
||||
|
||||
new ElasticsearchHibernatePropertiesBuilder()
|
||||
.setDebugIndexSyncStrategy("read-sync")
|
||||
.setDebugPrettyPrintJsonLog(true)
|
||||
.setIndexSchemaManagementStrategy(SchemaManagementStrategyName.CREATE)
|
||||
.setIndexManagementWaitTimeoutMillis(10000)
|
||||
.setRequiredIndexStatus(IndexStatus.YELLOW)
|
||||
.setHosts(host + ":" + httpPort)
|
||||
.setProtocol("http")
|
||||
.setUsername("")
|
||||
.setPassword("")
|
||||
.apply(theProperties);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public ElasticsearchContainer elasticContainer() {
|
||||
ElasticsearchContainer embeddedElasticSearch = TestElasticsearchContainerHelper.getEmbeddedElasticSearch();
|
||||
embeddedElasticSearch.start();
|
||||
return embeddedElasticSearch;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void stop() {
|
||||
elasticContainer().stop();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PartitionSettings partitionSettings() {
|
||||
return new PartitionSettings();
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public ElasticsearchSvcImpl myElasticsearchSvc() {
|
||||
int elasticsearchPort = elasticContainer().getMappedPort(9200);
|
||||
String host = elasticContainer().getHost();
|
||||
return new ElasticsearchSvcImpl("http", host + ":" + elasticsearchPort, null, null);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void stopEsClient() throws IOException {
|
||||
myElasticsearchSvc().close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter;
|
|||
import ca.uhn.fhir.jpa.batch.svc.BatchJobSubmitterImpl;
|
||||
import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc;
|
||||
import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect;
|
||||
import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener;
|
||||
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
|
||||
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||
|
@ -14,8 +14,8 @@ import net.ttddyy.dsproxy.listener.SingleQueryCountHolder;
|
|||
import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel;
|
||||
import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect;
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
@ -26,14 +26,13 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Configuration
|
||||
@Import({TestJPAConfig.class, BatchJobsConfig.class})
|
||||
@Import({TestJPAConfig.class, BatchJobsConfig.class, TestHibernateSearchAddInConfig.DefaultLuceneHeap.class})
|
||||
@EnableTransactionManagement()
|
||||
public class TestR4Config extends BaseJavaConfigR4 {
|
||||
|
||||
|
@ -159,17 +158,19 @@ public class TestR4Config extends BaseJavaConfigR4 {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Properties jpaProperties() {
|
||||
@Autowired
|
||||
TestHibernateSearchAddInConfig.IHibernateSearchConfigurer hibernateSearchConfigurer;
|
||||
|
||||
private Properties jpaProperties() {
|
||||
Properties extraProperties = new Properties();
|
||||
extraProperties.put("hibernate.format_sql", "false");
|
||||
extraProperties.put("hibernate.show_sql", "false");
|
||||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||
extraProperties.put("hibernate.dialect", HapiFhirH2Dialect.class.getName());
|
||||
|
||||
boolean enableLucene = myEnv.getProperty(BaseJpaTest.CONFIG_ENABLE_LUCENE, Boolean.TYPE, BaseJpaTest.CONFIG_ENABLE_LUCENE_DEFAULT_VALUE);
|
||||
Map<String, String> hibernateSearchProperties = BaseJpaTest.buildHibernateSearchProperties(enableLucene);
|
||||
extraProperties.putAll(hibernateSearchProperties);
|
||||
hibernateSearchConfigurer.apply(extraProperties);
|
||||
|
||||
ourLog.info("jpaProperties: {}", extraProperties);
|
||||
|
||||
return extraProperties;
|
||||
}
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.config;
|
||||
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.search.elastic.ElasticsearchHibernatePropertiesBuilder;
|
||||
import ca.uhn.fhir.jpa.search.elastic.IndexNamePrefixLayoutStrategy;
|
||||
import ca.uhn.fhir.jpa.search.lastn.config.TestElasticsearchContainerHelper;
|
||||
import org.h2.index.Index;
|
||||
import org.hibernate.search.backend.elasticsearch.index.IndexStatus;
|
||||
import org.hibernate.search.backend.elasticsearch.index.layout.IndexLayoutStrategy;
|
||||
import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.testcontainers.elasticsearch.ElasticsearchContainer;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class TestR4ConfigWithElasticSearch extends TestR4Config {
|
||||
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(TestR4ConfigWithElasticSearch.class);
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public Properties jpaProperties() {
|
||||
Properties retVal = super.jpaProperties();
|
||||
|
||||
//Override default lucene settings
|
||||
// Force elasticsearch to start first
|
||||
int httpPort = elasticContainer().getMappedPort(9200);//9200 is the HTTP port
|
||||
String host = elasticContainer().getHost();
|
||||
|
||||
ourLog.info("Hibernate Search: using elasticsearch - host {} {}", host, httpPort);
|
||||
|
||||
new ElasticsearchHibernatePropertiesBuilder()
|
||||
.setDebugIndexSyncStrategy("read-sync")
|
||||
.setDebugPrettyPrintJsonLog(true)
|
||||
.setIndexSchemaManagementStrategy(SchemaManagementStrategyName.CREATE)
|
||||
.setIndexManagementWaitTimeoutMillis(10000)
|
||||
.setRequiredIndexStatus(IndexStatus.YELLOW)
|
||||
.setHosts(host + ":" + httpPort)
|
||||
.setProtocol("http")
|
||||
.setUsername("")
|
||||
.setPassword("")
|
||||
.apply(retVal);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ElasticsearchContainer elasticContainer() {
|
||||
ElasticsearchContainer embeddedElasticSearch = TestElasticsearchContainerHelper.getEmbeddedElasticSearch();
|
||||
embeddedElasticSearch.start();
|
||||
return embeddedElasticSearch;
|
||||
}
|
||||
|
||||
|
||||
@PreDestroy
|
||||
public void stop() {
|
||||
elasticContainer().stop();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.config;
|
||||
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.io.IOException;
|
||||
|
||||
@Configuration
|
||||
public class TestR4ConfigWithElasticsearchClient extends TestR4ConfigWithElasticSearch {
|
||||
|
||||
|
||||
@Bean
|
||||
public PartitionSettings partitionSettings() {
|
||||
return new PartitionSettings();
|
||||
}
|
||||
|
||||
@Bean()
|
||||
public ElasticsearchSvcImpl myElasticsearchSvc() {
|
||||
int elasticsearchPort = elasticContainer().getMappedPort(9200);
|
||||
String host = elasticContainer().getHost();
|
||||
return new ElasticsearchSvcImpl("http", host + ":" + elasticsearchPort, null, null);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void stopEsClient() throws IOException {
|
||||
myElasticsearchSvc().close();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.config;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import ca.uhn.fhir.jpa.model.dialect.HapiFhirH2Dialect;
|
||||
import org.hibernate.search.backend.elasticsearch.index.layout.IndexLayoutStrategy;
|
||||
import org.hibernate.search.backend.lucene.cfg.LuceneBackendSettings;
|
||||
import org.hibernate.search.engine.cfg.BackendSettings;
|
||||
import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
|
||||
|
||||
@Configuration
|
||||
@EnableTransactionManagement()
|
||||
public class TestR4WithLuceneDisabledConfig extends TestR4Config {
|
||||
|
||||
/**
|
||||
* Disable fulltext searching
|
||||
*/
|
||||
@Override
|
||||
public IFulltextSearchSvc searchDaoR4() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory(ConfigurableListableBeanFactory theConfigurableListableBeanFactory) {
|
||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory(theConfigurableListableBeanFactory);
|
||||
retVal.setDataSource(dataSource());
|
||||
retVal.setJpaProperties(jpaProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties jpaProperties() {
|
||||
Properties extraProperties = new Properties();
|
||||
extraProperties.put("hibernate.format_sql", "false");
|
||||
extraProperties.put("hibernate.show_sql", "false");
|
||||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||
extraProperties.put("hibernate.dialect", HapiFhirH2Dialect.class.getName());
|
||||
extraProperties.put(HibernateOrmMapperSettings.ENABLED, "false");
|
||||
return extraProperties;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.config;
|
|||
|
||||
import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc;
|
||||
import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener;
|
||||
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
|
||||
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
|
||||
|
@ -23,14 +22,12 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import static ca.uhn.fhir.jpa.dao.BaseJpaTest.buildHeapLuceneHibernateSearchProperties;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@Configuration
|
||||
@Import(TestJPAConfig.class)
|
||||
@Import({TestJPAConfig.class, TestHibernateSearchAddInConfig.DefaultLuceneHeap.class})
|
||||
@EnableTransactionManagement()
|
||||
public class TestR5Config extends BaseJavaConfigR5 {
|
||||
|
||||
|
@ -147,6 +144,9 @@ public class TestR5Config extends BaseJavaConfigR5 {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
TestHibernateSearchAddInConfig.IHibernateSearchConfigurer hibernateSearchConfigurer;
|
||||
|
||||
private Properties jpaProperties() {
|
||||
Properties extraProperties = new Properties();
|
||||
extraProperties.put("hibernate.format_sql", "false");
|
||||
|
@ -154,9 +154,9 @@ public class TestR5Config extends BaseJavaConfigR5 {
|
|||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||
extraProperties.put("hibernate.dialect", HapiFhirH2Dialect.class.getName());
|
||||
|
||||
boolean enableLucene = myEnv.getProperty(BaseJpaTest.CONFIG_ENABLE_LUCENE, Boolean.TYPE, BaseJpaTest.CONFIG_ENABLE_LUCENE_DEFAULT_VALUE);
|
||||
Map<String, String> hibernateSearchProperties = BaseJpaTest.buildHibernateSearchProperties(enableLucene);
|
||||
extraProperties.putAll(hibernateSearchProperties);
|
||||
hibernateSearchConfigurer.apply(extraProperties);
|
||||
|
||||
ourLog.info("jpaProperties: {}", extraProperties);
|
||||
|
||||
return extraProperties;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
@ -148,6 +149,7 @@ public class BaseHapiFhirDaoTest {
|
|||
return from;
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
public void getTagOrNull_raceCondition_wontUpsertDuplicates() throws InterruptedException, ExecutionException {
|
||||
/*
|
||||
|
@ -365,7 +367,7 @@ public class BaseHapiFhirDaoTest {
|
|||
fail();
|
||||
} catch (Exception ex) {
|
||||
// verify
|
||||
assertEquals("Tag get/create failed after 10 attempts with error(s): " + exMsg, ex.getMessage());
|
||||
assertEquals("HAPI-2019: Tag get/create failed after 10 attempts with error(s): " + exMsg, ex.getMessage());
|
||||
|
||||
ArgumentCaptor<ILoggingEvent> appenderCaptor = ArgumentCaptor.forClass(ILoggingEvent.class);
|
||||
verify(myAppender, Mockito.times(10))
|
||||
|
|
|
@ -130,9 +130,6 @@ import static org.mockito.Mockito.when;
|
|||
UnregisterScheduledProcessor.SCHEDULING_DISABLED_EQUALS_TRUE
|
||||
})
|
||||
public abstract class BaseJpaTest extends BaseTest {
|
||||
public static final String CONFIG_ENABLE_LUCENE="hapi_test.enable_lucene";
|
||||
public static final String CONFIG_ENABLE_LUCENE_FALSE = CONFIG_ENABLE_LUCENE + "=false";
|
||||
public static final boolean CONFIG_ENABLE_LUCENE_DEFAULT_VALUE = true;
|
||||
|
||||
protected static final String CM_URL = "http://example.com/my_concept_map";
|
||||
protected static final String CS_URL = "http://example.com/my_code_system";
|
||||
|
@ -652,31 +649,6 @@ public abstract class BaseJpaTest extends BaseTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Map<String, String> buildHibernateSearchProperties(boolean enableLucene) {
|
||||
Map<String, String> hibernateSearchProperties;
|
||||
if (enableLucene) {
|
||||
ourLog.info("Hibernate Search is enabled");
|
||||
hibernateSearchProperties = buildHeapLuceneHibernateSearchProperties();
|
||||
} else {
|
||||
ourLog.info("Hibernate Search is disabled");
|
||||
hibernateSearchProperties = new HashMap<>();
|
||||
hibernateSearchProperties.put("hibernate.search.enabled", "false");
|
||||
}
|
||||
return hibernateSearchProperties;
|
||||
}
|
||||
|
||||
public static Map<String, String> buildHeapLuceneHibernateSearchProperties() {
|
||||
Map<String, String> props = new HashMap<>();
|
||||
ourLog.warn("Hibernate Search: using lucene - local-heap");
|
||||
props.put(BackendSettings.backendKey(BackendSettings.TYPE), "lucene");
|
||||
props.put(BackendSettings.backendKey(LuceneBackendSettings.ANALYSIS_CONFIGURER), HapiLuceneAnalysisConfigurer.class.getName());
|
||||
props.put(BackendSettings.backendKey(LuceneIndexSettings.DIRECTORY_TYPE), "local-heap");
|
||||
props.put(BackendSettings.backendKey(LuceneBackendSettings.LUCENE_VERSION), "LUCENE_CURRENT");
|
||||
props.put(HibernateOrmMapperSettings.ENABLED, "true");
|
||||
return props;
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public static void beforeClassRandomizeLocale() {
|
||||
doRandomizeLocaleAndTimezone();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ca.uhn.fhir.jpa.dao.dstu2;
|
||||
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParamConstants;
|
||||
|
@ -43,6 +44,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -66,9 +68,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||
import static org.mockito.Mockito.mock;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@TestPropertySource(properties = {
|
||||
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
|
||||
})
|
||||
@ContextConfiguration(classes= TestHibernateSearchAddInConfig.NoFT.class)
|
||||
public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu2SearchNoFtTest.class);
|
||||
@Autowired
|
||||
|
|
|
@ -4,7 +4,7 @@ import ca.uhn.fhir.context.phonetic.ApacheEncoder;
|
|||
import ca.uhn.fhir.context.phonetic.NumericEncoder;
|
||||
import ca.uhn.fhir.context.phonetic.PhoneticEncoderEnum;
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
|
@ -20,7 +20,7 @@ import org.junit.jupiter.api.AfterEach;
|
|||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -32,9 +32,7 @@ import static org.hamcrest.Matchers.hasSize;
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
@TestPropertySource(properties = {
|
||||
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
|
||||
})
|
||||
@ContextConfiguration(classes = TestHibernateSearchAddInConfig.NoFT.class)
|
||||
public class FhirResourceDaoDstu3PhoneticSearchNoFtTest extends BaseJpaDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3PhoneticSearchNoFtTest.class);
|
||||
public static final String GALE = "Gale";
|
||||
|
|
|
@ -2,7 +2,7 @@ package ca.uhn.fhir.jpa.dao.dstu3;
|
|||
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamNumber;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamQuantity;
|
||||
|
@ -97,7 +97,7 @@ import org.hl7.fhir.instance.model.api.IIdType;
|
|||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
|
@ -127,9 +127,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
@TestPropertySource(properties = {
|
||||
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
|
||||
})
|
||||
@ContextConfiguration(classes = TestHibernateSearchAddInConfig.NoFT.class)
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3SearchNoFtTest.class);
|
||||
|
|
|
@ -4,7 +4,8 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoObservation;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoPatient;
|
||||
import ca.uhn.fhir.jpa.config.TestR4ConfigWithElasticsearchClient;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
|
@ -53,7 +54,7 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@RequiresDocker
|
||||
@ContextConfiguration(classes = {TestR4ConfigWithElasticsearchClient.class})
|
||||
@ContextConfiguration(classes = {TestR4Config.class, TestHibernateSearchAddInConfig.Elasticsearch.class})
|
||||
abstract public class BaseR4SearchLastN extends BaseJpaTest {
|
||||
|
||||
private static final Map<String, String> observationPatientMap = new HashMap<>();
|
||||
|
|
|
@ -60,10 +60,7 @@ import java.util.concurrent.Future;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.matchesPattern;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
@ -1012,7 +1009,8 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test {
|
|||
|
||||
@Test
|
||||
public void testResourceWithTagCreationNoFailures() throws ExecutionException, InterruptedException {
|
||||
ExecutorService pool = Executors.newFixedThreadPool(5);
|
||||
// this was 5, but our random connection pool runs as small as 3, and this solution needs a spare connection to be safe.
|
||||
ExecutorService pool = Executors.newFixedThreadPool(2);
|
||||
try {
|
||||
Coding tag = new Coding();
|
||||
tag.setCode("code123");
|
||||
|
@ -1037,7 +1035,7 @@ public class FhirResourceDaoR4CreateTest extends BaseJpaR4Test {
|
|||
try {
|
||||
myPatientDao.update(updatePatient);
|
||||
} catch (ResourceVersionConflictException e) {
|
||||
assertEquals("The operation has failed with a version constraint failure. This generally means that two clients/threads were trying to update the same resource at the same time, and this request was chosen as the failing request.", e.getMessage());
|
||||
assertThat(e.getMessage(), startsWith(Msg.code(550) + Msg.code(823)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ourLog.error("Failure", e);
|
||||
|
|
|
@ -3,7 +3,8 @@ package ca.uhn.fhir.jpa.dao.r4;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.config.TestR4WithLuceneDisabledConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.BaseDateSearchDaoTests;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.dao.DaoTestDataBuilder;
|
||||
|
@ -21,7 +22,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestR4WithLuceneDisabledConfig.class})
|
||||
@ContextConfiguration(classes = {TestR4Config.class, TestHibernateSearchAddInConfig.NoFT.class})
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||
public class FhirResourceDaoR4LuceneDisabledStandardQueries extends BaseJpaTest {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(FhirResourceDaoR4LuceneDisabledStandardQueries.class);
|
||||
|
|
|
@ -6,7 +6,7 @@ import ca.uhn.fhir.interceptor.api.HookParams;
|
|||
import ca.uhn.fhir.interceptor.api.IAnonymousInterceptor;
|
||||
import ca.uhn.fhir.interceptor.api.Pointcut;
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
||||
|
@ -132,10 +132,12 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
|
@ -180,9 +182,8 @@ import static org.mockito.Mockito.times;
|
|||
import static org.mockito.Mockito.verify;
|
||||
|
||||
@SuppressWarnings({"unchecked", "Duplicates"})
|
||||
@TestPropertySource(properties = {
|
||||
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
|
||||
})
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestHibernateSearchAddInConfig.NoFT.class})
|
||||
public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoR4SearchNoFtTest.class);
|
||||
@Autowired
|
||||
|
|
|
@ -9,7 +9,8 @@ import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
|||
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome;
|
||||
import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc;
|
||||
import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportSvc;
|
||||
import ca.uhn.fhir.jpa.config.TestR4ConfigWithElasticSearch;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
||||
|
@ -73,7 +74,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@RequiresDocker
|
||||
@ContextConfiguration(classes = {TestR4ConfigWithElasticSearch.class})
|
||||
@ContextConfiguration(classes = {TestR4Config.class, TestHibernateSearchAddInConfig.Elasticsearch.class})
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||
public class FhirResourceDaoR4SearchWithElasticSearchIT extends BaseJpaTest {
|
||||
public static final String URL_MY_CODE_SYSTEM = "http://example.com/my_code_system";
|
||||
|
|
|
@ -10,7 +10,8 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet;
|
|||
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
||||
import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc;
|
||||
import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportSvc;
|
||||
import ca.uhn.fhir.jpa.config.TestR4WithLuceneDisabledConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.dao.dstu2.FhirResourceDaoDstu2SearchNoFtTest;
|
||||
import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc;
|
||||
|
@ -71,7 +72,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestR4WithLuceneDisabledConfig.class})
|
||||
@ContextConfiguration(classes = {TestR4Config.class, TestHibernateSearchAddInConfig.NoFT.class})
|
||||
@DirtiesContext
|
||||
public class FhirResourceDaoR4SearchWithLuceneDisabledTest extends BaseJpaTest {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoR4SearchWithLuceneDisabledTest.class);
|
||||
|
|
|
@ -7,7 +7,8 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet;
|
|||
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
||||
import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc;
|
||||
import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportSvc;
|
||||
import ca.uhn.fhir.jpa.config.TestR4ConfigWithElasticSearch;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
||||
|
@ -50,7 +51,7 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@RequiresDocker
|
||||
@ContextConfiguration(classes = {TestR4ConfigWithElasticSearch.class})
|
||||
@ContextConfiguration(classes = {TestR4Config.class, TestHibernateSearchAddInConfig.Elasticsearch.class})
|
||||
public class FhirResourceDaoR4TerminologyElasticsearchIT extends BaseJpaTest {
|
||||
|
||||
public static final String URL_MY_CODE_SYSTEM = "http://example.com/my_code_system";
|
||||
|
|
|
@ -3,7 +3,8 @@ package ca.uhn.fhir.jpa.dao.r4;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
||||
import ca.uhn.fhir.jpa.config.TestR4ConfigWithElasticsearchClient;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.ObservationLastNIndexPersistSvc;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
||||
|
@ -62,7 +63,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@RequiresDocker
|
||||
@ContextConfiguration(classes = {TestR4ConfigWithElasticsearchClient.class})
|
||||
@ContextConfiguration(classes = {TestR4Config.class, TestHibernateSearchAddInConfig.Elasticsearch.class})
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class PersistObservationIndexedSearchParamLastNR4IT {
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ package ca.uhn.fhir.jpa.dao.r4;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.config.TestR4WithLuceneDisabledConfig;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum;
|
||||
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
||||
|
@ -47,7 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestR4WithLuceneDisabledConfig.class})
|
||||
@ContextConfiguration(classes = {TestR4Config.class, TestHibernateSearchAddInConfig.NoFT.class})
|
||||
@DirtiesContext
|
||||
public class SyntheaPerfTest extends BaseJpaTest {
|
||||
|
||||
|
|
|
@ -1,33 +1,26 @@
|
|||
package ca.uhn.fhir.jpa.dao.r5;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.util.TestUtil;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.param.HasAndListParam;
|
||||
import ca.uhn.fhir.rest.param.HasOrListParam;
|
||||
import ca.uhn.fhir.rest.param.HasParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import org.hl7.fhir.r5.model.Organization;
|
||||
import org.hl7.fhir.r5.model.Patient;
|
||||
import org.hl7.fhir.r5.model.Practitioner;
|
||||
import org.hl7.fhir.r5.model.PractitionerRole;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@TestPropertySource(properties = {
|
||||
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
|
||||
})
|
||||
@SuppressWarnings({"unchecked", "Duplicates"})
|
||||
@ContextConfiguration(classes= TestHibernateSearchAddInConfig.NoFT.class)
|
||||
@SuppressWarnings({"Duplicates"})
|
||||
public class FhirResourceDaoR5SearchNoFtTest extends BaseJpaR5Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoR5SearchNoFtTest.class);
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@ package ca.uhn.fhir.jpa.provider.r4;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoCodeSystem;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet;
|
||||
import ca.uhn.fhir.jpa.config.TestR4WithLuceneDisabledConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.dao.dstu2.FhirResourceDaoDstu2SearchNoFtTest;
|
||||
import ca.uhn.fhir.jpa.provider.ValueSetOperationProvider;
|
||||
|
@ -59,7 +60,8 @@ import static org.hamcrest.Matchers.containsString;
|
|||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestR4WithLuceneDisabledConfig.class})
|
||||
@ContextConfiguration(classes = {TestR4Config.class, TestHibernateSearchAddInConfig.NoFT.class})
|
||||
@SuppressWarnings({"Duplicates"})
|
||||
public class ResourceProviderR4ValueSetLuceneDisabledTest extends BaseJpaTest {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR4ValueSetLuceneDisabledTest.class);
|
||||
|
|
|
@ -3,8 +3,8 @@ package ca.uhn.fhir.jpa.subscription.module.matcher;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
||||
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString;
|
||||
|
@ -37,7 +37,6 @@ import ca.uhn.fhir.rest.param.TokenParam;
|
|||
import ca.uhn.fhir.rest.param.TokenParamModifier;
|
||||
import ca.uhn.fhir.rest.param.UriParam;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||
|
@ -72,7 +71,6 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -86,11 +84,8 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
|||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@TestPropertySource(properties = {
|
||||
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
|
||||
})
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestR4Config.class})
|
||||
@ContextConfiguration(classes = {TestR4Config.class, TestHibernateSearchAddInConfig.NoFT.class})
|
||||
public class InMemorySubscriptionMatcherR4Test {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(InMemorySubscriptionMatcherR4Test.class);
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet;
|
|||
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
||||
import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc;
|
||||
import ca.uhn.fhir.jpa.bulk.export.api.IBulkDataExportSvc;
|
||||
import ca.uhn.fhir.jpa.config.TestR4ConfigWithElasticSearch;
|
||||
import ca.uhn.fhir.jpa.config.TestHibernateSearchAddInConfig;
|
||||
import ca.uhn.fhir.jpa.config.TestR4Config;
|
||||
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
||||
|
@ -16,7 +17,6 @@ import ca.uhn.fhir.jpa.entity.TermConcept;
|
|||
import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc;
|
||||
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermReadSvcR4;
|
||||
|
@ -24,6 +24,7 @@ import ca.uhn.fhir.jpa.term.custom.CustomTerminologySet;
|
|||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
|
||||
import ca.uhn.fhir.test.utilities.docker.RequiresDocker;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.CodeSystem;
|
||||
|
@ -53,7 +54,7 @@ import static org.mockito.Mockito.verify;
|
|||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@ContextConfiguration(classes = {TestR4ConfigWithElasticSearch.class})
|
||||
@ContextConfiguration(classes = {TestR4Config.class, TestHibernateSearchAddInConfig.Elasticsearch.class})
|
||||
@RequiresDocker
|
||||
public class ValueSetExpansionR4ElasticsearchIT extends BaseJpaTest {
|
||||
|
||||
|
|
Loading…
Reference in New Issue