From b715f669284012b1d25c183e73b550c4648abd1a Mon Sep 17 00:00:00 2001 From: Temoc Rodriguez Date: Mon, 16 Oct 2017 13:37:05 -0700 Subject: Fix operation history DB properties for Junits Removed operation_history.properties / operations-history.properties. Changed the properties in persistence.xml so that it uses the correct values. Previously junit would never write to db because the "guard.disabled" property was not set. Set this property. Additionally the operationshistory10 table was trying to be created even though it exists. These values work in junit code. Not tested on rackspace yet. Issue-ID: POLICY-345 Change-Id: Id755b3152ae6ac4991ea9c314154592ea0105070 Signed-off-by: Temoc Rodriguez --- .../eventmanager/ControlLoopOperationManager.java | 14 +++++++++----- .../src/main/resources/META-INF/persistence.xml | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'controlloop/common/eventmanager') diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index 89b702d63..a6d321f43 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -47,6 +47,7 @@ import org.onap.policy.controlloop.actor.so.SOActorServiceProvider; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.so.SOResponse; import org.onap.policy.vfc.VFCResponse; +import org.onap.policy.guard.Util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -551,12 +552,15 @@ public class ControlLoopOperationManager implements Serializable { // DB Properties Properties props = new Properties(); - try (InputStream is = org.onap.policy.guard.PIPEngineGetHistory.class.getResourceAsStream(org.onap.policy.guard.PIPEngineGetHistory.OPS_HIST_PROPS_LOC)){ - props.load(is); - } catch (Exception ex) { - logger.error("getCountFromDB threw: ", ex); - return; + if(PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_URL) != null && + PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER) != null && + PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS) != null){ + props.put(Util.ECLIPSE_LINK_KEY_URL, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_URL)); + props.put(Util.ECLIPSE_LINK_KEY_USER, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER)); + props.put(Util.ECLIPSE_LINK_KEY_PASS, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS)); } + + String OpsHistPU = System.getProperty("OperationsHistoryPU"); if(OpsHistPU == null || !OpsHistPU.equals("TestOperationsHistoryPU")){ OpsHistPU = "OperationsHistoryPU"; diff --git a/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml b/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml index 827e2562b..9af545592 100644 --- a/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml +++ b/controlloop/common/eventmanager/src/main/resources/META-INF/persistence.xml @@ -9,10 +9,9 @@ org.onap.policy.controlloop.eventmanager.OperationsHistoryDbEntry - + - -- cgit 1.2.3-korg