aboutsummaryrefslogtreecommitdiffstats
path: root/integrity-monitor/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'integrity-monitor/src/test')
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/test/AllSeemsWellTest.java265
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java528
-rw-r--r--integrity-monitor/src/test/resources/log4j.properties54
-rw-r--r--integrity-monitor/src/test/resources/logback-test.xml47
-rw-r--r--integrity-monitor/src/test/resources/logback.xml209
5 files changed, 489 insertions, 614 deletions
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/AllSeemsWellTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/AllSeemsWellTest.java
new file mode 100644
index 00000000..6fa8114d
--- /dev/null
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/AllSeemsWellTest.java
@@ -0,0 +1,265 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Monitor
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.im.test;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.policy.common.im.IntegrityMonitor;
+import org.onap.policy.common.im.IntegrityMonitorProperties;
+import org.onap.policy.common.im.StateManagement;
+import org.onap.policy.common.im.jpa.ForwardProgressEntity;
+import org.onap.policy.common.im.jpa.StateManagementEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AllSeemsWellTest {
+ private static Logger logger = LoggerFactory.getLogger(AllSeemsWellTest.class);
+ private static Properties myProp;
+ private static EntityManagerFactory emf;
+ private static EntityManager em;
+ private static EntityTransaction et;
+ private static String resourceName;
+ private static Properties systemProps;
+
+ private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
+ private static final String DEFAULT_DB_URL = "jdbc:h2:file:./sql/imTest";
+ private static final String DEFAULT_DB_USER = "sa";
+ private static final String DEFAULT_DB_PWD = "";
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ IntegrityMonitor.setUnitTesting(true);
+
+ myProp = new Properties();
+ myProp.put(IntegrityMonitorProperties.DB_DRIVER, AllSeemsWellTest.DEFAULT_DB_DRIVER);
+ myProp.put(IntegrityMonitorProperties.DB_URL, AllSeemsWellTest.DEFAULT_DB_URL);
+ myProp.put(IntegrityMonitorProperties.DB_USER, AllSeemsWellTest.DEFAULT_DB_USER);
+ myProp.put(IntegrityMonitorProperties.DB_PWD, AllSeemsWellTest.DEFAULT_DB_PWD);
+ myProp.put(IntegrityMonitorProperties.SITE_NAME, "SiteA");
+ myProp.put(IntegrityMonitorProperties.NODE_TYPE, "pap");
+
+ // set JMX remote port in system properties
+ systemProps = System.getProperties();
+ systemProps.put("com.sun.management.jmxremote.port", "9797");
+
+ resourceName = "siteA.pap1";
+
+ //Create the data schema and entity manager factory
+ emf = Persistence.createEntityManagerFactory("schemaPU", myProp);
+
+ // Create an entity manager to use the DB
+ em = emf.createEntityManager();
+
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+ // clear jmx remote port setting
+ systemProps.remove("com.sun.management.jmxremote.port");
+ }
+
+ //Ignore
+ @Test
+ public void testAllSeemsWell() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testAllSeemsWell\n\n");
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ myProp.put(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, "1");
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "5");
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "1");
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "1");
+
+ IntegrityMonitor.updateProperties(myProp);
+ /*
+ * The monitorInterval is 5 and the failedCounterThreshold is 1
+ * A forward progress will be stale after 5 seconds.
+ */
+
+ et = em.getTransaction();
+ et.begin();
+
+ // Make sure we start with the DB clean
+ em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
+ em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
+ em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
+
+ em.flush();
+ et.commit();
+
+ IntegrityMonitor.deleteInstance();
+
+ IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
+
+ StateManagement sm = im.getStateManager();
+
+ //Give it time to set the states in the DB
+ Thread.sleep(15000);
+
+ //Check the state
+ logger.debug("\n\ntestAllSeemsWell starting im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
+ assertTrue(sm.getOpState().equals(StateManagement.ENABLED));
+
+ //Indicate a failure
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLNOTWELL,
+ "'AllSeemsWellTest - ALLNOTWELL'");
+
+ //Wait for the state to change due to ALLNOTWELL
+ Thread.sleep(15000);
+ //Check the state
+ logger.debug("\n\ntestAllSeemsWell after ALLNOTWELL: im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
+ //assertTrue(sm.getOpState().equals(StateManagement.DISABLED));
+
+ Map<String, String> allNotWellMap = im.getAllNotWellMap();
+ for(String key: allNotWellMap.keySet()){
+ logger.debug("AllSeemsWellTest: allNotWellMap: key = {} msg = {}", key, allNotWellMap.get(key));
+ }
+ //assertTrue(allNotWellMap.size() == 1);
+
+ Map<String,String> allSeemsWellMap = im.getAllSeemsWellMap();
+ //assertTrue(allSeemsWellMap.isEmpty());
+
+ //Return to normal
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL,
+ "'AllSeemsWellTest - ALLSEEMSWELL'");
+
+ //Wait for the state to change due to ALLNOTWELL
+ Thread.sleep(15000);
+ //Check the state
+ logger.debug("\n\ntestAllSeemsWell after ALLSEEMSWELL: im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(),
+ sm.getOpState(),
+ sm.getAvailStatus(),
+ sm.getStandbyStatus());
+
+ //assertTrue(sm.getOpState().equals(StateManagement.ENABLED));
+
+ allNotWellMap = im.getAllNotWellMap();
+ assertTrue(allNotWellMap.isEmpty());
+
+ allSeemsWellMap = im.getAllSeemsWellMap();
+ assertTrue(allSeemsWellMap.size() == 1);
+ for(String key: allSeemsWellMap.keySet()){
+ logger.debug("AllSeemsWellTest: allSeemsWellMap: key = {} msg = {}", key, allSeemsWellMap.get(key));
+ }
+
+ //Check for null parameters
+ try{
+ im.allSeemsWell(null, IntegrityMonitorProperties.ALLSEEMSWELL,
+ "'AllSeemsWellTest - ALLSEEMSWELL'");
+ assertTrue(false);
+ }catch (IllegalArgumentException e) {
+ assertTrue(true);
+ }
+
+ try{
+ im.allSeemsWell("", IntegrityMonitorProperties.ALLSEEMSWELL,
+ "'AllSeemsWellTest - ALLSEEMSWELL'");
+ assertTrue(false);
+ }catch (IllegalArgumentException e) {
+ assertTrue(true);
+ }
+
+ try{
+ im.allSeemsWell(this.getClass().getName(), null,
+ "'AllSeemsWellTest - ALLSEEMSWELL'");
+ assertTrue(false);
+ }catch (IllegalArgumentException e) {
+ assertTrue(true);
+ }
+
+ try{
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL,
+ null);
+ assertTrue(false);
+ }catch (IllegalArgumentException e) {
+ assertTrue(true);
+ }
+
+ try{
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL,
+ "");
+ assertTrue(false);
+ }catch (IllegalArgumentException e) {
+ assertTrue(true);
+ }
+
+ // undo settings
+ myProp.put(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, Integer.toString(IntegrityMonitorProperties.DEFAULT_FAILED_COUNTER_THRESHOLD));
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, Integer.toString(IntegrityMonitorProperties.DEFAULT_MONITOR_INTERVAL));
+ myProp.put(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, Integer.toString(IntegrityMonitorProperties.DEFAULT_FAILED_COUNTER_THRESHOLD));
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, Integer.toString(IntegrityMonitorProperties.DEFAULT_MONITOR_INTERVAL));
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, Integer.toString(IntegrityMonitorProperties.DEFAULT_TEST_INTERVAL));
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, Integer.toString(IntegrityMonitorProperties.DEFAULT_WRITE_FPC_INTERVAL));
+ IntegrityMonitor.updateProperties(myProp);
+
+ et = em.getTransaction();
+
+ et.begin();
+ // Make sure we leave the DB clean
+ em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
+ em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
+ em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
+
+ em.flush();
+ et.commit();
+
+ logger.debug("\n\ntestAllSeemsWell: Exit\n\n");
+ }
+
+}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java
index de91a91d..563c5d55 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java
@@ -38,8 +38,8 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
-
import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.im.IntegrityMonitorProperties;
import org.onap.policy.common.im.StateManagement;
@@ -81,13 +81,7 @@ public class IntegrityMonitorTest {
public void setUp() throws Exception {
IntegrityMonitor.setUnitTesting(true);
- myProp = new Properties();
- myProp.put(IntegrityMonitorProperties.DB_DRIVER, IntegrityMonitorTest.DEFAULT_DB_DRIVER);
- myProp.put(IntegrityMonitorProperties.DB_URL, IntegrityMonitorTest.DEFAULT_DB_URL);
- myProp.put(IntegrityMonitorProperties.DB_USER, IntegrityMonitorTest.DEFAULT_DB_USER);
- myProp.put(IntegrityMonitorProperties.DB_PWD, IntegrityMonitorTest.DEFAULT_DB_PWD);
- myProp.put(IntegrityMonitorProperties.SITE_NAME, "SiteA");
- myProp.put(IntegrityMonitorProperties.NODE_TYPE, "pap");
+ cleanMyProp();
// set JMX remote port in system properties
systemProps = System.getProperties();
@@ -110,21 +104,44 @@ public class IntegrityMonitorTest {
systemProps.remove("com.sun.management.jmxremote.port");
}
+ private void cleanMyProp(){
+ myProp = new Properties();
+ myProp.put(IntegrityMonitorProperties.DB_DRIVER, IntegrityMonitorTest.DEFAULT_DB_DRIVER);
+ myProp.put(IntegrityMonitorProperties.DB_URL, IntegrityMonitorTest.DEFAULT_DB_URL);
+ myProp.put(IntegrityMonitorProperties.DB_USER, IntegrityMonitorTest.DEFAULT_DB_USER);
+ myProp.put(IntegrityMonitorProperties.DB_PWD, IntegrityMonitorTest.DEFAULT_DB_PWD);
+ myProp.put(IntegrityMonitorProperties.SITE_NAME, "SiteA");
+ myProp.put(IntegrityMonitorProperties.NODE_TYPE, "pap");
+ }
+
+ private void cleanDb(){
+ et = em.getTransaction();
+
+ et.begin();
+ // Make sure we leave the DB clean
+ em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
+ em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
+ em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
+ em.flush();
+ et.commit();
+ }
+
+
/*
* The following runs all tests and controls the order of execution. If you allow
* the tests to execute individually, you cannot predict the order and some
- * conflicts occur.
+ * conflicts may occur.
*/
//@Ignore
@Test
public void runAllTests() throws Exception{
testSanityJmx();
- testIM();
- //testSanityState();
- //testRefreshStateAudit();
+ testIM();
+ testSanityState();
+ testRefreshStateAudit();
testStateCheck();
- //testGetAllForwardProgressEntity();
- testStateAudit();
+ testGetAllForwardProgressEntity();
+ testStateAudit();
}
/*
@@ -139,13 +156,29 @@ public class IntegrityMonitorTest {
*/
public void testSanityJmx() throws Exception {
logger.debug("\nIntegrityMonitorTest: Entering testSanityJmx\n\n");
+ cleanDb();
+ cleanMyProp();
+ IntegrityMonitor.deleteInstance();
String dependent = "group1_logparser";
// parameters are passed via a properties file
myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, dependent);
myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "true");
- IntegrityMonitor.updateProperties(myProp);
+ // Disable the integrity monitor so it will not interfere
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the state audit
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable the write FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
+ // Speed up the check
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "1");
+ // Fail dependencies after three seconds
+ myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "3");
IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
logger.debug("\n\ntestSanityJmx starting im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
@@ -181,7 +214,7 @@ public class IntegrityMonitorTest {
// commit transaction
et.commit();
- Thread.sleep(15000); //sleep 15 sec so the FPManager has time to call evaluateSanty()
+ Thread.sleep(5000); //sleep 5 sec so the FPManager has time to check dependency health
boolean sanityPass = true;
try {
@@ -287,26 +320,26 @@ public class IntegrityMonitorTest {
public void testIM() throws Exception {
logger.debug("\nIntegrityMonitorTest: Entering testIM\n\n");
+ cleanDb();
+ cleanMyProp();
+ IntegrityMonitor.deleteInstance();
- // parameters are passed via a properties file
+ // Disable the integrity monitor so it will not interfere
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable dependency checking
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the state audit
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable writing the FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
- /*
- * Create an IntegrityMonitor
- * NOTE: This uses the database that was created above. So, this MUST follow the creation
- * of the DB
- */
IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
- logger.debug("\n\nim before sleep\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- im.getStateManager().getAdminState(),
- im.getStateManager().getOpState(),
- im.getStateManager().getAvailStatus(),
- im.getStateManager().getStandbyStatus());
-
- // wait for test transactions to fire and increment fpc
- Thread.sleep(20000);
-
- logger.debug("\n\nim after sleep\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ logger.debug("\n\nim initial state: \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
im.getStateManager().getAdminState(),
im.getStateManager().getOpState(),
im.getStateManager().getAvailStatus(),
@@ -336,6 +369,7 @@ public class IntegrityMonitorTest {
StateManagement sm = im.getStateManager();
sm.lock();
+
logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
sm.getAdminState(),
sm.getOpState(),
@@ -573,10 +607,26 @@ public class IntegrityMonitorTest {
public void testSanityState() throws Exception {
logger.debug("\nIntegrityMonitorTest: Entering testSanityState\n\n");
+ cleanDb();
+ cleanMyProp();
+ IntegrityMonitor.deleteInstance();
// parameters are passed via a properties file
myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "group1_dep1,group1_dep2; group2_dep1");
- IntegrityMonitor.updateProperties(myProp);
+ // Disable the integrity monitor so it will not interfere
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable dependency checking so it does not interfere
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
+ // Disable the state audit
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable writing the FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
+ // Max interval for use in deciding if a FPC entry is stale in seconds
+ myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "120");
IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
@@ -604,7 +654,9 @@ public class IntegrityMonitorTest {
new StateManagement(emf, "group1_dep2");
boolean sanityPass = true;
- Thread.sleep(15000);
+ // Call the dependency check directly instead of waiting for FPManager to do it.
+ logger.debug("\n\nIntegrityMonitor.testSanityState: calling im.dependencyCheck()\n\n");
+ im.dependencyCheck();
try {
im.evaluateSanity();
} catch (Exception e) {
@@ -613,48 +665,32 @@ public class IntegrityMonitorTest {
}
assertFalse(sanityPass); // expect sanity test to fail
- // undo dependency groups and jmx test properties settings
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
- myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
- IntegrityMonitor.updateProperties(myProp);
-
- et = em.getTransaction();
-
- et.begin();
- // Make sure we leave the DB clean
- em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-
- em.flush();
- et.commit();
-
logger.debug("\n\ntestSanityState: Exit\n\n");
}
public void testRefreshStateAudit() throws Exception {
logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Enter\n\n");
+ cleanDb();
+ cleanMyProp();
+ IntegrityMonitor.deleteInstance();
// parameters are passed via a properties file
myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
- myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "60000");
- IntegrityMonitor.updateProperties(myProp);
+ // Disable the integrity monitor so it will not interfere
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable dependency checking so it does not interfere
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
+ // Disable the state audit
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable writing the FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
- et = em.getTransaction();
- et.begin();
-
- // Make sure we leave the DB clean
- em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-
- em.flush();
- et.commit();
-
- IntegrityMonitor.deleteInstance();
-
- IntegrityMonitor.getInstance(resourceName, myProp);
+ IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
//the state here is unlocked, enabled, null, null
StateManagementEntity sme = null;
@@ -697,7 +733,8 @@ public class IntegrityMonitorTest {
em.flush();
et.commit();
- Thread.sleep(65000);
+ // Run the refreshStateAudit
+ im.executeRefreshStateAudit();
//The refreshStateAudit should run and change the state to unlocked,enabled,null,hotstandby
StateManagementEntity sme1 = null;
@@ -706,7 +743,6 @@ public class IntegrityMonitorTest {
query1.setParameter("resource", resourceName);
- //Just test that we are retrieving the right object
@SuppressWarnings("rawtypes")
List resourceList1 = query1.getResultList();
if (!resourceList1.isEmpty()) {
@@ -731,49 +767,36 @@ public class IntegrityMonitorTest {
assertTrue(false);
}
- et = em.getTransaction();
- et.begin();
-
- // Make sure we leave the DB clean
- em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-
- em.flush();
- et.commit();
-
- IntegrityMonitor.deleteInstance();
-
logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Exit\n\n");
}
public void testStateCheck() throws Exception {
logger.debug("\nIntegrityMonitorTest: Entering testStateCheck\n\n");
+ cleanDb();
+ cleanMyProp();
+ IntegrityMonitor.deleteInstance();
// parameters are passed via a properties file
myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "group1_dep1");
myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
myProp.put(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, "1");
- myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "10");
- IntegrityMonitor.updateProperties(myProp);
/*
- * The default monitorInterval is 30 and the default failedCounterThreshold is 3
- * Since stateCheck() uses the faileCounterThreshold * monitorInterval to determine
- * if an entry is stale, it will be stale after 30 seconds.
+ * The monitorInterval is set to 10 and the failedCounterThreshold is 1
+ * because stateCheck() uses the faileCounterThreshold * monitorInterval to determine
+ * if an entry is stale, it will be stale after 10 seconds.
*/
-
- et = em.getTransaction();
- et.begin();
-
- // Make sure we start with the DB clean
- em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-
- em.flush();
- et.commit();
-
- IntegrityMonitor.deleteInstance();
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "5");
+ /*
+ * We accelerate the test transaction and write FPC intervals because we don't want
+ * there to be any chance of a FPC failure because of the short monitor interval
+ */
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "1");
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "2");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // The maximum time in seconds to determine that a FPC entry is stale
+ myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "5");
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "5");
IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
@@ -792,73 +815,56 @@ public class IntegrityMonitorTest {
boolean sanityPass = true;
//Thread.sleep(15000);
- Thread.sleep(5000);
+ //Thread.sleep(5000);
try {
im.evaluateSanity();
} catch (Exception e) {
- logger.error("testStateCheck: After 15 sec sleep - evaluateSanity exception: ", e);
+ logger.error("testStateCheck: After 5 sec sleep - evaluateSanity exception: ", e);
sanityPass = false;
}
assertTrue(sanityPass); // expect sanity test to pass
- //now wait 30 seconds. The dependency entry should now be stale and the sanitry check should fail
+ //now wait 10 seconds. The dependency entry is checked every 10 sec. So, even in the worst case
+ //it should now be stale and the sanity check should fail
sanityPass = true;
- //Thread.sleep(30000);
Thread.sleep(10000);
try {
im.evaluateSanity();
} catch (Exception e) {
- logger.error("testStateCheck: After 10 sec sleep - evaluateSanity exception: ", e);
+ logger.error("testStateCheck: After 15 sec sleep - evaluateSanity exception: ", e);
sanityPass = false;
}
assertFalse(sanityPass); // expect sanity test to fail
- // undo dependency groups, jmx test properties settings and failed counter threshold
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
- myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
- myProp.put(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, Integer.toString(IntegrityMonitorProperties.DEFAULT_FAILED_COUNTER_THRESHOLD));
- myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, Integer.toString(IntegrityMonitorProperties.DEFAULT_MONITOR_INTERVAL));
- IntegrityMonitor.updateProperties(myProp);
-
- et = em.getTransaction();
-
- et.begin();
- // Make sure we leave the DB clean
- em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-
- em.flush();
- et.commit();
-
logger.debug("\n\ntestStateCheck: Exit\n\n");
}
public void testGetAllForwardProgressEntity() throws Exception{
logger.debug("\nIntegrityMonitorTest: Entering testGetAllForwardProgressEntity\n\n");
-
+ cleanDb();
+ cleanMyProp();
+ IntegrityMonitor.deleteInstance();
// parameters are passed via a properties file
myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
- IntegrityMonitor.updateProperties(myProp);
-
- et = em.getTransaction();
- et.begin();
-
- // Make sure we start with the DB clean
- em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-
- em.flush();
- et.commit();
-
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ // Disable the integrity monitor so it will not interfere
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable dependency checking so it does not interfere
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
+ // Disable the state audit
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable writing the FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
- IntegrityMonitor.deleteInstance();
IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
logger.debug("\nIntegrityMonitorTest: Creating ForwardProgressEntity entries\n\n");
- // Add a resources to put an entry in the forward progress table
+ // Add resource entries in the forward progress table
ForwardProgressEntity fpe = new ForwardProgressEntity();
ForwardProgressEntity fpe2 = new ForwardProgressEntity();
ForwardProgressEntity fpe3 = new ForwardProgressEntity();
@@ -881,42 +887,39 @@ public class IntegrityMonitorTest {
assertTrue(fpeList.size()==4);
- et = em.getTransaction();
-
- et.begin();
- // Make sure we leave the DB clean
- em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-
- em.flush();
- et.commit();
-
logger.debug("\nIntegrityMonitorTest: Exit testGetAllForwardProgressEntity\n\n");
}
public void testStateAudit() throws Exception{
logger.debug("\nIntegrityMonitorTest: Entering testStateAudit\n\n");
+ cleanDb();
+ cleanMyProp();
+ IntegrityMonitor.deleteInstance();
// parameters are passed via a properties file
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
- myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "100");
- IntegrityMonitor.updateProperties(myProp);
-
- et = em.getTransaction();
- et.begin();
- // Make sure we start with the DB clean
- em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-
- em.flush();
- et.commit();
+ // No Dependency Groups
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ // Don't use JMX
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ // Disable the internal sanity monitoring.
+ myProp.put(IntegrityMonitorProperties.FP_MONITOR_INTERVAL, "-1");
+ // Disable the dependency monitoring.
+ myProp.put(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, "-1");
+ // Disable the refresh state audit
+ myProp.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS, "-1");
+ // Disable the test transaction
+ myProp.put(IntegrityMonitorProperties.TEST_TRANS_INTERVAL, "-1");
+ // Disable the write FPC
+ myProp.put(IntegrityMonitorProperties.WRITE_FPC_INTERVAL, "-1");
+ // Disable the State Audit we will call it directly
+ myProp.put(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, "-1");
+ // Max interval for use in deciding if a FPC entry is stale in seconds
+ myProp.put(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, "120");
- IntegrityMonitor.deleteInstance();
IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
+ StateManagement sm = im.getStateManager();
logger.debug("\nIntegrityMonitorTest: Creating ForwardProgressEntity entries\n\n");
// Add resources to put an entry in the forward progress table
@@ -1007,9 +1010,12 @@ public class IntegrityMonitorTest {
}
logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit: sleeping 2 sec");
- Thread.sleep(3000);
- logger.debug("IntegrityMonitorTest:testStateAudit: Awake!");
+ em.refresh(sme1);
+ assertTrue(sme1.getOpState().equals(StateManagement.ENABLED));
+
+ logger.debug("IntegrityMonitorTest:testStateAudit: calling stateAudit()");
+ im.executeStateAudit();
+ logger.debug("IntegrityMonitorTest:testStateAudit: call to stateAudit() complete");
logger.debug("\nIntegrityMonitorTest:testStateAudit getting list of StateManagementEntity entries\n\n");
smeList = query.getResultList();
@@ -1036,176 +1042,6 @@ public class IntegrityMonitorTest {
em.refresh(sme1);
assertTrue(sme1.getOpState().equals(StateManagement.DISABLED));
-
- //Now lock this IM
- StateManagement sm = im.getStateManager();
- sm.lock();
-
- //Give it time to write the db
- Thread.sleep(2000);
-
- //Put things back to their starting condition
- et = em.getTransaction();
- et.begin();
- sme1.setOpState(StateManagement.ENABLED);
- sme1.setAvailStatus(StateManagement.NULL_VALUE);
- em.persist(sme1);
- et.commit();
-
- //Now it should not update sme1
- logger.debug("IntegrityMonitorTest:testStateAudit: 2nd sleeping 2 sec");
- Thread.sleep(2000);
- logger.debug("IntegrityMonitorTest:testStateAudit: 2nd Awake!");
-
- logger.debug("\nIntegrityMonitorTest:testStateAudit 2nd getting list of StateManagementEntity entries\n\n");
- smeList = query.getResultList();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity 2nd entries");
- for(Object mySme : smeList){
- StateManagementEntity tmpSme = (StateManagementEntity) mySme;
- em.refresh(tmpSme);
- logger.debug("\n 2nd ResourceName: {}" +
- "\n AdminState: {}" +
- "\n OpState: {}" +
- "\n AvailStatus: {}" +
- "\n StandbyStatus: {}",
- tmpSme.getResourceName(),
- tmpSme.getAdminState(),
- tmpSme.getOpState(),
- tmpSme.getAvailStatus(),
- tmpSme.getStandbyStatus()
- );
- }
- logger.debug("\n\n");
-
- em.refresh(sme1);
- assertTrue(sme1.getOpState().equals(StateManagement.ENABLED));
-
- //Now create a reason for this IM to be disabled. Add a bogus dependency
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "Bogus_Node");
- IntegrityMonitor.updateProperties(myProp);
-
- //Restart the IM
- IntegrityMonitor.deleteInstance();
- im = IntegrityMonitor.getInstance(resourceName, myProp);
-
- //Give it time to initialize and check dependencies
- logger.debug("IntegrityMonitorTest:testStateAudit: (restart) sleeping 10 sec");
- Thread.sleep(7000);
- logger.debug("IntegrityMonitorTest:testStateAudit: (restart) Awake!");
-
- //Now unlock this IM. Now it should be unlocked, but disabled due to dependency
- sm.unlock();
-
- //Now check its state
- logger.debug("\nIntegrityMonitorTest:testStateAudit (restart) getting list of StateManagementEntity entries\n\n");
- smeList = query.getResultList();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity (restart) entries");
- for(Object mySme : smeList){
- StateManagementEntity tmpSme = (StateManagementEntity) mySme;
- em.refresh(tmpSme);
-
- logger.debug("\n (restart) ResourceName: {}" +
- "\n AdminState: {}" +
- "\n OpState: {}" +
- "\n AvailStatus: {}" +
- "\n StandbyStatus: {}",
- tmpSme.getResourceName(),
- tmpSme.getAdminState(),
- tmpSme.getOpState(),
- tmpSme.getAvailStatus(),
- tmpSme.getStandbyStatus()
- );
-
- }
- logger.debug("\n\n");
-
- em.refresh(sme1);
- assertTrue(sme1.getOpState().equals(StateManagement.ENABLED));
-
- //Now lock this IM so it will not audit when it comes back up
- sm.lock();
-
- //Remove the bogus dependency and restart it
- myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
- IntegrityMonitor.updateProperties(myProp);
-
- //Restart the IM
- IntegrityMonitor.deleteInstance();
- im = IntegrityMonitor.getInstance(resourceName, myProp);
-
- //Give it time to initialize and check dependencies
- logger.debug("IntegrityMonitorTest:testStateAudit: (restart2) sleeping 10 sec");
- Thread.sleep(7000);
- logger.debug("IntegrityMonitorTest:testStateAudit: (restart2) Awake!");
-
- //Now check its state
- logger.debug("\nIntegrityMonitorTest:testStateAudit (restart2) getting list of StateManagementEntity entries\n\n");
- smeList = query.getResultList();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity (restart2) entries");
- for(Object mySme : smeList){
- StateManagementEntity tmpSme = (StateManagementEntity) mySme;
- em.refresh(tmpSme);
-
- logger.debug("\n (restart2) ResourceName: {}" +
- "\n AdminState: {}" +
- "\n OpState: {}" +
- "\n AvailStatus: {}" +
- "\n StandbyStatus: {}",
- tmpSme.getResourceName(),
- tmpSme.getAdminState(),
- tmpSme.getOpState(),
- tmpSme.getAvailStatus(),
- tmpSme.getStandbyStatus()
- );
- }
- logger.debug("\n\n");
-
- em.refresh(sme1);
- assertTrue(sme1.getOpState().equals(StateManagement.ENABLED));
-
- //Make this IM coldstandby
- sm.demote();
- //Give it time to write the DB
- Thread.sleep(2000);
- //unlock it
- sm.unlock();
- //Give it time to write the DB
- Thread.sleep(2000);
-
- //Now check its state
- logger.debug("\nIntegrityMonitorTest:testStateAudit (restart3) getting list of StateManagementEntity entries\n\n");
- smeList = query.getResultList();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity (restart3) entries");
- for(Object mySme : smeList){
- StateManagementEntity tmpSme = (StateManagementEntity) mySme;
- em.refresh(tmpSme);
-
- logger.debug("\n (restart3) ResourceName: {}" +
- "\n AdminState: {}" +
- "\n OpState: {}" +
- "\n AvailStatus: {}" +
- "\n StandbyStatus: {}",
- tmpSme.getResourceName(),
- tmpSme.getAdminState(),
- tmpSme.getOpState(),
- tmpSme.getAvailStatus(),
- tmpSme.getStandbyStatus()
- );
- }
- logger.debug("\n\n");
-
- //sme1 should not be changed because this IM is hotstandby and cannot change its state
- em.refresh(sme1);
- assertTrue(sme1.getOpState().equals(StateManagement.ENABLED));
-
//Now let's add sme2 to the mix
updateQuery = em.createQuery("UPDATE ForwardProgressEntity f "
+ "SET f.lastUpdated = :newDate "
@@ -1218,12 +1054,12 @@ public class IntegrityMonitorTest {
updateQuery.executeUpdate();
et.commit();
- //Finally, we want to promote this IM so it will disable sme1
- sm.promote();
//Give it a chance to write the DB and run the audit
- logger.debug("IntegrityMonitorTest:testStateAudit: (restart4) sleeping 2 sec");
- Thread.sleep(3000);
- logger.debug("IntegrityMonitorTest:testStateAudit: (restart4) Awake!");
+ logger.debug("IntegrityMonitorTest:testStateAudit: (restart4) Running State Audit");
+ Thread.sleep(2000);
+ im.executeStateAudit();
+ Thread.sleep(1000);
+ logger.debug("IntegrityMonitorTest:testStateAudit: (restart4) State Audit complete");
//Now check its state
logger.debug("\nIntegrityMonitorTest:testStateAudit (restart4) getting list of StateManagementEntity entries\n\n");
@@ -1255,16 +1091,6 @@ public class IntegrityMonitorTest {
em.refresh(sme2);
assertTrue(sme2.getOpState().equals(StateManagement.DISABLED));
- et = em.getTransaction();
- et.begin();
- // Make sure we leave the DB clean
- em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- em.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- em.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
-
- em.flush();
- et.commit();
-
logger.debug("\nIntegrityMonitorTest: Exit testStateAudit\n\n");
System.out.println("\n\ntestStateAudit: Exit\n\n");
}
diff --git a/integrity-monitor/src/test/resources/log4j.properties b/integrity-monitor/src/test/resources/log4j.properties
deleted file mode 100644
index efc18e9b..00000000
--- a/integrity-monitor/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,54 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# Integrity Monitor
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-#
-# Use this properties for debugging and development.
-#
-#
-# For debug output, set root logger level to DEBUG and output to FILE and CONSOLE
-#log4j.rootLogger=DEBUG, FILE, CONSOLE
-log4j.rootLogger=INFO, FILE, CONSOLE
-
-# A1 is set to be a DailyRollingFileAppender.
-log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
-
-# Set the name of the file
-log4j.appender.FILE.File=IntegrityMonitor.log
-
-# Set the immediate flush to true (default)
-log4j.appender.FILE.ImmediateFlush=true
-
-# Set the threshold to debug mode
-log4j.appender.FILE.Threshold=debug
-
-# Set the append to false, should not overwrite
-log4j.appender.FILE.Append=true
-
-# Set the DatePattern
-log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
-
-# A1 uses PatternLayout.
-log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.FILE.layout.ConversionPattern=%d{yyyy_MM_dd_HH_mm_ss_SSS} [%t] %-5p %l- %m%n
-
-# for Developments and Debugging
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy_MM_dd_HH_mm_ss_SSS} [%t] %-5p %l- %m%n
diff --git a/integrity-monitor/src/test/resources/logback-test.xml b/integrity-monitor/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..57a9d1c9
--- /dev/null
+++ b/integrity-monitor/src/test/resources/logback-test.xml
@@ -0,0 +1,47 @@
+<!--
+ ============LICENSE_START=======================================================
+ integrity-monitor
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Controls the output of logs for JUnit tests -->
+
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <Pattern>
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
+ </Pattern>
+ </encoder>
+ </appender>
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>logs/debug.log</file>
+ <encoder>
+ <Pattern>
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
+ </Pattern>
+ </encoder>
+ </appender>
+
+ <root level="debug">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="FILE" />
+ </root>
+
+</configuration>
+
diff --git a/integrity-monitor/src/test/resources/logback.xml b/integrity-monitor/src/test/resources/logback.xml
deleted file mode 100644
index 544162f3..00000000
--- a/integrity-monitor/src/test/resources/logback.xml
+++ /dev/null
@@ -1,209 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- Integrity Monitor
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ============LICENSE_END=========================================================
- -->
-
-<!-- Controls the output of logs for JUnit tests -->
-
-<configuration scan="true" scanPeriod="3 seconds" debug="true">
- <!--<jmxConfigurator /> -->
- <!-- directory path for all other type logs -->
- <property name="logDir" value="testingLogs" />
-
- <!-- directory path for debugging type logs -->
- <property name="debugDir" value="testingLogs" />
-
- <!-- specify the component name
- <ONAP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" -->
- <property name="componentName" value="common-modules"></property>
- <property name="subComponentName" value="integrity-monitor"></property>
-
- <!-- log file names -->
- <property name="errorLogName" value="error" />
- <property name="metricsLogName" value="metrics" />
- <property name="auditLogName" value="audit" />
- <property name="debugLogName" value="debug" />
-
- <property name="defaultPattern" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}|%c||%msg%n" />
- <!-- <property name="defaultPattern" value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n" /> -->
- <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" />
- <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" />
- <!--
- <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" />
- <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" />
- -->
- <!-- example from old log4j.properties: ${catalina.base}/logs/pdp-rest.log -->
- <!-- Example evaluator filter applied against console appender -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
- <!-- ============================================================================ -->
- <!-- EELF Appenders -->
- <!-- ============================================================================ -->
-
- <!-- The EELFAppender is used to record events to the general application
- log -->
-
-
-
-
- <!-- EELF Audit Appender. This appender is used to record audit engine
- related logging events. The audit logger and appender are specializations
- of the EELF application root logger and appender. This can be used to segregate
- Policy engine events from other components, or it can be eliminated to record
- these events as part of the application root log. -->
-
- <appender name="EELFAudit"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${auditLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
- <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFAudit" />
- </appender>
-
-<appender name="EELFMetrics"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${metricsLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} -
- %msg%n"</pattern> -->
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
-
- <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFMetrics"/>
- </appender>
-
- <appender name="EELFError"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDirectory}/${errorLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>ERROR</level>
- </filter>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFError"/>
- </appender>
-
- <appender name="EELFDebug"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${debugLogDirectory}/${debugLogName}.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip
- </fileNamePattern>
- <minIndex>1</minIndex>
- <maxIndex>9</maxIndex>
- </rollingPolicy>
- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <!-- <level>INFO</level> -->
- <level>DEBUG</level>
- </filter>
- <triggeringPolicy
- class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>5MB</maxFileSize>
- </triggeringPolicy>
- <encoder>
- <pattern>${defaultPattern}</pattern>
- </encoder>
- </appender>
-
- <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender">
- <queueSize>256</queueSize>
- <appender-ref ref="EELFDebug" />
- <includeCallerData>true</includeCallerData>
- </appender>
-
-
- <!-- ============================================================================ -->
- <!-- EELF loggers -->
- <!-- ============================================================================ -->
-
- <logger name="com.att.eelf.audit" level="info" additivity="false">
- <appender-ref ref="asyncEELFAudit" />
- </logger>
-
- <logger name="com.att.eelf.metrics" level="info" additivity="false">
- <appender-ref ref="asyncEELFMetrics" />
- </logger>
-
- <logger name="com.att.eelf.error" level="error" additivity="false">
- <appender-ref ref="asyncEELFError" />
- </logger>
-
- <!-- <logger name="com.att.eelf.debug" level="info" additivity="false"> -->
- <logger name="com.att.eelf.debug" level="debug" additivity="false">
- <appender-ref ref="asyncEELFDebug" />
- </logger>
-
-
- <!-- <root level="INFO"> -->
- <root level="DEBUG">
- <appender-ref ref="asyncEELFDebug" />
- <appender-ref ref="asyncEELFError" />
- </root>
-
-</configuration>