summaryrefslogtreecommitdiffstats
path: root/integrity-monitor/src/test/java
diff options
context:
space:
mode:
authorRalph Straubs <rs8887@att.com>2017-04-20 05:26:49 -0500
committerRalph Straubs <rs8887@att.com>2017-04-20 05:34:06 -0500
commitd5d7dd40f8b29a7a4921829bd6ccf9b670613af2 (patch)
treec93b970c711255a5468d82426ca1eb90ecdc8811 /integrity-monitor/src/test/java
parentc2aad6527c903cc3359ef9673d0706f37d4b89ec (diff)
Batch submit
[ECOMPD2TD-1073 1707] Removal of extra flush statements and addition of rollbacks in catch blocks instead of commits. [ECOMPD2TD-1073 1707] Adding some needed synchronized statements to IntegrityMonitor. [ECOMPD2TD-1159] - Loggers should be Serializable By making loggers Serializable, they can be included in Drools persistent data. 'EelfLogger' and 'SystemOutLogger' can do this trivially, but 'Logger4J' needed some additional work, because it has a non-serializable field 'log'. [ECOMPD2TD-000] Fix versioning of org.openecomp.policy.* dependencies [US866186 1707] First cut of stateCheck mod and non-working JUnit [US866186 1707] Completed the coding for the task TA1998344 which adds a check of forward progress for dependencies. [US866186 1707] Completed updates to IntegrityMonitor.stateCheck and IntegrityMonitorTest which includes addition of a JUnit for stateCheck and control of the order of JUnit execution. [US865296] ECOMP Policy Logging Compliance, add TargetEntity and TargetServiceName, remove unit from ElapsedTime [US865296] ECOMP Policy Logging Compliance, set audit log statuscode to 'COMPLETE' instead of N/A [US865296] ECOMP Policy Logging Compliance, remove time unit (seconds and milliseconds) from ElapsedTime for logging compliance [US866186 1707] Cleaned up IntegrityAudit JUnit tests. [US866186 1707] IntegrityMonitor JUnit clean up [US866186 1707] Re-added missing classes that were erroneously deleted. [US865296] - add get/setters and inits for required log fields Change-Id: I76ef4606ed6832ed48eaca68e72839a05c8bc3a8 Signed-off-by: Ralph Straubs <rs8887@att.com>
Diffstat (limited to 'integrity-monitor/src/test/java')
-rw-r--r--integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/IntegrityMonitorTest.java118
-rw-r--r--integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementTest.java7
-rw-r--r--integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateTransitionTest.java6
3 files changed, 121 insertions, 10 deletions
diff --git a/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/IntegrityMonitorTest.java b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/IntegrityMonitorTest.java
index 68a6cf2f..7375988e 100644
--- a/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/IntegrityMonitorTest.java
+++ b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/IntegrityMonitorTest.java
@@ -53,6 +53,11 @@ import org.openecomp.policy.common.im.jpa.StateManagementEntity;
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
import org.openecomp.policy.common.logging.flexlogger.Logger;
+/*
+ * All JUnits are designed to run in the local development environment
+ * where they have write privileges and can execute time-sensitive
+ * tasks.
+ */
public class IntegrityMonitorTest {
private static Logger logger = FlexLogger.getLogger(IntegrityMonitorTest.class);
private static Properties myProp;
@@ -103,6 +108,21 @@ public class IntegrityMonitorTest {
// clear jmx remote port setting
systemProps.remove("com.sun.management.jmxremote.port");
}
+
+ /*
+ * 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.
+ */
+ @Ignore
+ @Test
+ public void runAllTests() throws Exception{
+ testSanityJmx();
+ testIM();
+ testSanityState();
+ testRefreshStateAudit();
+ testStateCheck();
+ }
/*
* The following test verifies the following test cases:
@@ -114,8 +134,6 @@ public class IntegrityMonitorTest {
* Unlock
* Unlock restart
*/
- @Ignore // Test passed 10/18/16
- @Test
public void testSanityJmx() throws Exception {
System.out.println("\nIntegrityMonitorTest: Entering testSanityJmx\n\n");
@@ -267,8 +285,6 @@ public class IntegrityMonitorTest {
}
- @Ignore // Test passed 10/18/16
- @Test
public void testIM() throws Exception {
System.out.println("\nIntegrityMonitorTest: Entering testIM\n\n");
@@ -554,8 +570,6 @@ public class IntegrityMonitorTest {
}
- @Ignore // Test passed 10/18/16
- @Test
public void testSanityState() throws Exception {
System.out.println("\nIntegrityMonitorTest: Entering testSanityState\n\n");
@@ -618,8 +632,6 @@ public class IntegrityMonitorTest {
System.out.println("\n\ntestSanityState: Exit\n\n");
}
- @Ignore // Test passed 10/18/16
- @Test
public void testRefreshStateAudit() throws Exception {
logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Enter\n\n");
@@ -731,4 +743,94 @@ public class IntegrityMonitorTest {
logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Exit\n\n");
}
+
+ public void testStateCheck() throws Exception {
+ System.out.println("\nIntegrityMonitorTest: Entering testStateCheck\n\n");
+
+ // 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.
+ */
+
+ 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);
+
+ // Add a group1 dependent resources to put an entry in the forward progress table
+ // This sets lastUpdated to the current time
+ ForwardProgressEntity fpe = new ForwardProgressEntity();
+ fpe.setFpcCount(0);
+ fpe.setResourceName("group1_dep1");
+ et = em.getTransaction();
+ et.begin();
+ em.persist(fpe);
+ em.flush();
+ et.commit();
+
+ //Now add new group1 stateManager instances
+ StateManagement sm2 = new StateManagement(emf, "group1_dep1");
+
+ boolean sanityPass = true;
+ //Thread.sleep(15000);
+ Thread.sleep(5000);
+ try {
+ im.evaluateSanity();
+ } catch (Exception e) {
+ System.out.println("testStateCheck: After 15 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
+
+ sanityPass = true;
+ //Thread.sleep(30000);
+ Thread.sleep(10000);
+ try {
+ im.evaluateSanity();
+ } catch (Exception e) {
+ System.out.println("testStateCheck: After 10 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();
+
+ System.out.println("\n\ntestStateCheck: Exit\n\n");
+ }
+
}
diff --git a/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementTest.java b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementTest.java
index 3247d781..f51f5ac7 100644
--- a/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementTest.java
+++ b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateManagementTest.java
@@ -41,6 +41,7 @@ import javax.persistence.Query;
+
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -49,7 +50,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.openecomp.policy.common.im.StateManagement;
import org.openecomp.policy.common.im.StateTransition;
import org.openecomp.policy.common.im.StandbyStatusException;
@@ -57,6 +57,11 @@ import org.openecomp.policy.common.im.StateChangeNotifier;
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
import org.openecomp.policy.common.logging.flexlogger.Logger;
+/*
+ * All JUnits are designed to run in the local development environment
+ * where they have write privileges and can execute time-sensitive
+ * tasks.
+ */
public class StateManagementTest {
private static Logger logger = FlexLogger.getLogger(StateManagementTest.class);
diff --git a/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateTransitionTest.java b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateTransitionTest.java
index b0e6e18e..d76cad0d 100644
--- a/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateTransitionTest.java
+++ b/integrity-monitor/src/test/java/org/openecomp/policy/common/im/test/StateTransitionTest.java
@@ -50,7 +50,11 @@ import org.openecomp.policy.common.im.StandbyStatusException;
import org.openecomp.policy.common.im.StateChangeNotifier;
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
import org.openecomp.policy.common.logging.flexlogger.Logger;
-
+/*
+ * All JUnits are designed to run in the local development environment
+ * where they have write privileges and can execute time-sensitive
+ * tasks.
+ */
public class StateTransitionTest {
private static Logger logger = FlexLogger.getLogger(StateTransitionTest.class);