aboutsummaryrefslogtreecommitdiffstats
path: root/vid-ext-services-simulator/src/main
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-09-04 13:49:22 +0300
committerIttay Stern <ittay.stern@att.com>2019-09-04 14:15:24 +0300
commit0ccf8ebba94447e7e7004c1a14049f679b0f28b2 (patch)
tree7bb8aa6f3d470f23ba35da6af1af9a933243f7ca /vid-ext-services-simulator/src/main
parent87c87c875e0c0bba90e4ed911c8066dcfa85c517 (diff)
Improve vid-simulator cloud-nativeness
Issue-ID: VID-608 * Integrative tests will look at `SIM_HOST` that may differ from `VID_HOST`. * Simulator will look at `hibernate.connection.url` property for db-connection config * Don't skip DB connection if schema not ready, by removing schema validation Change-Id: Idb4587c30dd0cbc0fe7e7362cb691a4cb425fd10 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-ext-services-simulator/src/main')
-rw-r--r--vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java13
-rw-r--r--vid-ext-services-simulator/src/main/resources/META-INF/persistence.xml2
2 files changed, 13 insertions, 2 deletions
diff --git a/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java b/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java
index 3845c7419..aec437806 100644
--- a/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java
+++ b/vid-ext-services-simulator/src/main/java/org/onap/simulator/controller/SimulatorController.java
@@ -1,11 +1,13 @@
package org.onap.simulator.controller;
+import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.mockserver.integration.ClientAndServer.startClientAndServer;
import static org.mockserver.matchers.Times.exactly;
import static org.mockserver.model.JsonBody.json;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
@@ -107,11 +109,20 @@ public class SimulatorController {
private void initJPA() {
if (enableJPA) {
- entityManagerFactory = Persistence.createEntityManagerFactory("vid");
+ entityManagerFactory = Persistence.createEntityManagerFactory("vid", overrideConnectionUrl());
entityManager = entityManagerFactory.createEntityManager();
}
}
+ private Map<Object, Object> overrideConnectionUrl() {
+ final String connectionUrlEnvProperty = "hibernate.connection.url";
+ if (isEmpty(System.getProperty(connectionUrlEnvProperty))) {
+ return Collections.emptyMap();
+ } else {
+ return ImmutableMap.of(connectionUrlEnvProperty, System.getProperty(connectionUrlEnvProperty));
+ }
+ }
+
@PreDestroy
public void tearDown(){
logger.info("Stopping VID Simulator....");
diff --git a/vid-ext-services-simulator/src/main/resources/META-INF/persistence.xml b/vid-ext-services-simulator/src/main/resources/META-INF/persistence.xml
index 9e4453feb..448b5b380 100644
--- a/vid-ext-services-simulator/src/main/resources/META-INF/persistence.xml
+++ b/vid-ext-services-simulator/src/main/resources/META-INF/persistence.xml
@@ -12,7 +12,7 @@
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MariaDB103Dialect" />
- <property name="hibernate.hbm2ddl.auto" value="validate" />
+ <property name="hibernate.hbm2ddl.auto" value="none" />
<property name="hibernate.connection.driver_class" value="org.mariadb.jdbc.Driver"/>
<property name="hibernate.connection.username" value="euser"/>
<property name="hibernate.connection.password" value="euser"/>