aboutsummaryrefslogtreecommitdiffstats
path: root/integrity-monitor
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-02-13 09:19:43 -0500
committerJim Hahn <jrh3@att.com>2018-02-13 19:21:55 -0500
commitbf2cc29bf766feabca8ef633926f5fce00a5fe2e (patch)
tree6094d9294378fe7226a3ed7e287dc0381b067fcf /integrity-monitor
parent86664073b5a778c56e831d64b3a1883818af0ffe (diff)
Add test coverage to integrity-monitor
Removed "test" from package name. Refactored tests, creating common IntegrityMonitorTestBase. Turned log/print statements into assertEquals in StateTransitionTest. Turned log/print statements into assertEquals in StateManagementTest. Modified AllSeemsWellTest to use IntegrityMonitorTestBase. Modified IntegrityMonitorTest to use IntegrityMonitorTestBase. Added several hooks to IntegrityMonitor to control timers at a finer granularity. Added hooks to IntegrityMonitor to control the FPManager thread. Remove hooks for refresh timer, as property suffices. Added assertException() and assertNoException() methods to IntegrityMonitorTestBase, and then replaced most "try/catch" blocks with calls to those methods. Updated StateManagement to close EntityManagers. Modify pom to remove scope from utils dependency. Fix some comments and remove an unneeded EntityTransaction variable. Change-Id: Ic0789d26f985a40a35f618343fa4e88aa473b2b3 Issue-ID: POLICY-582 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'integrity-monitor')
-rw-r--r--integrity-monitor/pom.xml9
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java1030
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java411
-rw-r--r--integrity-monitor/src/main/resources/META-INF/persistence.xml3
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java173
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/ExceptionsTest.java (renamed from integrity-monitor/src/test/java/org/onap/policy/common/im/test/ExceptionsTest.java)2
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java907
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java306
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java130
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java239
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/StateTransitionTest.java (renamed from integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateTransitionTest.java)1112
-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.java1095
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementEntityTest.java193
-rw-r--r--integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementTest.java315
15 files changed, 2970 insertions, 3220 deletions
diff --git a/integrity-monitor/pom.xml b/integrity-monitor/pom.xml
index 67b035aa..4e69ccea 100644
--- a/integrity-monitor/pom.xml
+++ b/integrity-monitor/pom.xml
@@ -2,7 +2,7 @@
============LICENSE_START=======================================================
ONAP Policy Engine - Common Modules
================================================================================
- Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2017-2018 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.
@@ -42,6 +42,11 @@
<version>1.2.17</version>
</dependency>
<dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
@@ -50,7 +55,7 @@
<dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>utils-test</artifactId>
- <version>${project.version}</version>
+ <version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
index 17223ba3..d272d1c6 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
@@ -1,8 +1,8 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -29,6 +29,8 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.management.JMX;
@@ -42,12 +44,12 @@ import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.validation.constraints.NotNull;
-import org.onap.policy.common.im.jpa.ForwardProgressEntity;
-import org.onap.policy.common.im.jpa.ResourceRegistrationEntity;
-import org.onap.policy.common.im.jpa.StateManagementEntity;
import org.onap.policy.common.im.jmx.ComponentAdmin;
import org.onap.policy.common.im.jmx.ComponentAdminMBean;
import org.onap.policy.common.im.jmx.JmxAgentConnection;
+import org.onap.policy.common.im.jpa.ForwardProgressEntity;
+import org.onap.policy.common.im.jpa.ResourceRegistrationEntity;
+import org.onap.policy.common.im.jpa.StateManagementEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,8 +58,7 @@ import org.slf4j.LoggerFactory;
* managing its state. State management follows the X.731 ITU standard.
*/
public class IntegrityMonitor {
- private static final Logger logger = LoggerFactory
- .getLogger(IntegrityMonitor.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(IntegrityMonitor.class.getName());
// only allow one instance of IntegrityMonitor
private static IntegrityMonitor instance = null;
@@ -76,11 +77,21 @@ public class IntegrityMonitor {
private EntityManager em;
// Persistence Unit for JPA
- private static final String PERSISTENCE_UNIT = "operationalPU";
+ public static final String PERSISTENCE_UNIT = "operationalPU";
- private StateManagement stateManager = null;
+ private static String persistenceUnit = PERSISTENCE_UNIT;
+
+ private static final long CYCLE_INTERVAL_MILLIS = 1000l;
+
+ private static long cycleIntervalMillis = CYCLE_INTERVAL_MILLIS;
- private static final int CYCLE_INTERVAL_MILLIS = 1000;
+ /**
+ * Units used for intervals extracted from the properties, which are
+ * typically given in seconds.
+ */
+ private static TimeUnit propertyUnits = TimeUnit.SECONDS;
+
+ private StateManagement stateManager = null;
private FPManager fpManager = null;
@@ -118,17 +129,17 @@ public class IntegrityMonitor {
private int missedCycles = 0;
// forward progress monitoring interval
- private static int monitorInterval = IntegrityMonitorProperties.DEFAULT_MONITOR_INTERVAL;
+ private static long monitorIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_MONITOR_INTERVAL;
// The number of periods the counter fails to increment before an alarm is
// raised.
private static int failedCounterThreshold = IntegrityMonitorProperties.DEFAULT_FAILED_COUNTER_THRESHOLD;
// test transaction interval
- private static int testTransInterval = IntegrityMonitorProperties.DEFAULT_TEST_INTERVAL;
+ private static long testTransIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_TEST_INTERVAL;
// write Fpc to DB interval
- private static int writeFpcInterval = IntegrityMonitorProperties.DEFAULT_WRITE_FPC_INTERVAL;
+ private static long writeFpcIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_WRITE_FPC_INTERVAL;
// check the health of dependencies
- private static int checkDependencyInterval = IntegrityMonitorProperties.DEFAULT_CHECK_DEPENDENCY_INTERVAL;
-
+ private static long checkDependencyIntervalMs = 1000L
+ * IntegrityMonitorProperties.DEFAULT_CHECK_DEPENDENCY_INTERVAL;
// A lead subsystem will have dependency groups with resource names in the
// properties file.
@@ -136,16 +147,16 @@ public class IntegrityMonitor {
private static String[] depGroups = null;
private static boolean isUnitTesting = false;
-
+
// can turn on health checking of dependents via jmx test() call by setting
// this property to true
private static boolean testViaJmx = false;
private static String jmxFqdn = null;
- // this is the max interval seconds allowed without any forward progress
+ // this is the max interval allowed without any forward progress
// counter updates
- private static int maxFpcUpdateInterval = IntegrityMonitorProperties.DEFAULT_MAX_FPC_UPDATE_INTERVAL;
+ private static long maxFpcUpdateIntervalMs = 1000L * IntegrityMonitorProperties.DEFAULT_MAX_FPC_UPDATE_INTERVAL;
// Node types
private enum NodeType {
@@ -171,7 +182,7 @@ public class IntegrityMonitor {
private static final Object getInstanceLock = new Object();
private final Object refreshStateAuditLock = new Object();
private final Object imFlushLock = new Object();
-
+
private Map<String, String> allSeemsWellMap;
private Map<String, String> allNotWellMap;
@@ -187,9 +198,30 @@ public class IntegrityMonitor {
* @param properties
* a set of properties passed in from the resource
* @throws Exception
- * if any errors are encountered in the consructor
+ * if any errors are encountered in the constructor
+ */
+ protected IntegrityMonitor(String resourceName, Properties properties) throws Exception {
+
+ this(resourceName, properties, null);
+ }
+
+ /**
+ * IntegrityMonitor constructor. It is invoked from the getInstance() method
+ * in this class or from the constructor of a child or sub-class. A class
+ * can extend the IntegrityMonitor class if there is a need to override any
+ * of the base methods (ex. subsystemTest()). Only one instance is allowed
+ * to be created per resource name.
+ *
+ * @param resourceName
+ * The resource name of the resource
+ * @param properties
+ * a set of properties passed in from the resource
+ * @param queue
+ * queue to use to control the FPManager thread, or {@code null}
+ * @throws Exception
+ * if any errors are encountered in the constructor
*/
- protected IntegrityMonitor(String resourceName, Properties properties)
+ protected IntegrityMonitor(String resourceName, Properties properties, BlockingQueue<CountDownLatch> queue)
throws Exception {
// singleton check since this constructor can be called from a child or
@@ -197,8 +229,7 @@ public class IntegrityMonitor {
if (instance != null) {
String msg = "IM object exists and only one instance allowed";
logger.error("{}", msg);
- throw new IntegrityMonitorException(
- "IntegrityMonitor constructor exception: " + msg);
+ throw new IntegrityMonitorException("IntegrityMonitor constructor exception: " + msg);
}
instance = this;
@@ -216,17 +247,13 @@ public class IntegrityMonitor {
//
// Create the entity manager factory
//
- emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT,
- properties);
+ emf = Persistence.createEntityManagerFactory(persistenceUnit, properties);
//
// Did it get created?
//
if (emf == null) {
- logger.error(
- "Error creating IM entity manager factory with persistence unit: {}",
- PERSISTENCE_UNIT);
- throw new IntegrityMonitorException(
- "Unable to create IM Entity Manager Factory");
+ logger.error("Error creating IM entity manager factory with persistence unit: {}", persistenceUnit);
+ throw new IntegrityMonitorException("Unable to create IM Entity Manager Factory");
}
// add entry to forward progress and resource registration tables in DB
@@ -240,13 +267,11 @@ public class IntegrityMonitor {
try {
// if ForwardProgress entry exists for resourceName, update it. If
// not found, create a new entry
- Query fquery = em
- .createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
+ Query fquery = em.createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
fquery.setParameter("rn", resourceName);
@SuppressWarnings("rawtypes")
- List fpList = fquery.setLockMode(LockModeType.NONE)
- .setFlushMode(FlushModeType.COMMIT).getResultList();
+ List fpList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
ForwardProgressEntity fpx = null;
if (!fpList.isEmpty()) {
// ignores multiple results
@@ -254,10 +279,8 @@ public class IntegrityMonitor {
// refresh the object from DB in case cached data was returned
em.refresh(fpx);
if (logger.isDebugEnabled()) {
- logger.debug(
- "Resource {} exists and will be updated - old fpc= {}, lastUpdated= {}",
- resourceName, fpx.getFpcCount(),
- fpx.getLastUpdated());
+ logger.debug("Resource {} exists and will be updated - old fpc= {}, lastUpdated= {}", resourceName,
+ fpx.getFpcCount(), fpx.getLastUpdated());
}
fpx.setFpcCount(fpCounter);
} else {
@@ -275,13 +298,11 @@ public class IntegrityMonitor {
// if ResourceRegistration entry exists for resourceName, update it.
// If not found, create a new entry
- Query rquery = em
- .createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
+ Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
rquery.setParameter("rn", resourceName);
@SuppressWarnings("rawtypes")
- List rrList = rquery.setLockMode(LockModeType.NONE)
- .setFlushMode(FlushModeType.COMMIT).getResultList();
+ List rrList = rquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
ResourceRegistrationEntity rrx = null;
if (!rrList.isEmpty()) {
// ignores multiple results
@@ -289,10 +310,8 @@ public class IntegrityMonitor {
// refresh the object from DB in case cached data was returned
em.refresh(rrx);
if (logger.isDebugEnabled()) {
- logger.debug(
- "Resource {} exists and will be updated - old url= {}, createdDate={}",
- resourceName, rrx.getResourceUrl(),
- rrx.getCreatedDate());
+ logger.debug("Resource {} exists and will be updated - old url= {}, createdDate={}", resourceName,
+ rrx.getResourceUrl(), rrx.getCreatedDate());
}
rrx.setLastUpdated(new Date());
} else {
@@ -312,9 +331,7 @@ public class IntegrityMonitor {
}
} catch (Exception e) {
- logger.error(
- "IntegrityMonitor constructor DB table update failed with exception: ",
- e);
+ logger.error("IntegrityMonitor constructor DB table update failed with exception: ", e);
try {
if (et.isActive()) {
synchronized (imFlushLock) {
@@ -322,8 +339,7 @@ public class IntegrityMonitor {
}
}
} catch (Exception e1) {
- logger.error("IntegrityMonitor constructor threw exception: ",
- e1);
+ logger.error("IntegrityMonitor constructor threw exception: ", e1);
}
throw e;
}
@@ -345,11 +361,10 @@ public class IntegrityMonitor {
try {
new ComponentAdmin(resourceName, this, stateManager);
} catch (Exception e) {
- logger.error("ComponentAdmin constructor exception: {}",
- e.toString(), e);
+ logger.error("ComponentAdmin constructor exception: {}", e.toString(), e);
}
- fpManager = new FPManager();
+ fpManager = new FPManager(queue);
}
@@ -367,19 +382,39 @@ public class IntegrityMonitor {
* if unable to create jmx url or the constructor returns an
* exception
*/
- public static IntegrityMonitor getInstance(String resourceName,
- Properties properties) throws Exception {
+ public static IntegrityMonitor getInstance(String resourceName, Properties properties) throws Exception {
+ return getInstance(resourceName, properties, null);
+ }
+
+ /**
+ * Get an instance of IntegrityMonitor for a given resource name. It creates
+ * one if it does not exist. Only one instance is allowed to be created per
+ * resource name.
+ *
+ * @param resourceName
+ * The resource name of the resource
+ * @param properties
+ * a set of properties passed in from the resource
+ * @param queue
+ * queue to use to control the FPManager thread, or {@code null}
+ * @return The new instance of IntegrityMonitor
+ * @throws Exception
+ * if unable to create jmx url or the constructor returns an
+ * exception
+ */
+ protected static IntegrityMonitor getInstance(String resourceName, Properties properties,
+ BlockingQueue<CountDownLatch> queue) throws Exception {
+
synchronized (getInstanceLock) {
logger.debug("getInstance() called - resourceName= {}", resourceName);
- if (resourceName == null || resourceName.isEmpty()
- || properties == null) {
+ if (resourceName == null || resourceName.isEmpty() || properties == null) {
logger.error("Error: getIntegrityMonitorInstance() called with invalid input");
return null;
}
if (instance == null) {
logger.debug("Creating new instance of IntegrityMonitor");
- instance = new IntegrityMonitor(resourceName, properties);
+ instance = new IntegrityMonitor(resourceName, properties, queue);
}
return instance;
}
@@ -398,28 +433,34 @@ public class IntegrityMonitor {
/*
* This is a facility used by JUnit testing to destroy the IntegrityMonitor
- * instance before creating a new one. It includes a delay of 2 seconds to
- * allow the FPManager to fully exit.
+ * instance before creating a new one. It waits a bit to allow the FPManager
+ * to fully exit.
*/
public static void deleteInstance() throws IntegrityMonitorException {
logger.debug("deleteInstance() called");
- if (isUnitTesting() && instance != null && instance.getFPManager() != null) {
- // Stop the FPManager thread
- instance.getFPManager().stopAndExit();
+ synchronized (getInstanceLock) {
+ if (isUnitTesting() && instance != null && instance.getFPManager() != null) {
+ FPManager fpm = instance.getFPManager();
- try {
- // Make sure it has exited
- Thread.sleep(2L * CYCLE_INTERVAL_MILLIS);
- } catch (InterruptedException e) {
- logger.error("deleteInstance: Interrupted while waiting for FPManaager to fully exit", e);
- Thread.currentThread().interrupt();
- }
- if (instance.getFPManager().isAlive()) {
- logger.error("IntegrityMonitor.deleteInstance() Failed to kill FPManager thread");
- throw new IntegrityMonitorException(
- "IntegrityMonitor.deleteInstance() Failed to kill FPManager thread");
+ // Stop the FPManager thread
+ fpm.stopAndExit();
+
+ try {
+ // Make sure it has exited
+ fpm.join(2000L);
+ } catch (InterruptedException e) {
+ logger.error("deleteInstance: Interrupted while waiting for FPManaager to fully exit", e);
+ Thread.currentThread().interrupt();
+ }
+
+ if (fpm.isAlive()) {
+ logger.error("IntegrityMonitor.deleteInstance() Failed to kill FPManager thread");
+ throw new IntegrityMonitorException(
+ "IntegrityMonitor.deleteInstance() Failed to kill FPManager thread");
+ }
+
+ instance = null;
}
- instance = null;
}
logger.debug("deleteInstance() exit");
}
@@ -432,25 +473,21 @@ public class IntegrityMonitor {
// get the jmx remote port and construct the JMX URL
Properties systemProps = System.getProperties();
- String jmxPort = systemProps
- .getProperty("com.sun.management.jmxremote.port");
+ String jmxPort = systemProps.getProperty("com.sun.management.jmxremote.port");
String jmxErrMsg;
if (jmxPort == null) {
jmxErrMsg = "System property com.sun.management.jmxremote.port for JMX remote port is not set";
logger.error("{}", jmxErrMsg);
- throw new IntegrityMonitorException("getJmxUrl exception: "
- + jmxErrMsg);
+ throw new IntegrityMonitorException("getJmxUrl exception: " + jmxErrMsg);
}
int port = 0;
try {
port = Integer.parseInt(jmxPort);
} catch (NumberFormatException e) {
- jmxErrMsg = "JMX remote port is not a valid integer value - "
- + jmxPort;
+ jmxErrMsg = "JMX remote port is not a valid integer value - " + jmxPort;
logger.error("{}", jmxErrMsg);
- throw new IntegrityMonitorException("getJmxUrl exception: "
- + jmxErrMsg);
+ throw new IntegrityMonitorException("getJmxUrl exception: " + jmxErrMsg);
}
try {
@@ -473,8 +510,7 @@ public class IntegrityMonitor {
}
// assemble the jmx url
- String jmxUrl = "service:jmx:rmi:///jndi/rmi://" + jmxFqdn + ":"
- + port + "/jmxrmi";
+ String jmxUrl = "service:jmx:rmi:///jndi/rmi://" + jmxFqdn + ":" + port + "/jmxrmi";
logger.debug("IntegerityMonitor - jmx url={}", jmxUrl);
@@ -495,33 +531,24 @@ public class IntegrityMonitor {
String errorMsg = dependencyCheckErrorMsg;
logger.debug("evaluateSanity dependencyCheckErrorMsg = {}", errorMsg);
// check op state and throw exception if disabled
- if ((stateManager.getOpState() != null)
- && stateManager.getOpState().equals(
- StateManagement.DISABLED)) {
- String msg = "Resource " + resourceName
- + " operation state is disabled. " + errorMsg;
+ if ((stateManager.getOpState() != null) && stateManager.getOpState().equals(StateManagement.DISABLED)) {
+ String msg = "Resource " + resourceName + " operation state is disabled. " + errorMsg;
logger.debug("{}", msg);
throw new IntegrityMonitorException(msg);
}
// check admin state and throw exception if locked
- if ((stateManager.getAdminState() != null)
- && stateManager.getAdminState().equals(
- StateManagement.LOCKED)) {
- String msg = "Resource " + resourceName
- + " is administratively locked";
+ if ((stateManager.getAdminState() != null) && stateManager.getAdminState().equals(StateManagement.LOCKED)) {
+ String msg = "Resource " + resourceName + " is administratively locked";
logger.debug("{}", msg);
- throw new AdministrativeStateException(
- "IntegrityMonitor Admin State Exception: " + msg);
+ throw new AdministrativeStateException("IntegrityMonitor Admin State Exception: " + msg);
}
// check standby state and throw exception if cold standby
if ((stateManager.getStandbyStatus() != null)
- && stateManager.getStandbyStatus().equals(
- StateManagement.COLD_STANDBY)) {
+ && stateManager.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
String msg = "Resource " + resourceName + " is cold standby";
logger.debug("{}", msg);
- throw new StandbyStatusException(
- "IntegrityMonitor Standby Status Exception: " + msg);
+ throw new StandbyStatusException("IntegrityMonitor Standby Status Exception: " + msg);
}
}
@@ -545,13 +572,11 @@ public class IntegrityMonitor {
et.begin();
try {
- Query query = em
- .createQuery("Select p from ForwardProgressEntity p where p.resourceName=:resource");
+ Query query = em.createQuery("Select p from ForwardProgressEntity p where p.resourceName=:resource");
query.setParameter("resource", dep);
@SuppressWarnings("rawtypes")
- List fpList = query.setLockMode(LockModeType.NONE)
- .setFlushMode(FlushModeType.COMMIT).getResultList();
+ List fpList = query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
if (!fpList.isEmpty()) {
// exists
@@ -560,8 +585,7 @@ public class IntegrityMonitor {
em.refresh(forwardProgressEntity);
logger.debug("Found entry in ForwardProgressEntity table for dependent Resource={}", dep);
} else {
- errorMsg = dep
- + ": resource not found in ForwardProgressEntity database table";
+ errorMsg = dep + ": resource not found in ForwardProgressEntity database table";
logger.error("{}", errorMsg);
}
synchronized (imFlushLock) {
@@ -569,8 +593,7 @@ public class IntegrityMonitor {
}
} catch (Exception ex) {
// log an error
- errorMsg = dep
- + ": ForwardProgressEntity DB operation failed with exception: ";
+ errorMsg = dep + ": ForwardProgressEntity DB operation failed with exception: ";
logger.error("{}", errorMsg, ex);
synchronized (imFlushLock) {
if (et.isActive()) {
@@ -585,24 +608,20 @@ public class IntegrityMonitor {
et.begin();
try {
// query if StateManagement entry exists for dependent resource
- Query query = em
- .createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+ Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
query.setParameter("resource", dep);
@SuppressWarnings("rawtypes")
- List smList = query.setLockMode(LockModeType.NONE)
- .setFlushMode(FlushModeType.COMMIT).getResultList();
+ List smList = query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
if (!smList.isEmpty()) {
// exist
- stateManagementEntity = (StateManagementEntity) smList
- .get(0);
+ stateManagementEntity = (StateManagementEntity) smList.get(0);
// refresh the object from DB in case cached data was
// returned
em.refresh(stateManagementEntity);
logger.debug("Found entry in StateManagementEntity table for dependent Resource={}", dep);
} else {
- errorMsg = dep
- + ": resource not found in state management entity database table";
+ errorMsg = dep + ": resource not found in state management entity database table";
logger.error("{}", errorMsg);
}
@@ -611,8 +630,7 @@ public class IntegrityMonitor {
}
} catch (Exception e) {
// log an error
- errorMsg = dep
- + ": StateManagementEntity DB read failed with exception: ";
+ errorMsg = dep + ": StateManagementEntity DB read failed with exception: ";
logger.error("{}", errorMsg, e);
synchronized (imFlushLock) {
if (et.isActive()) {
@@ -626,39 +644,37 @@ public class IntegrityMonitor {
if (errorMsg == null) {
if (forwardProgressEntity != null && stateManagementEntity != null) {
Date date = new Date();
- long diffMs = date.getTime()
- - forwardProgressEntity.getLastUpdated().getTime();
+ long diffMs = date.getTime() - forwardProgressEntity.getLastUpdated().getTime();
logger.debug("IntegrityMonitor.stateCheck(): diffMs = {}", diffMs);
// Threshold for a stale entry
- long staleMs = 1000L * maxFpcUpdateInterval;
+ long staleMs = maxFpcUpdateIntervalMs;
logger.debug("IntegrityMonitor.stateCheck(): staleMs = {}", staleMs);
if (diffMs > staleMs) {
// ForwardProgress is stale. Disable it
try {
- if (!stateManagementEntity.getOpState().equals(
- StateManagement.DISABLED)) {
+ if (!stateManagementEntity.getOpState().equals(StateManagement.DISABLED)) {
logger.debug("IntegrityMonitor.stateCheck(): Changing OpStat = disabled for {}", dep);
stateManager.disableFailed(dep);
}
} catch (Exception e) {
- String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = "
- + dep + "; " + e.getMessage();
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + e.getMessage();
logger.error("{}", msg, e);
}
}
} else {
if (forwardProgressEntity == null) {
- String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = "
- + dep + "; " + " forwardProgressEntity == null.";
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + " forwardProgressEntity == null.";
logger.error("{}", msg);
}
else {
- String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = "
- + dep + "; " + " stateManagementEntity == null.";
+ String msg = "IntegrityMonitor.stateCheck(): Failed to diableFail dependent resource = " + dep
+ + "; " + " stateManagementEntity == null.";
logger.error("{}", msg);
}
}
@@ -668,30 +684,25 @@ public class IntegrityMonitor {
if (errorMsg == null) {
if (stateManagementEntity != null) {
if ((stateManager.getAdminState() != null)
- && stateManagementEntity.getAdminState().equals(
- StateManagement.LOCKED)) {
+ && stateManagementEntity.getAdminState().equals(StateManagement.LOCKED)) {
errorMsg = dep + ": resource is administratively locked";
logger.error("{}", errorMsg);
} else if ((stateManager.getOpState() != null)
- && stateManagementEntity.getOpState().equals(
- StateManagement.DISABLED)) {
+ && stateManagementEntity.getOpState().equals(StateManagement.DISABLED)) {
errorMsg = dep + ": resource is operationally disabled";
logger.error("{}", errorMsg);
} else if ((stateManager.getStandbyStatus() != null)
- && stateManagementEntity.getStandbyStatus().equals(
- StateManagement.COLD_STANDBY)) {
+ && stateManagementEntity.getStandbyStatus().equals(StateManagement.COLD_STANDBY)) {
errorMsg = dep + ": resource is cold standby";
logger.error("{}", errorMsg);
}
} else {
- errorMsg = dep
- + ": could not check standy state of resource. stateManagementEntity == null.";
+ errorMsg = dep + ": could not check standy state of resource. stateManagementEntity == null.";
logger.error("{}", errorMsg);
}
}
- String returnMsg = "IntegrityMonitor.stateCheck(): returned error_msg: "
- + errorMsg;
+ String returnMsg = "IntegrityMonitor.stateCheck(): returned error_msg: " + errorMsg;
logger.debug("{}", returnMsg);
return errorMsg;
}
@@ -708,13 +719,11 @@ public class IntegrityMonitor {
EntityTransaction et = em.getTransaction();
et.begin();
try {
- Query fquery = em
- .createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
+ Query fquery = em.createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
fquery.setParameter("rn", dep);
@SuppressWarnings("rawtypes")
- List fpList = fquery.setLockMode(LockModeType.NONE)
- .setFlushMode(FlushModeType.COMMIT).getResultList();
+ List fpList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
ForwardProgressEntity fpx;
if (!fpList.isEmpty()) {
// ignores multiple results
@@ -722,38 +731,32 @@ public class IntegrityMonitor {
// refresh the object from DB in case cached data was returned
em.refresh(fpx);
if (logger.isDebugEnabled()) {
- logger.debug(
- "Dependent resource {} - fpc= {}, lastUpdated={}",
- dep, fpx.getFpcCount(), fpx.getLastUpdated());
+ logger.debug("Dependent resource {} - fpc= {}, lastUpdated={}", dep, fpx.getFpcCount(),
+ fpx.getLastUpdated());
}
long currTime = System.currentTimeMillis();
// if dependent resource FPC has not been updated, consider it
// an error
- if ((currTime - fpx.getLastUpdated().getTime()) > (1000 * maxFpcUpdateInterval)) {
- errorMsg = dep
- + ": FP count has not been updated in the last "
- + maxFpcUpdateInterval + " seconds";
+ if ((currTime - fpx.getLastUpdated().getTime()) > maxFpcUpdateIntervalMs) {
+ errorMsg = dep + ": FP count has not been updated in the last " + maxFpcUpdateIntervalMs + "ms";
logger.error("{}", errorMsg);
try {
// create instance of StateMangement class for dependent
- StateManagement depStateManager = new StateManagement(
- emf, dep);
- if (!depStateManager.getOpState().equals(
- StateManagement.DISABLED)) {
- logger.debug("Forward progress not detected for dependent resource {}. Setting dependent's state to disable failed.", dep);
+ StateManagement depStateManager = new StateManagement(emf, dep);
+ if (!depStateManager.getOpState().equals(StateManagement.DISABLED)) {
+ logger.debug(
+ "Forward progress not detected for dependent resource {}. Setting dependent's state to disable failed.",
+ dep);
depStateManager.disableFailed();
}
} catch (Exception e) {
// ignore errors
- logger.error(
- "Update dependent state failed with exception: ",
- e);
+ logger.error("Update dependent state failed with exception: ", e);
}
}
} else {
// resource entry not found in FPC table
- errorMsg = dep
- + ": resource not found in ForwardProgressEntity table in the DB";
+ errorMsg = dep + ": resource not found in ForwardProgressEntity table in the DB";
logger.error("{}", errorMsg);
}
synchronized (imFlushLock) {
@@ -761,8 +764,7 @@ public class IntegrityMonitor {
}
} catch (Exception e) {
// log an error and continue
- errorMsg = dep
- + ": ForwardProgressEntity DB read failed with exception: ";
+ errorMsg = dep + ": ForwardProgressEntity DB read failed with exception: ";
logger.error("{}", errorMsg, e);
synchronized (imFlushLock) {
if (et.isActive()) {
@@ -781,11 +783,9 @@ public class IntegrityMonitor {
EntityTransaction et = em.getTransaction();
et.begin();
try {
- Query fquery = em
- .createQuery("Select e from ForwardProgressEntity e");
+ Query fquery = em.createQuery("Select e from ForwardProgressEntity e");
@SuppressWarnings("rawtypes")
- List myList = fquery.setLockMode(LockModeType.NONE)
- .setFlushMode(FlushModeType.COMMIT).getResultList();
+ List myList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
synchronized (imFlushLock) {
et.commit();
}
@@ -793,10 +793,8 @@ public class IntegrityMonitor {
if (!myList.isEmpty()) {
for (int i = 0; i < myList.size(); i++) {
if (logger.isDebugEnabled()) {
- logger.debug(
- "getAllForwardProgressEntity: myList.get({}).getResourceName(): {}",
- i, ((ForwardProgressEntity) myList.get(i))
- .getResourceName());
+ logger.debug("getAllForwardProgressEntity: myList.get({}).getResourceName(): {}", i,
+ ((ForwardProgressEntity) myList.get(i)).getResourceName());
}
fpList.add((ForwardProgressEntity) myList.get(i));
}
@@ -831,13 +829,11 @@ public class IntegrityMonitor {
et.begin();
try {
// query if ResourceRegistration entry exists for resourceName
- Query rquery = em
- .createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
+ Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
rquery.setParameter("rn", dep);
@SuppressWarnings("rawtypes")
- List rrList = rquery.setLockMode(LockModeType.NONE)
- .setFlushMode(FlushModeType.COMMIT).getResultList();
+ List rrList = rquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
ResourceRegistrationEntity rrx = null;
if (!rrList.isEmpty()) {
@@ -847,13 +843,10 @@ public class IntegrityMonitor {
em.refresh(rrx);
jmxUrl = rrx.getResourceUrl();
if (logger.isDebugEnabled()) {
- logger.debug(
- "Dependent Resource={}, url={}, createdDate={}",
- dep, jmxUrl, rrx.getCreatedDate());
+ logger.debug("Dependent Resource={}, url={}, createdDate={}", dep, jmxUrl, rrx.getCreatedDate());
}
} else {
- errorMsg = dep
- + ": resource not found in ResourceRegistrationEntity table in the DB";
+ errorMsg = dep + ": resource not found in ResourceRegistrationEntity table in the DB";
logger.error("{}", errorMsg);
}
@@ -861,8 +854,7 @@ public class IntegrityMonitor {
et.commit();
}
} catch (Exception e) {
- errorMsg = dep
- + ": ResourceRegistrationEntity DB read failed with exception: ";
+ errorMsg = dep + ": ResourceRegistrationEntity DB read failed with exception: ";
logger.error("{}", errorMsg, e);
synchronized (imFlushLock) {
if (et.isActive()) {
@@ -875,18 +867,15 @@ public class IntegrityMonitor {
JmxAgentConnection jmxAgentConnection = null;
try {
jmxAgentConnection = new JmxAgentConnection(jmxUrl);
- MBeanServerConnection mbeanServer = jmxAgentConnection
- .getMBeanConnection();
- ComponentAdminMBean admin = JMX.newMXBeanProxy(mbeanServer,
- ComponentAdmin.getObjectName(dep),
+ MBeanServerConnection mbeanServer = jmxAgentConnection.getMBeanConnection();
+ ComponentAdminMBean admin = JMX.newMXBeanProxy(mbeanServer, ComponentAdmin.getObjectName(dep),
ComponentAdminMBean.class);
// invoke the test method via the jmx proxy
admin.test();
logger.debug("Dependent resource {} sanity test passed", dep);
} catch (Exception e) {
- errorMsg = dep
- + ": resource sanity test failed with exception: ";
+ errorMsg = dep + ": resource sanity test failed with exception: ";
logger.error("{}", errorMsg, e);
} finally {
// close the JMX connector
@@ -928,19 +917,15 @@ public class IntegrityMonitor {
if (!errorMsg.isEmpty()) {
errorMsg = errorMsg.concat(",");
}
- errorMsg = errorMsg.concat(resourceName + ": "
- + e.getMessage());
+ errorMsg = errorMsg.concat(resourceName + ": " + e.getMessage());
this.stateManager.disableDependency();
} catch (Exception ex) {
logger.error("IntegrityMonitor threw exception.", ex);
if (!errorMsg.isEmpty()) {
errorMsg = errorMsg.concat(",");
}
- errorMsg = errorMsg
- .concat("\n"
- + resourceName
- + ": Failed to disable dependency after subsystemTest failure due to: "
- + ex.getMessage());
+ errorMsg = errorMsg.concat("\n" + resourceName
+ + ": Failed to disable dependency after subsystemTest failure due to: " + ex.getMessage());
}
}
@@ -955,8 +940,7 @@ public class IntegrityMonitor {
}
String[] dependencies = group.split(",");
if (logger.isDebugEnabled()) {
- logger.debug("group dependencies = {}",
- Arrays.toString(dependencies));
+ logger.debug("group dependencies = {}", Arrays.toString(dependencies));
}
int realDepCount = 0;
int failDepCount = 0;
@@ -967,7 +951,7 @@ public class IntegrityMonitor {
continue;
}
realDepCount++; // this is a valid dependency whose
- // state is tracked
+ // state is tracked
String failMsg = fpCheck(dep); // if a resource is
// down, its FP count
// will not be
@@ -986,18 +970,21 @@ public class IntegrityMonitor {
}
errorMsg = errorMsg.concat(failMsg);
}
- }// end for (String dep : dependencies)
+ } // end for (String dep : dependencies)
// if all dependencies in a group are failed, set this
// resource's state to disable dependency
- if ((realDepCount > 0)
- && (failDepCount == realDepCount)) {
+ if ((realDepCount > 0) && (failDepCount == realDepCount)) {
dependencyFailure = true;
try {
- logger.debug("All dependents in group {} have failed their health check. Updating this resource's state to disableDependency", group);
- if(stateManager.getAvailStatus()== null || !( (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY) ||
- (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED) ) ){
- // Note: redundant calls are made by refreshStateAudit
+ logger.debug(
+ "All dependents in group {} have failed their health check. Updating this resource's state to disableDependency",
+ group);
+ if (stateManager.getAvailStatus() == null || !((stateManager.getAvailStatus())
+ .equals(StateManagement.DEPENDENCY)
+ || (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED))) {
+ // Note: redundant calls are made by
+ // refreshStateAudit
this.stateManager.disableDependency();
}
} catch (Exception e) {
@@ -1005,15 +992,14 @@ public class IntegrityMonitor {
if (!errorMsg.isEmpty()) {
errorMsg = errorMsg.concat(",");
}
- errorMsg = errorMsg.concat(resourceName
- + ": Failed to disable dependency");
+ errorMsg = errorMsg.concat(resourceName + ": Failed to disable dependency");
break; // break out on failure and skip checking
// other groups
}
}
// check the next group
- }// end for (String group : depGroups)
+ } // end for (String group : depGroups)
/*
* We have checked all the dependency groups. If all are ok and
@@ -1021,19 +1007,22 @@ public class IntegrityMonitor {
*/
if (!dependencyFailure) {
try {
- logger.debug("All dependency groups have at least one viable member. Updating this resource's state to enableNoDependency");
- if(stateManager.getAvailStatus() != null && ((stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY) ||
- (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED)) ){
- // Note: redundant calls are made by refreshStateAudit
- this.stateManager.enableNoDependency();
- } // The refreshStateAudit will catch the case where it is disabled but availStatus != failed
+ logger.debug(
+ "All dependency groups have at least one viable member. Updating this resource's state to enableNoDependency");
+ if (stateManager.getAvailStatus() != null
+ && ((stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY)
+ || (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED))) {
+ // Note: redundant calls are made by
+ // refreshStateAudit
+ this.stateManager.enableNoDependency();
+ } // The refreshStateAudit will catch the case where it
+ // is disabled but availStatus != failed
} catch (Exception e) {
logger.error("IntegrityMonitor threw exception.", e);
if (!errorMsg.isEmpty()) {
errorMsg = errorMsg.concat(",");
}
- errorMsg = errorMsg.concat(resourceName
- + ": Failed to enable no dependency");
+ errorMsg = errorMsg.concat(resourceName + ": Failed to enable no dependency");
}
}
} else if (!dependencyFailure) {
@@ -1046,26 +1035,24 @@ public class IntegrityMonitor {
*/
try {
logger.debug("There are no dependents. Updating this resource's state to enableNoDependency");
- if(stateManager.getAvailStatus() != null && ((stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY) ||
- (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED)) ){
+ if (stateManager.getAvailStatus() != null
+ && ((stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY)
+ || (stateManager.getAvailStatus()).equals(StateManagement.DEPENDENCY_FAILED))) {
// Note: redundant calls are made by refreshStateAudit
this.stateManager.enableNoDependency();
- }// The refreshStateAudit will catch the case where it is
+ } // The refreshStateAudit will catch the case where it is
// disabled but availStatus != failed
} catch (Exception e) {
logger.error("IntegrityMonitor threw exception.", e);
if (!errorMsg.isEmpty()) {
errorMsg = errorMsg.concat(",");
}
- errorMsg = errorMsg.concat(resourceName
- + ": Failed to enable no dependency");
+ errorMsg = errorMsg.concat(resourceName + ": Failed to enable no dependency");
}
}
if (!errorMsg.isEmpty()) {
- logger.error(
- "Sanity failure detected in a dependent resource: {}",
- errorMsg);
+ logger.error("Sanity failure detected in a dependent resource: {}", errorMsg);
}
@@ -1077,13 +1064,13 @@ public class IntegrityMonitor {
}
/**
- * Execute a test transaction. It is called when the test transaction timer fires.
- * It could be overridden to provide additional test functionality. If overridden,
- * the overriding method must invoke startTransaction() and endTransaction() and
- * check if the allNotWellMap is empty.
+ * Execute a test transaction. It is called when the test transaction timer
+ * fires. It could be overridden to provide additional test functionality.
+ * If overridden, the overriding method must invoke startTransaction() and
+ * endTransaction() and check if the allNotWellMap is empty.
*/
public void testTransaction() {
- synchronized (testTransactionLock){
+ synchronized (testTransactionLock) {
logger.debug("testTransaction: entry");
//
// startTransaction() not required for testTransaction
@@ -1112,31 +1099,23 @@ public class IntegrityMonitor {
* throws admin state exception if resource is locked
* @throws StandbyStatusException
*/
- public void startTransaction() throws AdministrativeStateException,
- StandbyStatusException {
+ public void startTransaction() throws AdministrativeStateException, StandbyStatusException {
synchronized (startTransactionLock) {
// check admin state and throw exception if locked
- if ((stateManager.getAdminState() != null)
- && stateManager.getAdminState().equals(
- StateManagement.LOCKED)) {
- String msg = "Resource " + resourceName
- + " is administratively locked";
+ if ((stateManager.getAdminState() != null) && stateManager.getAdminState().equals(StateManagement.LOCKED)) {
+ String msg = "Resource " + resourceName + " is administratively locked";
- throw new AdministrativeStateException(
- "IntegrityMonitor Admin State Exception: " + msg);
+ throw new AdministrativeStateException("IntegrityMonitor Admin State Exception: " + msg);
}
// check standby state and throw exception if locked
if ((stateManager.getStandbyStatus() != null)
- && (stateManager.getStandbyStatus().equals(
- StateManagement.HOT_STANDBY) || stateManager
- .getStandbyStatus().equals(
- StateManagement.COLD_STANDBY))) {
+ && (stateManager.getStandbyStatus().equals(StateManagement.HOT_STANDBY)
+ || stateManager.getStandbyStatus().equals(StateManagement.COLD_STANDBY))) {
String msg = "Resource " + resourceName + " is standby";
- throw new StandbyStatusException(
- "IntegrityMonitor Standby Status Exception: " + msg);
+ throw new StandbyStatusException("IntegrityMonitor Standby Status Exception: " + msg);
}
// reset transactionTimer so it will not fire
@@ -1149,30 +1128,32 @@ public class IntegrityMonitor {
* the end of each transaction (successful or not).
*/
public void endTransaction() {
- synchronized(endTransactionLock){
- if(getAllNotWellMap() != null){
- if(!(getAllNotWellMap().isEmpty())){
+ synchronized (endTransactionLock) {
+ if (getAllNotWellMap() != null) {
+ if (!(getAllNotWellMap().isEmpty())) {
/*
- * An entity has reported that it is not well. We must not
+ * An entity has reported that it is not well. We must not
* allow the the forward progress counter to advance.
*/
String msg = "allNotWellMap:";
- for(Entry<String, String> entry: allNotWellMap.entrySet()){
+ for (Entry<String, String> entry : allNotWellMap.entrySet()) {
msg = msg.concat("\nkey = " + entry.getKey() + " msg = " + entry.getValue());
}
logger.error("endTransaction: allNotWellMap is NOT EMPTY. Not advancing forward"
+ "progress counter. \n{}\n", msg);
return;
- }else{
- if(logger.isDebugEnabled()){
- if(getAllSeemsWellMap() != null){
- if(!(getAllSeemsWellMap().isEmpty())){
+ } else {
+ if (logger.isDebugEnabled()) {
+ if (getAllSeemsWellMap() != null) {
+ if (!(getAllSeemsWellMap().isEmpty())) {
String msg = "allSeemsWellMap:";
- for(Entry<String, String> entry: allSeemsWellMap.entrySet()){
+ for (Entry<String, String> entry : allSeemsWellMap.entrySet()) {
msg = msg.concat("\nkey = " + entry.getKey() + " msg = " + entry.getValue());
}
- logger.debug("endTransaction: allNotWellMap IS EMPTY and allSeemsWellMap is NOT EMPTY. Advancing forward"
- + "progress counter. \n{}\n", msg);
+ logger.debug(
+ "endTransaction: allNotWellMap IS EMPTY and allSeemsWellMap is NOT EMPTY. Advancing forward"
+ + "progress counter. \n{}\n",
+ msg);
}
}
}
@@ -1195,13 +1176,11 @@ public class IntegrityMonitor {
try {
// query if ForwardProgress entry exists for resourceName
- Query fquery = em
- .createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
+ Query fquery = em.createQuery("Select f from ForwardProgressEntity f where f.resourceName=:rn");
fquery.setParameter("rn", resourceName);
@SuppressWarnings("rawtypes")
- List fpList = fquery.setLockMode(LockModeType.NONE)
- .setFlushMode(FlushModeType.COMMIT).getResultList();
+ List fpList = fquery.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
ForwardProgressEntity fpx;
if (!fpList.isEmpty()) {
// ignores multiple results
@@ -1209,10 +1188,8 @@ public class IntegrityMonitor {
// refresh the object from DB in case cached data was returned
em.refresh(fpx);
if (logger.isDebugEnabled()) {
- logger.debug(
- "Updating FP entry: Resource={}, fpcCount={}, lastUpdated={}, new fpcCount={}",
- resourceName, fpx.getFpcCount(),
- fpx.getLastUpdated(), fpCounter);
+ logger.debug("Updating FP entry: Resource={}, fpcCount={}, lastUpdated={}, new fpcCount={}",
+ resourceName, fpx.getFpcCount(), fpx.getLastUpdated(), fpCounter);
}
fpx.setFpcCount(fpCounter);
em.persist(fpx);
@@ -1222,8 +1199,7 @@ public class IntegrityMonitor {
}
} else {
// Error - FP entry does not exist
- String msg = "FP entry not found in database for resource "
- + resourceName;
+ String msg = "FP entry not found in database for resource " + resourceName;
throw new IntegrityMonitorException(msg);
}
} catch (Exception e) {
@@ -1236,8 +1212,7 @@ public class IntegrityMonitor {
} catch (Exception e1) {
logger.error("IntegrityMonitor threw exception.", e1);
}
- logger.error("writeFpc DB table commit failed with exception: {}",
- e);
+ logger.error("writeFpc DB table commit failed with exception: {}", e);
throw e;
}
}
@@ -1252,89 +1227,74 @@ public class IntegrityMonitor {
*
* @throws Exception
*/
- private static void validateProperties(Properties prop)
- throws IntegrityMonitorPropertiesException {
+ private static void validateProperties(Properties prop) throws IntegrityMonitorPropertiesException {
if (prop.getProperty(IntegrityMonitorProperties.DB_DRIVER) == null) {
- String msg = IntegrityMonitorProperties.DB_DRIVER
- + " property is null";
+ String msg = IntegrityMonitorProperties.DB_DRIVER + " property is null";
logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException(
- "IntegrityMonitor Property Exception: " + msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
}
if (prop.getProperty(IntegrityMonitorProperties.DB_URL) == null) {
- String msg = IntegrityMonitorProperties.DB_URL
- + " property is null";
+ String msg = IntegrityMonitorProperties.DB_URL + " property is null";
logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException(
- "IntegrityMonitor Property Exception: " + msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
}
if (prop.getProperty(IntegrityMonitorProperties.DB_USER) == null) {
- String msg = IntegrityMonitorProperties.DB_USER
- + " property is null";
+ String msg = IntegrityMonitorProperties.DB_USER + " property is null";
logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException(
- "IntegrityMonitor Property Exception: " + msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
}
if (prop.getProperty(IntegrityMonitorProperties.DB_PWD) == null) {
- String msg = IntegrityMonitorProperties.DB_PWD
- + " property is null";
+ String msg = IntegrityMonitorProperties.DB_PWD + " property is null";
logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException(
- "IntegrityMonitor Property Exception: " + msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
}
if (prop.getProperty(IntegrityMonitorProperties.FP_MONITOR_INTERVAL) != null) {
try {
- monitorInterval = Integer.parseInt(prop.getProperty(
- IntegrityMonitorProperties.FP_MONITOR_INTERVAL).trim());
+ monitorIntervalMs = toMillis(
+ Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.FP_MONITOR_INTERVAL).trim()));
} catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}",
- IntegrityMonitorProperties.FP_MONITOR_INTERVAL, e);
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.FP_MONITOR_INTERVAL, e);
}
}
if (prop.getProperty(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD) != null) {
try {
- failedCounterThreshold = Integer.parseInt(prop.getProperty(
- IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD)
- .trim());
+ failedCounterThreshold = Integer
+ .parseInt(prop.getProperty(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD).trim());
} catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}",
- IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, e);
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD, e);
}
}
if (prop.getProperty(IntegrityMonitorProperties.TEST_TRANS_INTERVAL) != null) {
try {
- testTransInterval = Integer.parseInt(prop.getProperty(
- IntegrityMonitorProperties.TEST_TRANS_INTERVAL).trim());
+ testTransIntervalMs = toMillis(
+ Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.TEST_TRANS_INTERVAL).trim()));
} catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}",
- IntegrityMonitorProperties.TEST_TRANS_INTERVAL, e);
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.TEST_TRANS_INTERVAL, e);
}
}
if (prop.getProperty(IntegrityMonitorProperties.WRITE_FPC_INTERVAL) != null) {
try {
- writeFpcInterval = Integer.parseInt(prop.getProperty(
- IntegrityMonitorProperties.WRITE_FPC_INTERVAL).trim());
+ writeFpcIntervalMs = toMillis(
+ Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.WRITE_FPC_INTERVAL).trim()));
} catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}",
- IntegrityMonitorProperties.WRITE_FPC_INTERVAL, e);
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.WRITE_FPC_INTERVAL, e);
}
}
if (prop.getProperty(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL) != null) {
try {
- checkDependencyInterval = Integer.parseInt(prop.getProperty(
- IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL).trim());
+ checkDependencyIntervalMs = toMillis(Integer
+ .parseInt(prop.getProperty(IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL).trim()));
} catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}",
- IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, e);
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.CHECK_DEPENDENCY_INTERVAL, e);
}
}
@@ -1344,57 +1304,45 @@ public class IntegrityMonitor {
// site_1.pdp_2
if (prop.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS) != null) {
try {
- depGroups = prop.getProperty(
- IntegrityMonitorProperties.DEPENDENCY_GROUPS)
- .split(";");
+ depGroups = prop.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS).split(";");
if (logger.isDebugEnabled()) {
- logger.debug("dependency groups property = {}",
- Arrays.toString(depGroups));
+ logger.debug("dependency groups property = {}", Arrays.toString(depGroups));
}
} catch (Exception e) {
- logger.warn("Ignored invalid property: {}",
- IntegrityMonitorProperties.DEPENDENCY_GROUPS, e);
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.DEPENDENCY_GROUPS, e);
}
}
siteName = prop.getProperty(IntegrityMonitorProperties.SITE_NAME);
if (siteName == null) {
- String msg = IntegrityMonitorProperties.SITE_NAME
- + " property is null";
+ String msg = IntegrityMonitorProperties.SITE_NAME + " property is null";
logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException(
- "IntegrityMonitor Property Exception: " + msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
} else {
siteName = siteName.trim();
}
nodeType = prop.getProperty(IntegrityMonitorProperties.NODE_TYPE);
if (nodeType == null) {
- String msg = IntegrityMonitorProperties.NODE_TYPE
- + " property is null";
+ String msg = IntegrityMonitorProperties.NODE_TYPE + " property is null";
logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException(
- "IntegrityMonitor Property Exception: " + msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
} else {
nodeType = nodeType.trim();
if (!isNodeTypeEnum(nodeType)) {
- String msg = IntegrityMonitorProperties.NODE_TYPE
- + " property " + nodeType + " is invalid";
+ String msg = IntegrityMonitorProperties.NODE_TYPE + " property " + nodeType + " is invalid";
logger.error("{}", msg);
- throw new IntegrityMonitorPropertiesException(
- "IntegrityMonitor Property Exception: " + msg);
+ throw new IntegrityMonitorPropertiesException("IntegrityMonitor Property Exception: " + msg);
}
}
if (prop.getProperty(IntegrityMonitorProperties.TEST_VIA_JMX) != null) {
- String jmxTest = prop.getProperty(
- IntegrityMonitorProperties.TEST_VIA_JMX).trim();
+ String jmxTest = prop.getProperty(IntegrityMonitorProperties.TEST_VIA_JMX).trim();
testViaJmx = Boolean.parseBoolean(jmxTest);
}
if (prop.getProperty(IntegrityMonitorProperties.JMX_FQDN) != null) {
- jmxFqdn = prop.getProperty(IntegrityMonitorProperties.JMX_FQDN)
- .trim();
+ jmxFqdn = prop.getProperty(IntegrityMonitorProperties.JMX_FQDN).trim();
if (jmxFqdn.isEmpty()) {
jmxFqdn = null;
}
@@ -1402,41 +1350,34 @@ public class IntegrityMonitor {
if (prop.getProperty(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL) != null) {
try {
- maxFpcUpdateInterval = Integer.parseInt(prop.getProperty(
- IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL)
- .trim());
+ maxFpcUpdateIntervalMs = toMillis(
+ Integer.parseInt(prop.getProperty(IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL).trim()));
} catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}",
- IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, e);
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.MAX_FPC_UPDATE_INTERVAL, e);
}
}
if (prop.getProperty(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS) != null) {
try {
stateAuditIntervalMs = Long
- .parseLong(prop
- .getProperty(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS));
+ .parseLong(prop.getProperty(IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS));
} catch (NumberFormatException e) {
- logger.warn("Ignored invalid property: {}",
- IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, e);
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.STATE_AUDIT_INTERVAL_MS, e);
}
}
if (prop.getProperty(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS) != null) {
try {
refreshStateAuditIntervalMs = Long
- .parseLong(prop
- .getProperty(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS));
+ .parseLong(prop.getProperty(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS));
} catch (NumberFormatException e) {
- logger.warn(
- "Ignored invalid property: {}",
- IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS,
+ logger.warn("Ignored invalid property: {}", IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS,
e);
}
}
- logger.debug("IntegrityMonitor.validateProperties(): Property values \n"
- + "maxFpcUpdateInterval = {}\n", maxFpcUpdateInterval);
+ logger.debug("IntegrityMonitor.validateProperties(): Property values \n" + "maxFpcUpdateIntervalMs = {}\n",
+ maxFpcUpdateIntervalMs);
return;
}
@@ -1472,15 +1413,14 @@ public class IntegrityMonitor {
logger.debug("fpMonitorCycle(): entry");
synchronized (fpMonitorCycleLock) {
// monitoring interval checks
- if (monitorInterval <= 0) {
+ if (monitorIntervalMs <= 0) {
logger.debug("fpMonitorCycle(): disabled");
elapsedTime = 0;
return; // monitoring is disabled
}
- elapsedTime = elapsedTime
- + TimeUnit.MILLISECONDS.toSeconds(CYCLE_INTERVAL_MILLIS);
- if (elapsedTime < monitorInterval) {
+ elapsedTime = elapsedTime + cycleIntervalMillis;
+ if (elapsedTime < monitorIntervalMs) {
return; // monitoring interval not reached
}
@@ -1491,15 +1431,13 @@ public class IntegrityMonitor {
// no forward progress
missedCycles += 1;
if (missedCycles >= failedCounterThreshold && !alarmExists) {
- logger.debug(
- "Forward progress not detected for resource {}. Setting state to disable failed.",
+ logger.debug("Forward progress not detected for resource {}. Setting state to disable failed.",
resourceName);
- if (!(stateManager.getOpState())
- .equals(StateManagement.DISABLED)) {
+ if (!(stateManager.getOpState()).equals(StateManagement.DISABLED)) {
// Note: The refreshStateAudit will make redundant
// calls
stateManager.disableFailed();
- }// The refreshStateAudit will catch the case where
+ } // The refreshStateAudit will catch the case where
// opStat = disabled and availState !
// failed/dependency.failed
alarmExists = true;
@@ -1509,14 +1447,12 @@ public class IntegrityMonitor {
lastFpCounter = fpCounter;
missedCycles = 0;
// set op state to enabled
- logger.debug(
- "Forward progress detected for resource {}. Setting state to enable not failed.",
+ logger.debug("Forward progress detected for resource {}. Setting state to enable not failed.",
resourceName);
- if (!(stateManager.getOpState())
- .equals(StateManagement.ENABLED)) {
+ if (!(stateManager.getOpState()).equals(StateManagement.ENABLED)) {
// Note: The refreshStateAudit will make redundant calls
stateManager.enableNotFailed();
- }// The refreshStateAudit will catch the case where
+ } // The refreshStateAudit will catch the case where
// opState=enabled and availStatus != null
alarmExists = false;
}
@@ -1539,39 +1475,39 @@ public class IntegrityMonitor {
logger.debug("IntegrityMonitor.stateAudit(): disabled");
return; // stateAudit is disabled
}
-
- //Only run from nodes that are operational
- if(stateManager.getOpState().equals(StateManagement.DISABLED)){
+
+ // Only run from nodes that are operational
+ if (stateManager.getOpState().equals(StateManagement.DISABLED)) {
logger.debug("IntegrityMonitor.stateAudit(): DISABLED. returning");
return;
}
- if(stateManager.getAdminState().equals(StateManagement.LOCKED)){
+ if (stateManager.getAdminState().equals(StateManagement.LOCKED)) {
logger.debug("IntegrityMonitor.stateAudit(): LOCKED. returning");
return;
}
- if(!stateManager.getStandbyStatus().equals(StateManagement.NULL_VALUE) &&
- stateManager.getStandbyStatus()!= null){
- if(!stateManager.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE)){
+ if (!stateManager.getStandbyStatus().equals(StateManagement.NULL_VALUE)
+ && stateManager.getStandbyStatus() != null) {
+ if (!stateManager.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE)) {
logger.debug("IntegrityMonitor.stateAudit(): NOT PROVIDING_SERVICE. returning");
return;
}
}
- Date date = new Date();
- long timeSinceLastStateAudit = date.getTime() - lastStateAuditTime.getTime();
- if (timeSinceLastStateAudit < stateAuditIntervalMs){
+ Date date = new Date();
+ long timeSinceLastStateAudit = date.getTime() - lastStateAuditTime.getTime();
+ if (timeSinceLastStateAudit < stateAuditIntervalMs) {
logger.debug("IntegrityMonitor.stateAudit(): Not time to run. returning");
return;
}
-
+
executeStateAudit();
lastStateAuditTime = date;
logger.debug("IntegrityMonitor.stateAudit(): exit");
}// end stateAudit()
-
- public void executeStateAudit(){
+
+ public void executeStateAudit() {
logger.debug("IntegrityMonitor.executeStateAudit(): entry");
Date date = new Date();
@@ -1579,77 +1515,87 @@ public class IntegrityMonitor {
List<ForwardProgressEntity> fpList = getAllForwardProgressEntity();
// Check if each forwardprogressentity entry is current
- for(ForwardProgressEntity fpe : fpList){
- //If the this is my ForwardProgressEntity, continue
- if(fpe.getResourceName().equals(IntegrityMonitor.resourceName)){
+ for (ForwardProgressEntity fpe : fpList) {
+ // If the this is my ForwardProgressEntity, continue
+ if (fpe.getResourceName().equals(IntegrityMonitor.resourceName)) {
continue;
}
- //Make sure you are not getting a cached version
+ // Make sure you are not getting a cached version
em.refresh(fpe);
long diffMs = date.getTime() - fpe.getLastUpdated().getTime();
- if(logger.isDebugEnabled()){
- logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, diffMs = {}", fpe.getResourceName(), diffMs);
+ if (logger.isDebugEnabled()) {
+ logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, diffMs = {}", fpe.getResourceName(),
+ diffMs);
}
- //Threshold for a stale entry
- long staleMs = 1000L * maxFpcUpdateInterval;
- if(logger.isDebugEnabled()){
- logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, staleMs = {}", fpe.getResourceName(), staleMs);
+ // Threshold for a stale entry
+ long staleMs = maxFpcUpdateIntervalMs;
+ if (logger.isDebugEnabled()) {
+ logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, staleMs = {}", fpe.getResourceName(),
+ staleMs);
}
- if(diffMs > staleMs){
- //ForwardProgress is stale. Disable it
+ if (diffMs > staleMs) {
+ // ForwardProgress is stale. Disable it
// Start a transaction
- logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, FPC is stale. Disabling it" );
+ logger.debug("IntegrityMonitor.executeStateAudit(): resource = {}, FPC is stale. Disabling it");
EntityTransaction et = em.getTransaction();
et.begin();
StateManagementEntity sme = null;
try {
// query if StateManagement entry exists for fpe resource
- Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+ Query query = em
+ .createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
query.setParameter("resource", fpe.getResourceName());
@SuppressWarnings("rawtypes")
- List smList = query.setLockMode(
- LockModeType.NONE).setFlushMode(FlushModeType.COMMIT).getResultList();
+ List smList = query.setLockMode(LockModeType.NONE).setFlushMode(FlushModeType.COMMIT)
+ .getResultList();
if (!smList.isEmpty()) {
// exists
sme = (StateManagementEntity) smList.get(0);
- // refresh the object from DB in case cached data was returned
+ // refresh the object from DB in case cached data was
+ // returned
em.refresh(sme);
- if(logger.isDebugEnabled()){
- logger.debug("IntegrityMonitor.executeStateAudit(): Found entry in StateManagementEntity table for Resource={}", sme.getResourceName());
+ if (logger.isDebugEnabled()) {
+ logger.debug(
+ "IntegrityMonitor.executeStateAudit(): Found entry in StateManagementEntity table for Resource={}",
+ sme.getResourceName());
}
} else {
- String msg = "IntegrityMonitor.executeStateAudit(): " + fpe.getResourceName() + ": resource not found in state management entity database table";
- logger.error("{}", msg);
+ String msg = "IntegrityMonitor.executeStateAudit(): " + fpe.getResourceName()
+ + ": resource not found in state management entity database table";
+ logger.error("{}", msg);
}
- synchronized(imFlushLock){
+ synchronized (imFlushLock) {
et.commit();
}
} catch (Exception e) {
// log an error
- logger.error("IntegrityMonitor.executeStateAudit(): {}: StateManagementEntity DB read failed with exception: ", fpe.getResourceName(), e);
- synchronized(imFlushLock){
- if(et.isActive()){
+ logger.error(
+ "IntegrityMonitor.executeStateAudit(): {}: StateManagementEntity DB read failed with exception: ",
+ fpe.getResourceName(), e);
+ synchronized (imFlushLock) {
+ if (et.isActive()) {
et.rollback();
}
}
}
- if(sme != null && !sme.getOpState().equals(StateManagement.DISABLED)){
- if(logger.isDebugEnabled()){
- logger.debug("IntegrityMonitor.executeStateAudit(): Changing OpStat = disabled for {}", sme.getResourceName());
+ if (sme != null && !sme.getOpState().equals(StateManagement.DISABLED)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("IntegrityMonitor.executeStateAudit(): Changing OpStat = disabled for {}",
+ sme.getResourceName());
+ }
+ try {
+ stateManager.disableFailed(sme.getResourceName());
+ } catch (Exception e) {
+ String msg = "IntegrityMonitor.executeStateAudit(): Failed to disable " + sme.getResourceName();
+ logger.error("{}", msg, e);
}
- try {
- stateManager.disableFailed(sme.getResourceName());
- } catch (Exception e) {
- String msg = "IntegrityMonitor.executeStateAudit(): Failed to disable " + sme.getResourceName();
- logger.error("{}", msg, e);
- }
}
- }// end if(diffMs > staleMs)
- }// end for(ForwardProgressEntity fpe : fpList)
+ } // end if(diffMs > staleMs)
+ } // end for(ForwardProgressEntity fpe : fpList)
logger.debug("IntegrityMonitor.executeStateAudit(): exit");
}
@@ -1661,15 +1607,14 @@ public class IntegrityMonitor {
synchronized (checkTestTransactionLock) {
// test transaction timer checks
- if (testTransInterval <= 0) {
+ if (testTransIntervalMs <= 0) {
logger.debug("checkTestTransaction(): disabled");
elapsedTestTransTime = 0;
return; // test transaction is disabled
}
- elapsedTestTransTime = elapsedTestTransTime
- + TimeUnit.MILLISECONDS.toSeconds(CYCLE_INTERVAL_MILLIS);
- if (elapsedTestTransTime < testTransInterval) {
+ elapsedTestTransTime = elapsedTestTransTime + cycleIntervalMillis;
+ if (elapsedTestTransTime < testTransIntervalMs) {
return; // test transaction interval not reached
}
@@ -1689,15 +1634,14 @@ public class IntegrityMonitor {
synchronized (checkWriteFpcLock) {
// test transaction timer checks
- if (writeFpcInterval <= 0) {
+ if (writeFpcIntervalMs <= 0) {
logger.debug("checkWriteFpc(): disabled");
elapsedWriteFpcTime = 0;
return; // write Fpc is disabled
}
- elapsedWriteFpcTime = elapsedWriteFpcTime
- + TimeUnit.MILLISECONDS.toSeconds(CYCLE_INTERVAL_MILLIS);
- if (elapsedWriteFpcTime < writeFpcInterval) {
+ elapsedWriteFpcTime = elapsedWriteFpcTime + cycleIntervalMillis;
+ if (elapsedWriteFpcTime < writeFpcIntervalMs) {
return; // write Fpc interval not reached
}
@@ -1719,16 +1663,15 @@ public class IntegrityMonitor {
*/
private void checkDependentHealth() {
logger.debug("checkDependentHealth: entry");
- if (checkDependencyInterval <=0) {
+ if (checkDependencyIntervalMs <= 0) {
logger.debug("checkDependentHealth: disabled");
return; // dependency monitoring is disabled
}
long currTime = System.currentTimeMillis();
- logger.debug(
- "checkDependentHealth currTime - lastDependencyCheckTime = {}",
+ logger.debug("checkDependentHealth currTime - lastDependencyCheckTime = {}",
currTime - lastDependencyCheckTime);
- if ((currTime - lastDependencyCheckTime) > (1000L * checkDependencyInterval)) {
+ if ((currTime - lastDependencyCheckTime) > checkDependencyIntervalMs) {
// execute dependency check and update this resource's state
dependencyCheck();
@@ -1756,16 +1699,15 @@ public class IntegrityMonitor {
executeRefreshStateAudit();
logger.debug("refreshStateAudit(): exit");
}
-
- public void executeRefreshStateAudit(){
+
+ public void executeRefreshStateAudit() {
logger.debug("executeRefreshStateAudit(): entry");
synchronized (refreshStateAuditLock) {
logger.debug("refreshStateAudit: entry");
Date now = new Date();
long nowMs = now.getTime();
long lastTimeMs = refreshStateAuditLastRunDate.getTime();
- logger.debug("refreshStateAudit: ms since last run = {}",
- nowMs - lastTimeMs);
+ logger.debug("refreshStateAudit: ms since last run = {}", nowMs - lastTimeMs);
if ((nowMs - lastTimeMs) > refreshStateAuditIntervalMs) {
String adminState = stateManager.getAdminState();
@@ -1775,18 +1717,14 @@ public class IntegrityMonitor {
logger.debug("refreshStateAudit: calling lock()");
stateManager.lock();
} catch (Exception e) {
- logger.error(
- "refreshStateAudit: caught unexpected exception from stateManager.lock(): ",
- e);
+ logger.error("refreshStateAudit: caught unexpected exception from stateManager.lock(): ", e);
}
} else {// unlocked
try {
logger.debug("refreshStateAudit: calling unlock()");
stateManager.unlock();
} catch (Exception e) {
- logger.error(
- "refreshStateAudit: caught unexpected exception from stateManager.unlock(): ",
- e);
+ logger.error("refreshStateAudit: caught unexpected exception from stateManager.unlock(): ", e);
}
}
refreshStateAuditLastRunDate = new Date();
@@ -1796,24 +1734,20 @@ public class IntegrityMonitor {
logger.debug("executeRefreshStateAudit(): exit");
}
- public static boolean isUnitTesting() {
- return isUnitTesting;
- }
-
- public static void setUnitTesting(boolean isUnitTesting) {
- IntegrityMonitor.isUnitTesting = isUnitTesting;
- }
-
/**
* The following nested class periodically performs the forward progress
* check, checks dependencies, does a refresh state audit and runs the
* stateAudit.
*/
class FPManager extends Thread {
- private volatile boolean exit = false;
+ private final CountDownLatch stopper = new CountDownLatch(1);
+
+ private BlockingQueue<CountDownLatch> queue;
+ private CountDownLatch progressLatch = null;
// Constructor - start FP manager thread
- FPManager() {
+ FPManager(BlockingQueue<CountDownLatch> queue) {
+ this.queue = queue;
// set now as the last time the refreshStateAudit ran
IntegrityMonitor.this.refreshStateAuditLastRunDate = new Date();
// start thread
@@ -1823,139 +1757,209 @@ public class IntegrityMonitor {
@Override
public void run() {
logger.debug("FPManager thread running");
- while (!exit) {
- try {
- Thread.sleep(CYCLE_INTERVAL_MILLIS);
- } catch (InterruptedException e) {
- // The 'sleep' call was interrupted
- logger.debug("IntegrityMonitor threw exception.", e);
- Thread.currentThread().interrupt();
- continue;
- }
-
- try {
- logger.debug("FPManager calling fpMonitorCycle()");
- // check forward progress timer
- IntegrityMonitor.this.fpMonitorCycle();
-
- logger.debug("FPManager calling checkTestTransaction()");
- // check test transaction timer
- IntegrityMonitor.this.checkTestTransaction();
- logger.debug("FPManager calling checkWriteFpc()");
- // check write Fpc timer
- IntegrityMonitor.this.checkWriteFpc();
+ try {
+ getLatch();
+ decrementLatch();
- logger.debug("FPManager calling checkDependentHealth()");
- // check dependency health
- IntegrityMonitor.this.checkDependentHealth();
+ while (!stopper.await(cycleIntervalMillis, TimeUnit.MILLISECONDS)) {
+ getLatch();
+ IntegrityMonitor.this.runOnce();
+ decrementLatch();
+ }
- logger.debug("FPManager calling refreshStateAudit()");
- // check if it is time to run the refreshStateAudit
- IntegrityMonitor.this.refreshStateAudit();
+ } catch (InterruptedException e) {
+ logger.debug("IntegrityMonitor threw exception.", e);
+ Thread.currentThread().interrupt();
+ }
+ }
- logger.debug("FPManager calling stateAudit()");
- // check if it is time to run the stateAudit
- IntegrityMonitor.this.stateAudit();
+ public void stopAndExit() {
+ stopper.countDown();
+ this.interrupt();
+ }
- } catch (Exception e) {
- logger.error(
- "Ignore FPManager thread processing timer(s) exception: ",
- e);
- }
+ /**
+ * Gets the next latch from the queue.
+ *
+ * @throws InterruptedException
+ *
+ */
+ private void getLatch() throws InterruptedException {
+ if (queue != null) {
+ progressLatch = queue.take();
}
}
- public void stopAndExit() {
- exit = true;
- // Referring to the FPManager instance
- FPManager.this.interrupt();
+ /**
+ * Decrements the current latch.
+ */
+ private void decrementLatch() {
+ if (progressLatch != null) {
+ progressLatch.countDown();
+ }
}
}
+ private void runOnce() {
+ try {
+ logger.debug("FPManager calling fpMonitorCycle()");
+ // check forward progress timer
+ fpMonitorCycle();
+
+ logger.debug("FPManager calling checkTestTransaction()");
+ // check test transaction timer
+ checkTestTransaction();
+
+ logger.debug("FPManager calling checkWriteFpc()");
+ // check write Fpc timer
+ checkWriteFpc();
+
+ logger.debug("FPManager calling checkDependentHealth()");
+ // check dependency health
+ checkDependentHealth();
+
+ logger.debug("FPManager calling refreshStateAudit()");
+ // check if it is time to run the refreshStateAudit
+ refreshStateAudit();
+
+ logger.debug("FPManager calling stateAudit()");
+ // check if it is time to run the stateAudit
+ stateAudit();
+
+ } catch (Exception e) {
+ logger.error("Ignore FPManager thread processing timer(s) exception: ", e);
+ }
+ }
+
public void allSeemsWell(@NotNull String key, @NotNull Boolean asw, @NotNull String msg)
throws AllSeemsWellException {
logger.debug("allSeemsWell entry: key = {}, asw = {}, msg = {}", key, asw, msg);
- if(key == null || key.isEmpty()){
+ if (key == null || key.isEmpty()) {
logger.error("allSeemsWell: 'key' has no visible content");
throw new IllegalArgumentException("allSeemsWell: 'key' has no visible content");
}
- if(asw == null){
+ if (asw == null) {
logger.error("allSeemsWell: 'asw' is null");
throw new IllegalArgumentException("allSeemsWell: 'asw' is null");
}
- if(msg == null || msg.isEmpty()){
+ if (msg == null || msg.isEmpty()) {
logger.error("allSeemsWell: 'msg' has no visible content");
throw new IllegalArgumentException("allSeemsWell: 'msg' has no visible content");
}
-
- if(allSeemsWellMap == null){
+
+ if (allSeemsWellMap == null) {
allSeemsWellMap = new HashMap<>();
}
-
- if(allNotWellMap == null){
+
+ if (allNotWellMap == null) {
allNotWellMap = new HashMap<>();
}
- if(asw){
+ if (asw) {
logger.info("allSeemsWell: ALL SEEMS WELL: key = {}, msg = {}", key, msg);
- try{
+ try {
allSeemsWellMap.put(key, msg);
- }catch(Exception e){
- String exceptMsg ="allSeemsWell: encountered an exception with allSeemsWellMap.put("
- + key + "," + msg + ")";
+ } catch (Exception e) {
+ String exceptMsg = "allSeemsWell: encountered an exception with allSeemsWellMap.put(" + key + "," + msg
+ + ")";
logger.error(exceptMsg);
throw new AllSeemsWellException(exceptMsg, e);
}
- try{
+ try {
allNotWellMap.remove(key);
- }catch(Exception e){
- String exceptMsg ="allSeemsWell: encountered an exception with allNotWellMap.delete("
- + key + ")";
+ } catch (Exception e) {
+ String exceptMsg = "allSeemsWell: encountered an exception with allNotWellMap.delete(" + key + ")";
logger.error(exceptMsg);
throw new AllSeemsWellException(exceptMsg, e);
}
- }else{
+ } else {
logger.error("allSeemsWell: ALL NOT WELL: key = {}, msg = {}", key, msg);
- try{
+ try {
allSeemsWellMap.remove(key);
- }catch(Exception e){
- String exceptMsg ="allSeemsWell: encountered an exception with allSeemsWellMap.remove("
- + key + ")";
+ } catch (Exception e) {
+ String exceptMsg = "allSeemsWell: encountered an exception with allSeemsWellMap.remove(" + key + ")";
logger.error(exceptMsg);
throw new AllSeemsWellException(exceptMsg, e);
}
- try{
+ try {
allNotWellMap.put(key, msg);
- }catch(Exception e){
- String exceptMsg ="allSeemsWell: encountered an exception with allNotWellMap.put("
- + key + msg + ")";
+ } catch (Exception e) {
+ String exceptMsg = "allSeemsWell: encountered an exception with allNotWellMap.put(" + key + msg + ")";
logger.error(exceptMsg);
throw new AllSeemsWellException(exceptMsg, e);
}
}
- if(logger.isDebugEnabled()){
- for(Entry<String, String> entry: allSeemsWellMap.entrySet()){
- logger.debug("allSeemsWellMap: key = {} msg = {}", entry.getKey(), entry.getValue());
+ if (logger.isDebugEnabled()) {
+ for (Entry<String, String> entry : allSeemsWellMap.entrySet()) {
+ logger.debug("allSeemsWellMap: key = {} msg = {}", entry.getKey(), entry.getValue());
}
- for(Entry<String, String> entry: allNotWellMap.entrySet()){
- logger.debug("allNotWellMap: key = {} msg = {}", entry.getKey(), entry.getValue());
+ for (Entry<String, String> entry : allNotWellMap.entrySet()) {
+ logger.debug("allNotWellMap: key = {} msg = {}", entry.getKey(), entry.getValue());
}
logger.debug("allSeemsWell exit");
}
}
- public Map<String, String> getAllSeemsWellMap(){
+ /**
+ * Converts the given value to milliseconds using the current
+ * {@link #propertyUnits}.
+ *
+ * @param value
+ * value to be converted, or -1
+ * @return the value, in milliseconds, or -1
+ */
+ private static long toMillis(long value) {
+ return (value < 0 ? -1 : propertyUnits.toMillis(value));
+ }
+
+ public Map<String, String> getAllSeemsWellMap() {
return allSeemsWellMap;
}
- public Map<String, String> getAllNotWellMap(){
+ public Map<String, String> getAllNotWellMap() {
return allNotWellMap;
}
+
+ /*
+ * The remaining methods are used by JUnit tests.
+ */
+
+ public static boolean isUnitTesting() {
+ return isUnitTesting;
+ }
+
+ public static void setUnitTesting(boolean isUnitTesting) {
+ IntegrityMonitor.isUnitTesting = isUnitTesting;
+ }
+
+ protected static TimeUnit getPropertyUnits() {
+ return propertyUnits;
+ }
+
+ protected static void setPropertyUnits(TimeUnit propertyUnits) {
+ IntegrityMonitor.propertyUnits = propertyUnits;
+ }
+
+ protected static long getCycleIntervalMillis() {
+ return cycleIntervalMillis;
+ }
+
+ protected static void setCycleIntervalMillis(long cycleIntervalMillis) {
+ IntegrityMonitor.cycleIntervalMillis = cycleIntervalMillis;
+ }
+
+ protected static String getPersistenceUnit() {
+ return persistenceUnit;
+ }
+
+ protected static void setPersistenceUnit(String persistenceUnit) {
+ IntegrityMonitor.persistenceUnit = persistenceUnit;
+ }
}
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
index 05da2a87..ccc12d48 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
@@ -20,19 +20,19 @@
package org.onap.policy.common.im;
-import java.util.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Observable;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.Query;
-
import org.onap.policy.common.im.jpa.StateManagementEntity;
-import org.onap.policy.common.im.StateElement;
-import org.onap.policy.common.im.StandbyStatusException;
+import org.onap.policy.common.utils.jpa.EntityMgrCloser;
+import org.onap.policy.common.utils.jpa.EntityTransCloser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
@@ -104,59 +104,44 @@ public class StateManagement extends Observable {
if(logger.isDebugEnabled()){
logger.debug("StateManagement: constructor, resourceName: {}", resourceName);
}
+
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
-
- if(!et.isActive()){
- et.begin();
- }
- this.resourceName = resourceName;
- if(logger.isDebugEnabled()){
- logger.debug("resourceName = {}", this.resourceName);
- }
-
-
- try {
- //Create a StateManagementEntity object
- if(logger.isDebugEnabled()){
- logger.debug("findStateManagementEntity for {}", this.resourceName);
- }
- StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
-
- //persist the administrative state
- if (sm != null) {
- if(logger.isDebugEnabled()){
- logger.debug("Persist adminstrative state, resourceName = {}", this.resourceName);
- }
- em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
- } else {
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
- }
-
- //Load the StateTransition hash table
- st = new StateTransition();
-
- if(logger.isDebugEnabled()){
- logger.debug("StateManagement: constructor end, resourceName: {}", this.resourceName);
- }
- } catch(Exception ex) {
- logger.error("StateManagement: constructor caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
- throw new StateManagementException("StateManagement: Exception: " + ex.toString(), ex);
- }
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
+ this.resourceName = resourceName;
+ if(logger.isDebugEnabled()){
+ logger.debug("resourceName = {}", this.resourceName);
+ }
+
+
+ try {
+ //Create a StateManagementEntity object
+ if(logger.isDebugEnabled()){
+ logger.debug("findStateManagementEntity for {}", this.resourceName);
+ }
+ StateManagementEntity sm = findStateManagementEntity(em, this.resourceName);
+
+ //persist the administrative state
+ if (sm != null) {
+ if(logger.isDebugEnabled()){
+ logger.debug("Persist adminstrative state, resourceName = {}", this.resourceName);
+ }
+ em.persist(sm);
+ }
+ et.commit();
+
+ //Load the StateTransition hash table
+ st = new StateTransition();
+
+ if(logger.isDebugEnabled()){
+ logger.debug("StateManagement: constructor end, resourceName: {}", this.resourceName);
+ }
+ } catch(Exception ex) {
+ logger.error("StateManagement: constructor caught unexpected exception: ", ex);
+ throw new StateManagementException("StateManagement: Exception: " + ex.toString(), ex);
+ }
+ }
}
/**
@@ -174,14 +159,11 @@ public class StateManagement extends Observable {
if(logger.isDebugEnabled()){
logger.debug("StateManagement: initializeState() operation started, resourceName = {}", this.resourceName);
}
- EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
-
- if(!et.isActive()){
- et.begin();
- }
+ EntityManager em = emf.createEntityManager();
- try {
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("findStateManagementEntity for {}", this.resourceName);
}
@@ -193,11 +175,7 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(StateManagement.NULL_VALUE);
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
setChanged();
notifyObservers(ADMIN_STATE);
@@ -206,11 +184,6 @@ public class StateManagement extends Observable {
}
} catch(Exception ex) {
logger.error("StateManagement.initializeState() caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.initializeState() Exception: " + ex);
}
}
@@ -230,13 +203,10 @@ public class StateManagement extends Observable {
logger.debug("StateManagement: lock() operation started, resourceName = {}", this.resourceName);
}
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
-
- if(!et.isActive()){
- et.begin();
- }
- try {
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("findStateManagementEntity for {}", this.resourceName);
}
@@ -251,11 +221,7 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
setChanged();
notifyObservers(ADMIN_STATE);
@@ -264,11 +230,6 @@ public class StateManagement extends Observable {
}
} catch(Exception ex) {
logger.error("StateManagement.lock() caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.lock() Exception: " + ex.toString());
}
}
@@ -288,13 +249,10 @@ public class StateManagement extends Observable {
logger.debug("StateManagement: unlock() operation started, resourceName = {}", this.resourceName);
}
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
- if(!et.isActive()){
- et.begin();
- }
-
- try {
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("findStateManagementEntity for {}", this.resourceName);
}
@@ -308,11 +266,7 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
setChanged();
notifyObservers(ADMIN_STATE);
@@ -321,11 +275,6 @@ public class StateManagement extends Observable {
}
} catch(Exception ex) {
logger.error("StateManagement.unlock() caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.unlock() Exception: " + ex);
}
}
@@ -346,13 +295,10 @@ public class StateManagement extends Observable {
logger.debug("StateManagement: enableNotFailed() operation started, resourceName = {}", this.resourceName);
}
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
-
- if(!et.isActive()){
- et.begin();
- }
- try {
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("findStateManagementEntity for {}", this.resourceName);
}
@@ -366,11 +312,8 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
+
setChanged();
notifyObservers(OPERATION_STATE);
@@ -379,11 +322,6 @@ public class StateManagement extends Observable {
}
} catch(Exception ex) {
logger.error("StateManagement.enableNotFailed() caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.enableNotFailed() Exception: " + ex);
}
}
@@ -403,12 +341,10 @@ public class StateManagement extends Observable {
logger.debug("StateManagement: disableFailed() operation started, resourceName = {}", this.resourceName);
}
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
- if(!et.isActive()){
- et.begin();
- }
- try {
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("findStateManagementEntity for {}", this.resourceName);
}
@@ -422,11 +358,7 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
setChanged();
notifyObservers(OPERATION_STATE);
@@ -435,11 +367,6 @@ public class StateManagement extends Observable {
}
} catch(Exception ex) {
logger.error("StateManagement.disableFailed() caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.disableFailed() Exception: " + ex);
}
}
@@ -465,12 +392,10 @@ public class StateManagement extends Observable {
otherResourceName);
}
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
- if(!et.isActive()){
- et.begin();
- }
- try {
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("findStateManagementEntity for " + otherResourceName);
}
@@ -484,11 +409,7 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
setChanged();
notifyObservers(OPERATION_STATE);
@@ -498,11 +419,6 @@ public class StateManagement extends Observable {
}
} catch(Exception ex) {
logger.error("StateManagement.disableFailed(otherResourceName) caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.disableFailed(otherResourceName) Exception: " + ex);
}
}
@@ -522,13 +438,10 @@ public class StateManagement extends Observable {
logger.debug("StateManagement: disableDependency() operation started, resourceName = {}", this.resourceName);
}
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
- if(!et.isActive()){
- et.begin();
- }
-
- try {
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("findStateManagementEntity for {}", this.resourceName);
}
@@ -542,11 +455,7 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
setChanged();
notifyObservers(OPERATION_STATE);
@@ -555,11 +464,6 @@ public class StateManagement extends Observable {
}
} catch(Exception ex) {
logger.error("StateManagement.disableDependency() caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.disableDependency() Exception: " + ex);
}
}
@@ -580,13 +484,10 @@ public class StateManagement extends Observable {
logger.debug("StateManagement: enableNoDependency() operation started, resourceName = {}", this.resourceName);
}
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
-
- if(!et.isActive()){
- et.begin();
- }
- try {
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("findStateManagementEntity for {}", this.resourceName);
}
@@ -600,11 +501,7 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
setChanged();
notifyObservers(OPERATION_STATE);
@@ -613,11 +510,6 @@ public class StateManagement extends Observable {
}
} catch(Exception ex) {
logger.error("StateManagement.enableNoDependency() caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.enableNoDependency() Exception: " + ex);
}
}
@@ -637,16 +529,14 @@ public class StateManagement extends Observable {
if(logger.isDebugEnabled()){
logger.debug("StateManagement: promote() operation started, resourceName = {}", this.resourceName);
}
- EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
-
- if(!et.isActive()){
- et.begin();
- }
StateManagementEntity sm;
+
+ EntityManager em = emf.createEntityManager();
- try{
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("findStateManagementEntity for {}", this.resourceName);
}
@@ -660,20 +550,11 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
setChanged();
notifyObservers(STANDBY_STATUS);
}catch(Exception ex){
logger.error("StateManagement.promote() caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.promote() Exception: " + ex);
}
@@ -701,13 +582,10 @@ public class StateManagement extends Observable {
logger.debug("StateManagement: demote() operation started, resourceName = {}", this.resourceName);
}
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
- if(!et.isActive()){
- et.begin();
- }
-
- try {
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("findStateManagementEntity for {}", this.resourceName);
}
@@ -721,11 +599,7 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
setChanged();
notifyObservers(STANDBY_STATUS);
@@ -734,11 +608,6 @@ public class StateManagement extends Observable {
}
} catch(Exception ex) {
logger.error("StateManagement.demote() caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.demote() Exception: " + ex);
}
}
@@ -764,13 +633,10 @@ public class StateManagement extends Observable {
logger.debug("\nStateManagement: SYNCLOCK demote(otherResourceName) operation for resourceName = {}\n", otherResourceName);
}
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
-
- if(!et.isActive()){
- et.begin();
- }
- try {
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
+
if(logger.isDebugEnabled()){
logger.debug("StateManagement: SYNCLOCK demote(otherResourceName) findStateManagementEntity for {}", otherResourceName);
}
@@ -784,11 +650,7 @@ public class StateManagement extends Observable {
sm.setStandbyStatus(stateElement.getEndingStandbyStatus());
em.persist(sm);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+ et.commit();
//We don't notify observers because this is assumed to be a remote resource
if(logger.isDebugEnabled()){
@@ -796,11 +658,6 @@ public class StateManagement extends Observable {
}
} catch(Exception ex) {
logger.error("StateManagement.demote(otherResourceName) caught unexpected exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
throw new StateManagementException("StateManagement.demote(otherResourceName) Exception: " + ex);
}
}
@@ -814,8 +671,9 @@ public String getAdminState()
if(logger.isDebugEnabled()){
logger.debug("StateManagement(6/1/16): getAdminState for resourceName {}", this.resourceName);
}
- try {
- EntityManager em = emf.createEntityManager();
+
+ EntityManager em = emf.createEntityManager();
+ try(EntityMgrCloser emc = new EntityMgrCloser(em)) {
Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
query.setParameter("resource", this.resourceName);
@@ -848,8 +706,9 @@ public String getOpState()
if(logger.isDebugEnabled()){
logger.debug("StateManagement(6/1/16): getOpState for resourceName {}", this.resourceName);
}
- try {
- EntityManager em = emf.createEntityManager();
+
+ EntityManager em = emf.createEntityManager();
+ try(EntityMgrCloser emc = new EntityMgrCloser(em)) {
Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
query.setParameter("resource", this.resourceName);
@@ -882,8 +741,9 @@ public String getOpState()
if(logger.isDebugEnabled()){
logger.debug("StateManagement(6/1/16): getAvailStatus for resourceName {}", this.resourceName);
}
- try {
- EntityManager em = emf.createEntityManager();
+
+ EntityManager em = emf.createEntityManager();
+ try(EntityMgrCloser emc = new EntityMgrCloser(em)) {
Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
query.setParameter("resource", this.resourceName);
@@ -916,8 +776,9 @@ public String getOpState()
if(logger.isDebugEnabled()){
logger.debug("StateManagement(6/1/16): getStandbyStatus for resourceName {}", this.resourceName);
}
- try {
- EntityManager em = emf.createEntityManager();
+
+ EntityManager em = emf.createEntityManager();
+ try(EntityMgrCloser emc = new EntityMgrCloser(em)) {
Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
query.setParameter("resource", this.resourceName);
@@ -999,11 +860,9 @@ public String getOpState()
// The transaction is required for the LockModeType
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
- if(!et.isActive()){
- et.begin();
- }
- try {
+
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
Query stateManagementListQuery = em
.createQuery("SELECT p FROM StateManagementEntity p WHERE p.resourceName=:resource");
@@ -1023,18 +882,10 @@ public String getOpState()
} else {
logger.error("getStandbyStatus: resourceName ={} not found in statemanagemententity table", otherResourceName);
}
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+
+ et.commit();
} catch (Exception e) {
logger.error("getStandbyStatus: Caught Exception attempting to get statemanagemententity record, message='{}'", e.getMessage(), e);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
}
if (logger.isDebugEnabled()) {
logger.debug("getStandbyStatus: Returning standbyStatus={}", tempStandbyStatus);
@@ -1056,12 +907,9 @@ public String getOpState()
* Start transaction
*/
EntityManager em = emf.createEntityManager();
- EntityTransaction et = em.getTransaction();
- if(!et.isActive()){
- et.begin();
- }
- try{
+ try(EntityMgrCloser emc = new EntityMgrCloser(em);
+ MyTransaction et = new MyTransaction(em)) {
Query stateManagementEntityListQuery = em
.createQuery("SELECT p FROM StateManagementEntity p");
@SuppressWarnings("unchecked")
@@ -1078,22 +926,43 @@ public String getOpState()
}
em.remove(stateManagementEntity);
}
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.commit();
- }
- }
+
+ et.commit();
}catch(Exception ex){
logger.error("StateManagement.deleteAllStateManagementEntities() caught Exception: ", ex);
- synchronized(FLUSHLOCK){
- if(et.isActive()){
- et.rollback();
- }
- }
}
if(logger.isDebugEnabled()){
logger.debug("deleteAllStateManagementEntities: Exiting");
}
}
+
+ private static class MyTransaction extends EntityTransCloser {
+
+ /**
+ * @param em
+ */
+ public MyTransaction(EntityManager em) {
+ super(em.getTransaction());
+ }
+
+ @Override
+ public void commit() {
+ synchronized(FLUSHLOCK){
+ if(getTransation().isActive()){
+ super.commit();
+ }
+ }
+ }
+
+ @Override
+ public void rollback() {
+ synchronized(FLUSHLOCK){
+ if(getTransation().isActive()){
+ super.rollback();
+ }
+ }
+ }
+
+ }
}
diff --git a/integrity-monitor/src/main/resources/META-INF/persistence.xml b/integrity-monitor/src/main/resources/META-INF/persistence.xml
index 7fbec098..f5089b12 100644
--- a/integrity-monitor/src/main/resources/META-INF/persistence.xml
+++ b/integrity-monitor/src/main/resources/META-INF/persistence.xml
@@ -30,9 +30,6 @@
<shared-cache-mode>NONE</shared-cache-mode>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
- <property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/>
- <property name="javax.persistence.schema-generation.scripts.create-target" value="./sql/generatedCreateNcomp.ddl"/>
- <property name="javax.persistence.schema-generation.scripts.drop-target" value="./sql/generatedDropNcomp.ddl"/>
</properties>
</persistence-unit>
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java
new file mode 100644
index 00000000..967ca739
--- /dev/null
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/AllSeemsWellTest.java
@@ -0,0 +1,173 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Integrity Monitor
+ * ================================================================================
+ * Copyright (C) 2017-2018 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AllSeemsWellTest extends IntegrityMonitorTestBase {
+ private static Logger logger = LoggerFactory.getLogger(AllSeemsWellTest.class);
+
+ private static final long STATE_CYCLE_MS = 3 * CYCLE_INTERVAL_MS;
+
+ private static Properties myProp;
+ private static String resourceName;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ IntegrityMonitorTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + AllSeemsWellTest.class.getSimpleName());
+
+ resourceName = IntegrityMonitorTestBase.siteName + "." + IntegrityMonitorTestBase.nodeType;
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ IntegrityMonitorTestBase.tearDownAfterClass();
+ }
+
+ @Before
+ public void setUp() {
+ super.setUpTest();
+
+ myProp = makeProperties();
+
+ }
+
+ @After
+ public void tearDown() {
+ super.tearDownTest();
+ }
+
+ // 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.
+ */
+
+ IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
+
+ StateManagement sm = im.getStateManager();
+
+ // Give it time to set the states in the DB
+ Thread.sleep(STATE_CYCLE_MS);
+
+ // Check the state
+ logger.debug(
+ "\n\ntestAllSeemsWell starting im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.ENABLED, sm.getOpState());
+
+ // Indicate a failure
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLNOTWELL,
+ "'AllSeemsWellTest - ALLNOTWELL'");
+
+ // Wait for the state to change due to ALLNOTWELL
+ Thread.sleep(STATE_CYCLE_MS);
+ // Check the state
+ logger.debug(
+ "\n\ntestAllSeemsWell after ALLNOTWELL: im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ // assertEquals(StateManagement.DISABLED, sm.getOpState());
+
+ Map<String, String> allNotWellMap = im.getAllNotWellMap();
+ for (String key : allNotWellMap.keySet()) {
+ logger.debug("AllSeemsWellTest: allNotWellMap: key = {} msg = {}", key, allNotWellMap.get(key));
+ }
+ // assertEquals(1, allNotWellMap.size());
+
+ 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(STATE_CYCLE_MS);
+ // Check the state
+ logger.debug(
+ "\n\ntestAllSeemsWell after ALLSEEMSWELL: im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ // assertEquals(StateManagement.ENABLED, sm.getOpState());
+
+ allNotWellMap = im.getAllNotWellMap();
+ assertTrue(allNotWellMap.isEmpty());
+
+ allSeemsWellMap = im.getAllSeemsWellMap();
+ assertEquals(1, allSeemsWellMap.size());
+ for (String key : allSeemsWellMap.keySet()) {
+ logger.debug("AllSeemsWellTest: allSeemsWellMap: key = {} msg = {}", key, allSeemsWellMap.get(key));
+ }
+
+ // Check for null parameters
+ assertException(im, imx -> {
+ imx.allSeemsWell(null, IntegrityMonitorProperties.ALLSEEMSWELL, "'AllSeemsWellTest - ALLSEEMSWELL'");
+ });
+
+ assertException(im, imx -> {
+ im.allSeemsWell("", IntegrityMonitorProperties.ALLSEEMSWELL, "'AllSeemsWellTest - ALLSEEMSWELL'");
+ });
+
+ assertException(im, imx -> {
+ im.allSeemsWell(this.getClass().getName(), null, "'AllSeemsWellTest - ALLSEEMSWELL'");
+ });
+
+ assertException(im, imx -> {
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL, null);
+ });
+
+ assertException(im, imx -> {
+ im.allSeemsWell(this.getClass().getName(), IntegrityMonitorProperties.ALLSEEMSWELL, "");
+ });
+
+ logger.debug("\n\ntestAllSeemsWell: Exit\n\n");
+ }
+
+}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/ExceptionsTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/ExceptionsTest.java
index a5c5c910..5066f9d5 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/ExceptionsTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/ExceptionsTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.common.im.test;
+package org.onap.policy.common.im;
import static org.junit.Assert.assertEquals;
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java
new file mode 100644
index 00000000..3704b07d
--- /dev/null
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTest.java
@@ -0,0 +1,907 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Integrity Monitor
+ * ================================================================================
+ * Copyright (C) 2017-2018 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import javax.persistence.EntityTransaction;
+import javax.persistence.Query;
+import javax.persistence.TemporalType;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.common.im.jpa.ForwardProgressEntity;
+import org.onap.policy.common.im.jpa.ResourceRegistrationEntity;
+import org.onap.policy.common.im.jpa.StateManagementEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/*
+ * 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 extends IntegrityMonitorTestBase {
+ private static Logger logger = LoggerFactory.getLogger(IntegrityMonitorTest.class);
+
+ private static Properties myProp;
+ private static EntityTransaction et;
+ private static String resourceName;
+
+ private BlockingQueue<CountDownLatch> queue;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ IntegrityMonitorTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + IntegrityMonitorTest.class.getSimpleName());
+
+ resourceName = IntegrityMonitorTestBase.siteName + "." + IntegrityMonitorTestBase.nodeType;
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ IntegrityMonitorTestBase.tearDownAfterClass();
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUpTest();
+
+ myProp = makeProperties();
+ et = null;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (et != null && et.isActive()) {
+ try {
+ et.rollback();
+
+ } catch (RuntimeException e) {
+ logger.error("cannot rollback transaction", e);
+ }
+ }
+
+ super.tearDownTest();
+ }
+
+ /*
+ * The following test verifies the following test cases: New Install New
+ * Install - Bad Dependency data Recovery from bad dependency data Lock Lock
+ * restart Unlock Unlock restart
+ */
+ @Test
+ public void testSanityJmx() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testSanityJmx\n\n");
+
+ String dependent = "group1_logparser";
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, dependent);
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "true");
+ // 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 = makeMonitor(resourceName, myProp);
+ logger.debug(
+ "\n\ntestSanityJmx starting im state \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
+ // add an entry to Resource registration table in the DB for the
+ // dependent resource
+
+ et = em.getTransaction();
+ et.begin();
+ Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
+ rquery.setParameter("rn", dependent);
+
+ @SuppressWarnings("rawtypes")
+ List rrList = rquery.getResultList();
+ ResourceRegistrationEntity rrx = null;
+ if (rrList.isEmpty()) {
+ // register resource by adding entry to table in DB
+ logger.debug("Adding resource {} to ResourceRegistration table", dependent);
+ rrx = new ResourceRegistrationEntity();
+ // set columns in entry
+ rrx.setResourceName(dependent);
+ rrx.setResourceUrl("service:jmx:somewhere:9999");
+ rrx.setNodeType("logparser");
+ rrx.setSite("siteA");
+ }
+ em.persist(rrx);
+ // flush to the DB
+ em.flush();
+
+ // commit transaction
+ et.commit();
+
+ // wait for the FPManager to check dependency health
+ waitStep();
+
+ assertException(im, imx -> {
+ imx.evaluateSanity();
+ });
+
+ // undo dependency groups and jmx test properties settings
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ myProp.put(IntegrityMonitorProperties.TEST_VIA_JMX, "false");
+ IntegrityMonitor.updateProperties(myProp);
+
+ logger.debug("\ntestSantityJmx ending properties: {}", myProp);
+
+ // We know at this point that the IM is disable-dependency. We want to
+ // be
+ // sure it will recover from this condition since the properties were
+ // updated.
+
+ logger.debug(
+ "\n\ntestSanityJmx ending im state\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
+
+ logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
+ // Create a new instance. It should recover from the disabled-dependency
+ // condition
+ im = makeMonitor(resourceName, myProp);
+
+ logger.debug(
+ "\n\ntestSanityJmx state after creating new im\n"
+ + "AdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
+
+ // Verify the state
+ assertEquals(StateManagement.UNLOCKED, im.getStateManager().getAdminState());
+ assertEquals(StateManagement.ENABLED, im.getStateManager().getOpState());
+ assertEquals(StateManagement.NULL_VALUE, im.getStateManager().getAvailStatus());
+ assertEquals(StateManagement.NULL_VALUE, im.getStateManager().getStandbyStatus());
+
+ // Test state manager via the IntegrityMonitor
+ StateManagement sm = im.getStateManager();
+
+ // Verify lock state
+ sm.lock();
+ logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.LOCKED, sm.getAdminState());
+
+ // Verify lock persists across a restart
+ logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
+ // Create a new instance. It should come up with the admin state locked
+ im = makeMonitor(resourceName, myProp);
+ sm = im.getStateManager();
+ logger.debug(
+ "\n\ntestSanityJmx restart with AdminState=locked"
+ + "\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.LOCKED, sm.getAdminState());
+
+ // Verify unlock
+ sm.unlock();
+ logger.debug(
+ "\n\ntestSanityJmx sm.unlock\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.UNLOCKED, sm.getAdminState());
+
+ // Verify unlock restart
+ logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
+ // Create a new instance. It should come up with the admin state locked
+ im = makeMonitor(resourceName, myProp);
+ sm = im.getStateManager();
+ logger.debug(
+ "\n\ntestSanityJmx restart with AdminState=unlocked\n"
+ + "AdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.UNLOCKED, sm.getAdminState());
+
+ logger.debug("\n\ntestSanityJmx: Exit\n\n");
+ }
+
+ @Test
+ public void testIM() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testIM\n\n");
+
+ // 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");
+
+ IntegrityMonitor im = makeMonitor(resourceName, myProp);
+
+ logger.debug("\n\nim initial state: \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ im.getStateManager().getAdminState(), im.getStateManager().getOpState(),
+ im.getStateManager().getAvailStatus(), im.getStateManager().getStandbyStatus());
+
+ waitStep();
+
+ // test evaluate sanity
+ assertNoException(im, imx -> {
+ imx.evaluateSanity();
+ });
+
+ // Test startTransaction - should work since it is unlocked
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ // Test state manager via the IntegrityMonitor
+ StateManagement sm = im.getStateManager();
+
+ sm.lock();
+
+ logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.LOCKED, sm.getAdminState());
+
+ // test startTransaction. It should fail since it is locked
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.unlock();
+ logger.debug("\n\nsm.unlock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.UNLOCKED, sm.getAdminState());
+
+ // test startTransaction. It should succeed
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.disableDependency();
+ logger.debug(
+ "\n\nsm.disableDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.DISABLED, sm.getOpState());
+ assertEquals(StateManagement.DEPENDENCY, sm.getAvailStatus());
+
+ // test startTransaction. It should succeed since standby status is null
+ // and unlocked
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.enableNoDependency();
+
+ logger.debug(
+ "\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.ENABLED, sm.getOpState());
+ // test startTransaction. It should succeed since standby status is null
+ // and unlocked
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.disableFailed();
+ logger.debug("\n\nsm.disableFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.DISABLED, sm.getOpState());
+ assertEquals(StateManagement.FAILED, sm.getAvailStatus());
+ // test startTransaction. It should succeed since standby status is null
+ // and unlocked
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.enableNotFailed();
+
+ logger.debug(
+ "\n\nsm.enabledNotFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.ENABLED, sm.getOpState());
+ // test startTransaction. It should succeed since standby status is null
+ // and unlocked
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.demote();
+
+ logger.debug("\n\nsm.demote()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.HOT_STANDBY, sm.getStandbyStatus());
+
+ // test startTransaction. It should fail since it is standby
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.promote();
+
+ logger.debug("\n\nsm.promote()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.PROVIDING_SERVICE, sm.getStandbyStatus());
+
+ // test startTransaction. It should succeed since it is providing
+ // service
+ assertNoException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ // Test the multi-valued availability status
+ sm.disableDependency();
+ sm.disableFailed();
+
+ logger.debug(
+ "\n\nsm.disableDependency(), sm.disableFailed\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.DEPENDENCY_FAILED, sm.getAvailStatus());
+
+ // Test startTransaction. Should fail since standby status is cold
+ // standby
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.enableNoDependency();
+
+ logger.debug(
+ "\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.FAILED, sm.getAvailStatus());
+ // Test startTransaction. Should fail since standby status is cold
+ // standby
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.disableDependency();
+ sm.enableNotFailed();
+
+ logger.debug(
+ "\n\nsm.disableDependency(),sm.enableNotFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+
+ assertEquals(StateManagement.DEPENDENCY, sm.getAvailStatus());
+ // Test startTransaction. Should fail since standby status is cold
+ // standby
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ sm.enableNoDependency();
+ logger.debug(
+ "\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
+ sm.getAdminState(), sm.getOpState(), sm.getAvailStatus(), sm.getStandbyStatus());
+ assertEquals(StateManagement.ENABLED, sm.getOpState());
+ // test startTransaction. It should fail since standby status is hot
+ // standby
+ assertException(im, imx -> {
+ imx.startTransaction();
+ });
+
+ logger.debug("\n\ntestIM: Exit\n\n");
+ }
+
+ @Test
+ public void testSanityState() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testSanityState\n\n");
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "group1_dep1,group1_dep2; group2_dep1");
+ // 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 = makeMonitor(resourceName, myProp);
+
+ waitStep();
+
+ // Add a group1 dependent resources to put an entry in the forward
+ // progress table
+ ForwardProgressEntity fpe = new ForwardProgressEntity();
+ ForwardProgressEntity fpe2 = new ForwardProgressEntity();
+ fpe.setFpcCount(0);
+ fpe.setResourceName("group1_dep1");
+ fpe2.setFpcCount(0);
+ fpe2.setResourceName("group1_dep2");
+ et = em.getTransaction();
+ et.begin();
+ em.persist(fpe);
+ em.persist(fpe2);
+ em.flush();
+ et.commit();
+
+ // Add a group2 dependent resource to the StateManagementEntity DB table
+ // and set its admin state to locked
+ // Expect sanity test to fail.
+ StateManagement stateManager = new StateManagement(emf, "group2_dep1");
+ stateManager.lock();
+
+ new StateManagement(emf, "group1_dep1");
+ new StateManagement(emf, "group1_dep2");
+
+ // 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();
+ assertException(im, imx -> {
+ imx.evaluateSanity();
+ });
+
+ logger.debug("\n\ntestSanityState: Exit\n\n");
+ }
+
+ @Test
+ public void testRefreshStateAudit() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Enter\n\n");
+
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ 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 im = makeMonitor(resourceName, myProp);
+
+ waitStep();
+
+ // the state here is unlocked, enabled, null, null
+ StateManagementEntity sme = null;
+
+ Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+
+ query.setParameter("resource", resourceName);
+
+ // Just test that we are retrieving the right object
+ @SuppressWarnings("rawtypes")
+ List resourceList = query.getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ sme = (StateManagementEntity) resourceList.get(0);
+ em.refresh(sme);
+
+ logger.debug(
+ "??? -- Retrieve StateManagementEntity from database --\nsme.getResourceName() = {}\n"
+ + "sme.getAdminState() = {}\nsme.getOpState() = {}\nsme.getAvailStatus() = {}\nsme.getStandbyStatus() = {}",
+ sme.getResourceName(), sme.getAdminState(), sme.getOpState(), sme.getAvailStatus(),
+ sme.getStandbyStatus());
+
+ assertEquals(StateManagement.UNLOCKED, sme.getAdminState());
+ assertEquals(StateManagement.ENABLED, sme.getOpState());
+ assertEquals(StateManagement.NULL_VALUE, sme.getAvailStatus());
+ assertEquals(StateManagement.NULL_VALUE, sme.getStandbyStatus());
+ logger.debug("--");
+ } else {
+ logger.debug("Record not found, resourceName: " + resourceName);
+ fail("missing record");
+ }
+
+ et = em.getTransaction();
+ et.begin();
+
+ sme.setStandbyStatus(StateManagement.COLD_STANDBY);
+ em.persist(sme);
+ em.flush();
+ et.commit();
+
+ // Run the refreshStateAudit
+ im.executeRefreshStateAudit();
+
+ // The refreshStateAudit should run and change the state to
+ // unlocked,enabled,null,hotstandby
+ StateManagementEntity sme1 = null;
+
+ Query query1 = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+
+ query1.setParameter("resource", resourceName);
+
+ @SuppressWarnings("rawtypes")
+ List resourceList1 = query1.getResultList();
+ if (!resourceList1.isEmpty()) {
+ // exist
+ sme1 = (StateManagementEntity) resourceList1.get(0);
+ em.refresh(sme1);
+ logger.debug(
+ "??? -- Retrieve StateManagementEntity from database --\nsme1.getResourceName() = {}\n"
+ + "sme1.getAdminState() = {}\nsme1.getOpState() = {}\nsme1.getAvailStatus() = {}\nsme1.getStandbyStatus() = {}",
+ sme1.getResourceName(), sme1.getAdminState(), sme1.getOpState(), sme1.getAvailStatus(),
+ sme1.getStandbyStatus());
+
+ assertEquals(StateManagement.UNLOCKED, sme1.getAdminState());
+ assertEquals(StateManagement.ENABLED, sme1.getOpState());
+ assertEquals(StateManagement.NULL_VALUE, sme1.getAvailStatus());
+ assertEquals(StateManagement.HOT_STANDBY, sme1.getStandbyStatus());
+ logger.debug("--");
+ } else {
+ logger.debug("Record not found, resourceName: " + resourceName);
+ fail("record not found");
+ }
+
+ logger.debug("\nIntegrityMonitorTest: testRefreshStateAudit Exit\n\n");
+ }
+
+ @Test
+ public void testStateCheck() throws Exception {
+ logger.debug("\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");
+ /*
+ * 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.
+ */
+ 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 = makeMonitor(resourceName, myProp);
+
+ // Note: do ***NOT*** do waitStep() here
+
+ // 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();
+
+ new StateManagement(emf, "group1_dep1");
+
+ assertNoException(im, imx -> {
+ imx.evaluateSanity();
+ });
+
+ // wait for FPManager to perform dependency health check. Once that's
+ // done,
+ // it should now be stale and the sanity check should fail
+ waitStep();
+
+ assertException(im, imx -> {
+ imx.evaluateSanity();
+ });
+
+ logger.debug("\n\ntestStateCheck: Exit\n\n");
+ }
+
+ @Test
+ public void testGetAllForwardProgressEntity() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testGetAllForwardProgressEntity\n\n");
+ // parameters are passed via a properties file
+ myProp.put(IntegrityMonitorProperties.DEPENDENCY_GROUPS, "");
+ 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 im = makeMonitor(resourceName, myProp);
+ waitStep();
+
+ logger.debug("\nIntegrityMonitorTest: Creating ForwardProgressEntity entries\n\n");
+ // Add resource entries in the forward progress table
+ ForwardProgressEntity fpe = new ForwardProgressEntity();
+ ForwardProgressEntity fpe2 = new ForwardProgressEntity();
+ ForwardProgressEntity fpe3 = new ForwardProgressEntity();
+ fpe.setFpcCount(0);
+ fpe.setResourceName("siteA_pap2");
+ fpe2.setFpcCount(0);
+ fpe2.setResourceName("siteB_pap1");
+ fpe3.setFpcCount(0);
+ fpe3.setResourceName("siteB_pap2");
+ et = em.getTransaction();
+ et.begin();
+ em.persist(fpe);
+ em.persist(fpe2);
+ em.persist(fpe3);
+ em.flush();
+ et.commit();
+
+ logger.debug(
+ "\nIntegrityMonitorTest:testGetAllForwardProgressEntity Calling im.getAllForwardProgressEntity()\n\n");
+ List<ForwardProgressEntity> fpeList = im.getAllForwardProgressEntity();
+
+ assertEquals(4, fpeList.size());
+
+ logger.debug("\nIntegrityMonitorTest: Exit testGetAllForwardProgressEntity\n\n");
+ }
+
+ @Test
+ public void testStateAudit() throws Exception {
+ logger.debug("\nIntegrityMonitorTest: Entering testStateAudit\n\n");
+
+ // parameters are passed via a properties file
+
+ // 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 im = makeMonitor(resourceName, myProp);
+ waitStep();
+
+ logger.debug("\nIntegrityMonitorTest: Creating ForwardProgressEntity entries\n\n");
+ // Add resources to put an entry in the forward progress table
+ Date staleDate = new Date(0);
+ ForwardProgressEntity fpe1 = new ForwardProgressEntity();
+ ForwardProgressEntity fpe2 = new ForwardProgressEntity();
+ ForwardProgressEntity fpe3 = new ForwardProgressEntity();
+ fpe1.setFpcCount(0);
+ fpe1.setResourceName("siteA_pap2");
+ fpe2.setFpcCount(0);
+ fpe2.setResourceName("siteB_pap1");
+ fpe3.setFpcCount(0);
+ fpe3.setResourceName("siteB_pap2");
+ logger.debug("\nIntegrityMonitorTest: Creating StateManagementEntity entries\n\n");
+ StateManagementEntity sme1 = new StateManagementEntity();
+ StateManagementEntity sme2 = new StateManagementEntity();
+ StateManagementEntity sme3 = new StateManagementEntity();
+ sme1.setResourceName("siteA_pap2");
+ sme1.setAdminState(StateManagement.UNLOCKED);
+ sme1.setOpState(StateManagement.ENABLED);
+ sme1.setAvailStatus(StateManagement.NULL_VALUE);
+ sme1.setStandbyStatus(StateManagement.NULL_VALUE);
+ sme2.setResourceName("siteB_pap1");
+ sme2.setAdminState(StateManagement.UNLOCKED);
+ sme2.setOpState(StateManagement.ENABLED);
+ sme2.setAvailStatus(StateManagement.NULL_VALUE);
+ sme2.setStandbyStatus(StateManagement.NULL_VALUE);
+ sme3.setResourceName("siteB_pap2");
+ sme3.setAdminState(StateManagement.UNLOCKED);
+ sme3.setOpState(StateManagement.ENABLED);
+ sme3.setAvailStatus(StateManagement.NULL_VALUE);
+ sme3.setStandbyStatus(StateManagement.NULL_VALUE);
+ et = em.getTransaction();
+ et.begin();
+ em.persist(fpe1);
+ em.persist(fpe2);
+ em.persist(fpe3);
+ em.persist(sme1);
+ em.persist(sme2);
+ em.persist(sme3);
+ em.flush();
+ et.commit();
+
+ Query updateQuery = em.createQuery(
+ "UPDATE ForwardProgressEntity f " + "SET f.lastUpdated = :newDate " + "WHERE f.resourceName=:resource");
+ updateQuery.setParameter("newDate", staleDate, TemporalType.TIMESTAMP);
+ updateQuery.setParameter("resource", fpe1.getResourceName());
+
+ et = em.getTransaction();
+ et.begin();
+ updateQuery.executeUpdate();
+ et.commit();
+
+ logger.debug("\nIntegrityMonitorTest:testStateAudit Calling im.getAllForwardProgressEntity()\n\n");
+ List<ForwardProgressEntity> fpeList = im.getAllForwardProgressEntity();
+
+ logger.debug("\n\n");
+ logger.debug("IntegrityMonitorTest:testStateAudit:ForwardProgressEntity entries");
+ for (ForwardProgressEntity myFpe : fpeList) {
+ logger.debug("\n ResourceName: {}" + "\n LastUpdated: {}", myFpe.getResourceName(),
+ myFpe.getLastUpdated());
+ }
+ logger.debug("\n\n");
+
+ logger.debug("\nIntegrityMonitorTest:testStateAudit getting list of StateManagementEntity entries\n\n");
+ Query query = em.createQuery("SELECT s FROM StateManagementEntity s");
+ List<?> smeList = query.getResultList();
+
+ logger.debug("\n\n");
+ logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity entries");
+ for (Object mySme : smeList) {
+ StateManagementEntity tmpSme = (StateManagementEntity) mySme;
+ em.refresh(tmpSme);
+ logger.debug(
+ "\n 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);
+ assertEquals(StateManagement.ENABLED, sme1.getOpState());
+
+ 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();
+
+ logger.debug("\n\n");
+ logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity entries");
+ for (Object mySme : smeList) {
+ StateManagementEntity tmpSme = (StateManagementEntity) mySme;
+ em.refresh(tmpSme);
+ logger.debug(
+ "\n 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);
+ assertEquals(StateManagement.DISABLED, sme1.getOpState());
+
+ // Now let's add sme2 to the mix
+ updateQuery = em.createQuery(
+ "UPDATE ForwardProgressEntity f " + "SET f.lastUpdated = :newDate " + "WHERE f.resourceName=:resource");
+ updateQuery.setParameter("newDate", staleDate, TemporalType.TIMESTAMP);
+ updateQuery.setParameter("resource", fpe2.getResourceName());
+
+ et = em.getTransaction();
+ et.begin();
+ updateQuery.executeUpdate();
+ et.commit();
+
+ // Give it a chance to write the DB and run the audit
+ logger.debug("IntegrityMonitorTest:testStateAudit: (restart4) Running State Audit");
+ waitStep();
+ im.executeStateAudit();
+ waitStep();
+ logger.debug("IntegrityMonitorTest:testStateAudit: (restart4) State Audit complete");
+
+ // Now check its state
+ logger.debug(
+ "\nIntegrityMonitorTest:testStateAudit (restart4) getting list of StateManagementEntity entries\n\n");
+ smeList = query.getResultList();
+
+ logger.debug("\n\n");
+ logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity (restart4) entries");
+ for (Object mySme : smeList) {
+ StateManagementEntity tmpSme = (StateManagementEntity) mySme;
+ em.refresh(tmpSme);
+
+ logger.debug(
+ "\n (restart4) 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);
+ assertEquals(StateManagement.DISABLED, sme1.getOpState());
+
+ em.refresh(sme2);
+ assertEquals(StateManagement.DISABLED, sme2.getOpState());
+
+ logger.debug("\nIntegrityMonitorTest: Exit testStateAudit\n\n");
+ System.out.println("\n\ntestStateAudit: Exit\n\n");
+ }
+
+ private IntegrityMonitor makeMonitor(String resourceName, Properties myProp) throws Exception {
+ IntegrityMonitor.deleteInstance();
+
+ queue = new LinkedBlockingQueue<>();
+
+ IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp, queue);
+
+ // wait for the monitor thread to start
+ waitStep();
+
+ return im;
+ }
+
+ /**
+ * Waits for the FPManager to complete another cycle.
+ *
+ * @throws InterruptedException
+ */
+ private void waitStep() throws InterruptedException {
+ CountDownLatch latch = new CountDownLatch(1);
+ queue.offer(latch);
+ waitLatch(latch);
+ }
+}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java
new file mode 100644
index 00000000..84d0b51a
--- /dev/null
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/IntegrityMonitorTestBase.java
@@ -0,0 +1,306 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Integrity Audit
+ * ================================================================================
+ * Copyright (C) 2018 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;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.onap.policy.common.utils.jpa.EntityTransCloser;
+import org.onap.policy.common.utils.test.log.logback.ExtractAppender;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * All JUnits are designed to run in the local development environment where
+ * they have write privileges and can execute time-sensitive tasks.
+ * <p/>
+ * Many of the test verification steps are performed by scanning for items
+ * written to the log file. Rather than actually scan the log file, an
+ * {@link ExtractAppender} is used to monitor events that are logged and extract
+ * relevant items. In order to attach the appender to the debug log, it assumes
+ * that the debug log is a <i>logback</i> Logger configured per EELF.
+ * <p/>
+ * These tests use a temporary, in-memory DB, which is dropped once the tests
+ * complete.
+ */
+public class IntegrityMonitorTestBase {
+ private static Logger logger = LoggerFactory.getLogger(IntegrityMonitorTestBase.class);
+
+ /**
+ * Directory containing the slf4j log files.
+ */
+ private static final String SLF4J_LOG_DIR = "logs";
+
+ private static final String JMX_PORT_PROP = "com.sun.management.jmxremote.port";
+
+ /**
+ * Max time, in milliseconds, to wait for a latch to be triggered.
+ */
+ protected static final long WAIT_MS = 5000l;
+
+ /**
+ * Milliseconds that monitor should sleep between cycles.
+ */
+ protected static final long CYCLE_INTERVAL_MS = 2l;
+
+ public static final String DEFAULT_DB_URL_PREFIX = "jdbc:h2:mem:";
+
+ protected static final String dbDriver = "org.h2.Driver";
+ protected static final String dbUser = "testu";
+ protected static final String dbPwd = "testp";
+ protected static final String siteName = "SiteA";
+ protected static final String nodeType = "pap";
+
+ // will be defined by the test *Classes*
+ protected static String dbUrl;
+
+ /**
+ * Persistence unit.
+ */
+ protected static final String PERSISTENCE_UNIT = "schemaPU";
+
+ /**
+ * Properties to be used in all tests.
+ */
+ protected static Properties properties;
+
+ /**
+ * Entity manager factory pointing to the in-memory DB for A_SEQ_PU.
+ */
+ protected static EntityManagerFactory emf;
+
+ /**
+ * Entity manager factory pointing to the in-memory DB associated with emf.
+ */
+ protected static EntityManager em;
+
+ /**
+ * Saved JMX port from system properties, to be restored once all tests
+ * complete.
+ */
+ private static Object savedJmxPort;
+
+ /**
+ * Saved IM persistence unit, to be restored once all tests complete.
+ */
+ private static String savedPU;
+
+ /**
+ * Saved monitor cycle interval, to be restored once all tests complete.
+ */
+ private static long savedCycleIntervalMillis;
+
+ /**
+ * Saved property time units, to be restored once all tests complete.
+ */
+ private static TimeUnit savedPropertyUnits;
+
+ /**
+ * Saves current configuration information and then sets new values.
+ *
+ * @param dbDriver
+ * the name of the DB Driver class
+ * @param dbUrl
+ * the URL to the DB
+ * @throws IOException
+ * @throws Exception
+ */
+ protected static void setUpBeforeClass(String dbUrl) throws IOException {
+ logger.info("setup");
+
+ Properties systemProps = System.getProperties();
+
+ // truncate the logs
+ new FileOutputStream(SLF4J_LOG_DIR + "/audit.log").close();
+ new FileOutputStream(SLF4J_LOG_DIR + "/debug.log").close();
+ new FileOutputStream(SLF4J_LOG_DIR + "/error.log").close();
+ new FileOutputStream(SLF4J_LOG_DIR + "/metrics.log").close();
+
+ IntegrityMonitorTestBase.dbUrl = dbUrl;
+
+ // save data that we have to restore at the end of the test
+ savedJmxPort = systemProps.get(JMX_PORT_PROP);
+ savedPU = IntegrityMonitor.getPersistenceUnit();
+ savedCycleIntervalMillis = IntegrityMonitor.getCycleIntervalMillis();
+ savedPropertyUnits = IntegrityMonitor.getPropertyUnits();
+
+ systemProps.put(JMX_PORT_PROP, "9797");
+
+ IntegrityMonitor.setPersistenceUnit(PERSISTENCE_UNIT);
+ IntegrityMonitor.setCycleIntervalMillis(CYCLE_INTERVAL_MS);
+ IntegrityMonitor.setPropertyUnits(TimeUnit.MILLISECONDS);
+
+ IntegrityMonitor.setUnitTesting(true);
+
+ properties = new Properties();
+ properties.put(IntegrityMonitorProperties.DB_DRIVER, dbDriver);
+ properties.put(IntegrityMonitorProperties.DB_URL, dbUrl);
+ properties.put(IntegrityMonitorProperties.DB_USER, dbUser);
+ properties.put(IntegrityMonitorProperties.DB_PWD, dbPwd);
+ properties.put(IntegrityMonitorProperties.SITE_NAME, siteName);
+ properties.put(IntegrityMonitorProperties.NODE_TYPE, nodeType);
+ properties.put(IntegrityMonitorProperties.REFRESH_STATE_AUDIT_INTERVAL_MS,
+ String.valueOf(100L * CYCLE_INTERVAL_MS));
+
+ emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, makeProperties());
+
+ // keep this open so the in-memory DB stays around until all tests are
+ // done
+ em = emf.createEntityManager();
+
+ stopMonitor();
+ }
+
+ /**
+ * Restores the configuration to what it was before the test.
+ */
+ protected static void tearDownAfterClass() {
+ Properties systemProps = System.getProperties();
+ if (savedJmxPort == null) {
+ systemProps.remove(JMX_PORT_PROP);
+
+ } else {
+ systemProps.put(JMX_PORT_PROP, savedJmxPort);
+ }
+
+ IntegrityMonitor.setPersistenceUnit(savedPU);
+ IntegrityMonitor.setCycleIntervalMillis(savedCycleIntervalMillis);
+ IntegrityMonitor.setPropertyUnits(savedPropertyUnits);
+
+ IntegrityMonitor.setUnitTesting(false);
+
+ // this should result in the in-memory DB being deleted
+ em.close();
+ emf.close();
+ }
+
+ /**
+ * Sets up for a test, which includes deleting all records from the
+ * IntegrityAuditEntity table.
+ */
+ protected void setUpTest() {
+
+ // Clean up the DB
+ try (EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
+
+ em.createQuery("Delete from StateManagementEntity").executeUpdate();
+ em.createQuery("Delete from ForwardProgressEntity").executeUpdate();
+ em.createQuery("Delete from ResourceRegistrationEntity").executeUpdate();
+
+ // commit transaction
+ et.commit();
+ }
+ }
+
+ /**
+ * Cleans up after a test, removing any ExtractAppenders from the logger and
+ * stopping any AuditThreads.
+ */
+ protected void tearDownTest() {
+ stopMonitor();
+ }
+
+ /**
+ * Stops the IntegrityMonitor instance.
+ */
+ private static void stopMonitor() {
+ try {
+ IntegrityMonitor.deleteInstance();
+
+ } catch (IntegrityMonitorException e) {
+ // no need to log, as exception was already logged
+ }
+ }
+
+ /**
+ * Makes a new Property set that's a clone of {@link #properties}.
+ *
+ * @return a new Property set containing all of a copy of all of the
+ * {@link #properties}
+ */
+ protected static Properties makeProperties() {
+ Properties props = new Properties();
+ props.putAll(properties);
+ return props;
+ }
+
+ /**
+ * Waits for a latch to reach zero.
+ *
+ * @param latch
+ * @throws InterruptedException
+ * @throws AssertionError
+ * if the latch did not reach zero in the allotted time
+ */
+ protected void waitLatch(CountDownLatch latch) throws InterruptedException {
+ assertTrue(latch.await(WAIT_MS, TimeUnit.SECONDS));
+ }
+
+ /**
+ * Applies a function on an object, expecting it to succeed. Catches any
+ * exceptions thrown by the function.
+ *
+ * @param arg
+ * @param func
+ * @throws AssertionError
+ */
+ protected <T> void assertNoException(T arg, VoidFunction<T> func) {
+ try {
+ func.apply(arg);
+
+ } catch (Exception e) {
+ System.out.println("startTransaction exception: " + e);
+ fail("action failed");
+ }
+ }
+
+ /**
+ * Applies a function on an object, expecting it to fail. Catches any
+ * exceptions thrown by the function.
+ *
+ * @param arg
+ * @param func
+ * @throws AssertionError
+ */
+ protected <T> void assertException(T arg, VoidFunction<T> func) {
+ try {
+ func.apply(arg);
+ fail("missing exception");
+ } catch (Exception e) {
+ System.out.println("action found expected exception: " + e);
+ }
+ }
+
+ @FunctionalInterface
+ protected static interface VoidFunction<T> {
+ public void apply(T arg) throws Exception;
+ }
+}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
new file mode 100644
index 00000000..44faa58f
--- /dev/null
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementEntityTest.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Monitor
+ * ================================================================================
+ * Copyright (C) 2017-2018 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;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import javax.persistence.Query;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.common.im.jpa.StateManagementEntity;
+import org.onap.policy.common.utils.jpa.EntityTransCloser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StateManagementEntityTest extends IntegrityMonitorTestBase {
+ private static Logger logger = LoggerFactory.getLogger(StateManagementEntityTest.class);
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ IntegrityMonitorTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + StateManagementEntityTest.class.getSimpleName());
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ IntegrityMonitorTestBase.tearDownAfterClass();
+ }
+
+ @Before
+ public void setUp() {
+ super.setUpTest();
+ }
+
+ @After
+ public void tearDown() {
+ super.tearDownTest();
+ }
+
+ @Test
+ public void testJPA() throws Exception {
+ logger.debug("\n??? logger.infor StateManagementEntityTest: Entering\n\n");
+
+ //Define the resourceName for the StateManagement constructor
+ String resourceName = "test_resource1";
+
+ //
+ logger.debug("Create StateManagementEntity, resourceName: {}", resourceName);
+ logger.debug("??? instantiate StateManagementEntity object");
+ StateManagementEntity sme = new StateManagementEntity();
+
+ logger.debug("??? setResourceName : {}", resourceName);
+ sme.setResourceName(resourceName);
+ logger.debug("??? getResourceName : {}", sme.getResourceName());
+
+ sme.setAdminState(StateManagement.UNLOCKED);
+ assertEquals(StateManagement.UNLOCKED, sme.getAdminState());
+
+ sme.setOpState(StateManagement.ENABLED);
+ assertEquals(StateManagement.ENABLED, sme.getOpState());
+
+ sme.setAvailStatus(StateManagement.NULL_VALUE);
+ assertEquals(StateManagement.NULL_VALUE, sme.getAvailStatus());
+
+ sme.setStandbyStatus(StateManagement.COLD_STANDBY);
+ assertEquals(StateManagement.COLD_STANDBY, sme.getStandbyStatus());
+
+ try(EntityTransCloser et = new EntityTransCloser(em.getTransaction())) {
+ logger.debug("??? before persist");
+ em.persist(sme);
+ logger.debug("??? after persist");
+
+ em.flush();
+ logger.debug("??? after flush");
+
+ et.commit();
+ logger.debug("??? after commit");
+ }
+
+ try {
+ Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
+
+ query.setParameter("resource", resourceName);
+
+ //Just test that we are retrieving the right object
+ @SuppressWarnings("rawtypes")
+ List resourceList = query.getResultList();
+ if (!resourceList.isEmpty()) {
+ // exist
+ StateManagementEntity sme2 = (StateManagementEntity) resourceList.get(0);
+
+ assertEquals(sme.getResourceName(), sme2.getResourceName());
+ assertEquals(sme.getAdminState(), sme2.getAdminState());
+ assertEquals(sme.getOpState(), sme2.getOpState());
+ assertEquals(sme.getAvailStatus(), sme2.getAvailStatus());
+ assertEquals(sme.getStandbyStatus(), sme2.getStandbyStatus());
+ logger.debug("--");
+ } else {
+ logger.debug("Record not found, resourceName: {}", resourceName);
+ }
+ } catch(Exception ex) {
+ logger.error("Exception on select query: " + ex.toString());
+ }
+
+ logger.debug("\n\nJpaTest: Exit\n\n");
+ }
+}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java
new file mode 100644
index 00000000..29719215
--- /dev/null
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateManagementTest.java
@@ -0,0 +1,239 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Integrity Monitor
+ * ================================================================================
+ * Copyright (C) 2017-2018 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;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/*
+ * 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 extends IntegrityMonitorTestBase {
+ private static Logger logger = LoggerFactory.getLogger(StateManagementTest.class);
+ //
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ IntegrityMonitorTestBase.setUpBeforeClass(DEFAULT_DB_URL_PREFIX + StateManagementTest.class.getSimpleName());
+
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ IntegrityMonitorTestBase.tearDownAfterClass();
+ }
+
+ @Before
+ public void setUp() {
+ super.setUpTest();
+ }
+
+ @After
+ public void tearDown() {
+ super.tearDownTest();
+ }
+
+ @Test
+ public void test() throws Exception {
+ logger.info("\n\nlogger.infor StateManagementTest: Entering\n\n");
+ String resourceName = "test_resource1";
+
+ // These parameters are in a properties file
+ try {
+ StateManagement sm = new StateManagement(emf, resourceName);
+
+ logger.info("\n??? initial state");
+ assertEquals("unlocked,enabled,null,null", makeString(sm));
+
+ logger.info("\n??? test lock()");
+ sm.lock();
+ assertEquals("locked,enabled,null,null", makeString(sm));
+
+ logger.info("\n??? test unlock()");
+ sm.unlock();
+ assertEquals("unlocked,enabled,null,null", makeString(sm));
+
+ logger.info("\n??? test enableNotFailed()");
+ sm.enableNotFailed();
+ assertEquals("unlocked,enabled,null,null", makeString(sm));
+
+ logger.info("\n??? test disableFailed()");
+ sm.disableFailed();
+ assertEquals("unlocked,disabled,failed,null", makeString(sm));
+
+ // P4 If promote() is called while either the opState is disabled or
+ // the adminState is locked,
+ // the standbystatus shall transition to coldstandby and a
+ // StandbyStatusException shall be thrown
+ logger.info("\n??? promote() test case P4");
+ assertException(sm, smx -> {
+ sm.disableFailed();
+ sm.lock();
+
+ sm.promote();
+ });
+ assertEquals("locked,disabled,failed,coldstandby", makeString(sm));
+
+ // P3 If promote() is called while standbyStatus is coldstandby, the
+ // state shall not transition
+ // and a StandbyStatusException shall be thrown
+ logger.info("\n??? promote() test case P3");
+ assertException(sm, smx -> {
+ sm.promote();
+ });
+ assertEquals("locked,disabled,failed,coldstandby", makeString(sm));
+
+ // P2 If promote() is called while the standbyStatus is null and the
+ // opState is enabled and adminState is unlocked,
+ // the state shall transition to providingservice
+ logger.info("\n??? promote() test case P2");
+ resourceName = "test_resource2";
+ StateManagement sm2 = new StateManagement(emf, resourceName);
+ sm2.enableNotFailed();
+ sm2.unlock();
+ assertEquals("unlocked,enabled,null,null", makeString(sm2));
+ sm2.promote();
+ assertEquals("unlocked,enabled,null,providingservice", makeString(sm2));
+
+ // P5 If promote() is called while standbyStatus is
+ // providingservice, no action is taken
+ logger.info("\n??? promote() test case P5");
+ sm2.promote();
+ assertEquals("unlocked,enabled,null,providingservice", makeString(sm2));
+
+ // D1 If demote() is called while standbyStatus is providingservice,
+ // the state shall transition to hotstandby
+ logger.info("\n??? demote() test case D1");
+ sm2.demote();
+ assertEquals("unlocked,enabled,null,hotstandby", makeString(sm2));
+
+ // D4 If demote() is called while standbyStatus is hotstandby, no
+ // action is taken
+ logger.info("\n??? demote() test case D4");
+ sm2.demote();
+ assertEquals("unlocked,enabled,null,hotstandby", makeString(sm2));
+
+ // D3 If demote() is called while standbyStatus is null and
+ // adminState is locked or opState is disabled,
+ // the state shall transition to coldstandby
+ logger.info("\n??? demote() test case D3");
+ resourceName = "test_resource3";
+ StateManagement sm3 = new StateManagement(emf, resourceName);
+ sm3.lock();
+ sm3.disableFailed();
+ sm3.demote();
+ assertEquals("locked,disabled,failed,coldstandby", makeString(sm3));
+
+ // D5 If demote() is called while standbyStatus is coldstandby, no
+ // action is taken
+ logger.info("\n??? demote() test case D5");
+ sm3.demote();
+ assertEquals("locked,disabled,failed,coldstandby", makeString(sm3));
+
+ // D2 If demote() is called while standbyStatus is null and
+ // adminState is unlocked and opState is enabled,
+ // the state shall transition to hotstandby
+ logger.info("\n??? demote() test case D2");
+ resourceName = "test_resource4";
+ StateManagement sm4 = new StateManagement(emf, resourceName);
+ sm4.unlock();
+ sm4.enableNotFailed();
+ assertEquals("unlocked,enabled,null,null", makeString(sm4));
+ sm4.demote();
+ assertEquals("unlocked,enabled,null,hotstandby", makeString(sm4));
+
+ // P1 If promote() is called while standbyStatus is hotstandby, the
+ // state shall transition to providingservice.
+ logger.info("\n??? promote() test case P1");
+ sm4.promote();
+ assertEquals("unlocked,enabled,null,providingservice", makeString(sm4));
+
+ // State change notification
+ logger.info("\n??? State change notification test case 1 - lock()");
+ StateChangeNotifier stateChangeNotifier = new StateChangeNotifier();
+ sm.addObserver(stateChangeNotifier);
+ sm.lock();
+ assertEquals("locked,disabled,failed,coldstandby", makeString(stateChangeNotifier.getStateManagement()));
+
+ logger.info("\n??? State change notification test case 2 - unlock()");
+ sm.unlock();
+ assertEquals("unlocked,disabled,failed,coldstandby", makeString(stateChangeNotifier.getStateManagement()));
+
+ logger.info("\n??? State change notification test case 3 - enabled()");
+ sm.enableNotFailed();
+ assertEquals("unlocked,enabled,null,hotstandby", makeString(stateChangeNotifier.getStateManagement()));
+
+ logger.info("\n??? State change notification test case 4 - disableFailed()");
+ sm.disableFailed();
+ assertEquals("unlocked,disabled,failed,coldstandby", makeString(stateChangeNotifier.getStateManagement()));
+
+ logger.info("\n??? State change notification test case 5 - demote()");
+ sm.demote();
+ assertEquals("unlocked,disabled,failed,coldstandby", makeString(stateChangeNotifier.getStateManagement()));
+
+ logger.info("\n??? State change notification test case 6 - promote()");
+ assertException(sm, smx -> {
+ sm.promote();
+ });
+ assertEquals("unlocked,disabled,failed,coldstandby", makeString(sm));
+
+ } catch (Exception ex) {
+ logger.error("Exception: {}", ex.toString());
+ throw ex;
+ }
+
+ logger.info("\n\nStateManagementTest: Exit\n\n");
+ }
+
+ /**
+ * Converts a state element to a comma-separated string.
+ *
+ * @param se
+ * element to be converted
+ * @return a string representing the element
+ */
+ private String makeString(StateManagement sm) {
+ if (sm == null) {
+ return null;
+ }
+
+ StringBuilder b = new StringBuilder();
+
+ b.append(sm.getAdminState());
+ b.append(',');
+ b.append(sm.getOpState());
+ b.append(',');
+ b.append(sm.getAvailStatus());
+ b.append(',');
+ b.append(sm.getStandbyStatus());
+
+ return b.toString();
+ }
+}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateTransitionTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateTransitionTest.java
index 6d4dc7c6..177a4489 100644
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateTransitionTest.java
+++ b/integrity-monitor/src/test/java/org/onap/policy/common/im/StateTransitionTest.java
@@ -1,8 +1,8 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -18,18 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.common.im.test;
+package org.onap.policy.common.im;
+
+import static org.junit.Assert.assertEquals;
-import java.util.Properties;
-import javax.persistence.EntityManagerFactory;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-
-import org.onap.policy.common.im.StateTransition;
-import org.onap.policy.common.im.StateElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
@@ -39,17 +36,6 @@ import org.slf4j.LoggerFactory;
*/
public class StateTransitionTest {
private static Logger logger = LoggerFactory.getLogger(StateTransitionTest.class);
-
- private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
- private static final String DEFAULT_DB_URL = "jdbc:h2:file:./sql/smTest";
- private static final String DEFAULT_DB_USER = "sa";
- private static final String DEFAULT_DB_PWD = "";
-
- private static final String DB_DRIVER = "javax.persistence.jdbc.driver";
- private static final String DB_URL = "javax.persistence.jdbc.url";
- private static final String DB_USER = "javax.persistence.jdbc.user";
- private static final String DB_PWD = "javax.persistence.jdbc.password";
- //
@BeforeClass
public static void setUpClass() throws Exception {
@@ -68,19 +54,10 @@ public class StateTransitionTest {
public void tearDown() throws Exception {
}
- //@Ignore
@Test
- public void testJPA() throws Exception {
+ public void test() throws Exception {
logger.info("\n\nlogger.infor StateTransitionTest: Entering\n\n");
- //These parameters are in a properties file
- EntityManagerFactory emf = null;
try {
- Properties myProp = new Properties();
- myProp.put(DB_DRIVER, DEFAULT_DB_DRIVER);
- myProp.put(DB_URL, DEFAULT_DB_URL);
- myProp.put(DB_USER, DEFAULT_DB_USER);
- myProp.put(DB_PWD, DEFAULT_DB_PWD);
-
logger.info("??? create a new StateTransition");
StateTransition st = new StateTransition();
@@ -88,2085 +65,2096 @@ public class StateTransitionTest {
try {
// bad test case
se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "lock");
- //
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
+
logger.info("??? StateTransition testcase 1");
se = st.getEndingState("unlocked", "enabled", "null", "null", "lock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 2");
se = st.getEndingState("unlocked", "enabled", "null", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 3");
se = st.getEndingState("unlocked", "enabled", "null", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 4");
se = st.getEndingState("unlocked", "enabled", "null", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 5");
se = st.getEndingState("unlocked", "enabled", "null", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 6");
se = st.getEndingState("unlocked", "enabled", "null", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 7");
se = st.getEndingState("unlocked", "enabled", "null", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 8");
se = st.getEndingState("unlocked", "enabled", "null", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 9");
se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 10");
se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 11");
se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 12");
se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 13");
se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 14");
se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 15");
se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 16");
se = st.getEndingState("unlocked", "enabled", "null", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 17");
se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 18");
se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 19");
se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 20");
se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 21");
se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 22");
se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 23");
se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 24");
se = st.getEndingState("unlocked", "enabled", "null", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 25");
se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 26");
se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 27");
se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 28");
se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
-
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
+
logger.info("??? StateTransition testcase 29");
se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 30");
se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 31");
se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 32");
se = st.getEndingState("unlocked", "enabled", "null", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 33");
se = st.getEndingState("unlocked", "enabled", "failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 34");
se = st.getEndingState("unlocked", "enabled", "failed", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 35");
se = st.getEndingState("unlocked", "enabled", "failed", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 36");
se = st.getEndingState("unlocked", "enabled", "failed", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 37");
se = st.getEndingState("unlocked", "enabled", "failed", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 38");
se = st.getEndingState("unlocked", "enabled", "failed", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 39");
se = st.getEndingState("unlocked", "enabled", "failed", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 40");
se = st.getEndingState("unlocked", "enabled", "failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 41");
se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 42");
se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 43");
se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 44");
se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 45");
se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 46");
se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 47");
se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 48");
se = st.getEndingState("unlocked", "enabled", "failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 49");
se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 50");
se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 51");
se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 52");
se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 53");
se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 54");
se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 55");
se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 56");
se = st.getEndingState("unlocked", "enabled", "failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 57");
se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 58");
se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 59");
se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 60");
se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 61");
se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 62");
se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 63");
se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 64");
se = st.getEndingState("unlocked", "enabled", "failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 65");
se = st.getEndingState("unlocked", "enabled", "dependency", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 66");
se = st.getEndingState("unlocked", "enabled", "dependency", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 67");
se = st.getEndingState("unlocked", "enabled", "dependency", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 68");
se = st.getEndingState("unlocked", "enabled", "dependency", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 69");
se = st.getEndingState("unlocked", "enabled", "dependency", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 70");
se = st.getEndingState("unlocked", "enabled", "dependency", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 71");
se = st.getEndingState("unlocked", "enabled", "dependency", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 72");
se = st.getEndingState("unlocked", "enabled", "dependency", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 73");
se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 74");
se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 75");
se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 76");
se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 77");
se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 78");
se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 79");
se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 80");
se = st.getEndingState("unlocked", "enabled", "dependency", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 81");
se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 82");
se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 83");
se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 84");
se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 85");
se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 86");
se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 87");
se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 88");
se = st.getEndingState("unlocked", "enabled", "dependency", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 89");
se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 90");
se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 91");
se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 92");
se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 93");
se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 94");
se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 95");
se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 96");
se = st.getEndingState("unlocked", "enabled", "dependency", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 97");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 98");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 99");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 100");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 101");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 102");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 103");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 104");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 105");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 106");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 107");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 108");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 109");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 110");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 111");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 112");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 113");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 114");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 115");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 116");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 117");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 118");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 119");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 120");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 121");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 122");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 123");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 124");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 125");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 126");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 127");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("providingservice,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 128");
se = st.getEndingState("unlocked", "enabled", "dependency,failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 129");
se = st.getEndingState("unlocked", "disabled", "null", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 130");
se = st.getEndingState("unlocked", "disabled", "null", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 131");
se = st.getEndingState("unlocked", "disabled", "null", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 132");
se = st.getEndingState("unlocked", "disabled", "null", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 133");
se = st.getEndingState("unlocked", "disabled", "null", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 134");
se = st.getEndingState("unlocked", "disabled", "null", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 135");
se = st.getEndingState("unlocked", "disabled", "null", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 136");
se = st.getEndingState("unlocked", "disabled", "null", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 137");
se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 138");
se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 139");
se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 140");
se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 141");
se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 142");
se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 143");
se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 144");
se = st.getEndingState("unlocked", "disabled", "null", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 145");
se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 146");
se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 147");
se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 148");
se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 149");
se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 150");
se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 151");
se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 152");
se = st.getEndingState("unlocked", "disabled", "null", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 153");
se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 154");
se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 155");
se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 156");
se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 157");
se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 158");
se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 159");
se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 160");
se = st.getEndingState("unlocked", "disabled", "null", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 161");
se = st.getEndingState("unlocked", "disabled", "failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 162");
se = st.getEndingState("unlocked", "disabled", "failed", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 163");
se = st.getEndingState("unlocked", "disabled", "failed", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 164");
se = st.getEndingState("unlocked", "disabled", "failed", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 165");
se = st.getEndingState("unlocked", "disabled", "failed", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 166");
se = st.getEndingState("unlocked", "disabled", "failed", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 167");
se = st.getEndingState("unlocked", "disabled", "failed", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 168");
se = st.getEndingState("unlocked", "disabled", "failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 169");
se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 170");
se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 171");
se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 172");
se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 173");
se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 174");
se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 175");
se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 176");
se = st.getEndingState("unlocked", "disabled", "failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 177");
se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 178");
se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 179");
se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 180");
se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 181");
se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 182");
se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 183");
se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 184");
se = st.getEndingState("unlocked", "disabled", "failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 185");
se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 186");
se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 187");
se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 188");
se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 189");
se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 190");
se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 191");
se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 192");
se = st.getEndingState("unlocked", "disabled", "failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 193");
se = st.getEndingState("unlocked", "disabled", "dependency", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 194");
se = st.getEndingState("unlocked", "disabled", "dependency", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 195");
se = st.getEndingState("unlocked", "disabled", "dependency", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 196");
se = st.getEndingState("unlocked", "disabled", "dependency", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 197");
se = st.getEndingState("unlocked", "disabled", "dependency", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 198");
se = st.getEndingState("unlocked", "disabled", "dependency", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 199");
se = st.getEndingState("unlocked", "disabled", "dependency", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 200");
se = st.getEndingState("unlocked", "disabled", "dependency", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 201");
se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 202");
se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 203");
se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 204");
se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 205");
se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 206");
se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 207");
se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 208");
se = st.getEndingState("unlocked", "disabled", "dependency", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 209");
se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 210");
se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 211");
se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 212");
se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 213");
se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 214");
se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 215");
se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 216");
se = st.getEndingState("unlocked", "disabled", "dependency", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 217");
se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 218");
se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 219");
se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 220");
se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 221");
se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 222");
se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 223");
se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 224");
se = st.getEndingState("unlocked", "disabled", "dependency", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 225");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 226");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 227");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 228");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 229");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 230");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 231");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 232");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 233");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 234");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 235");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 236");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 237");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 238");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 239");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 240");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 241");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 242");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 243");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 244");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 245");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 246");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 247");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 248");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 249");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 250");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 251");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 252");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 253");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 254");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 255");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 256");
se = st.getEndingState("unlocked", "disabled", "dependency,failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 257");
se = st.getEndingState("locked", "enabled", "null", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 258");
se = st.getEndingState("locked", "enabled", "null", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 259");
se = st.getEndingState("locked", "enabled", "null", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 260");
se = st.getEndingState("locked", "enabled", "null", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 261");
se = st.getEndingState("locked", "enabled", "null", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 262");
se = st.getEndingState("locked", "enabled", "null", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 263");
se = st.getEndingState("locked", "enabled", "null", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 264");
se = st.getEndingState("locked", "enabled", "null", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 265");
se = st.getEndingState("locked", "enabled", "null", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 266");
se = st.getEndingState("locked", "enabled", "null", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 267");
se = st.getEndingState("locked", "enabled", "null", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 268");
se = st.getEndingState("locked", "enabled", "null", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 269");
se = st.getEndingState("locked", "enabled", "null", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 270");
se = st.getEndingState("locked", "enabled", "null", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 271");
se = st.getEndingState("locked", "enabled", "null", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 272");
se = st.getEndingState("locked", "enabled", "null", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 273");
se = st.getEndingState("locked", "enabled", "null", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 274");
se = st.getEndingState("locked", "enabled", "null", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 275");
se = st.getEndingState("locked", "enabled", "null", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 276");
se = st.getEndingState("locked", "enabled", "null", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 277");
se = st.getEndingState("locked", "enabled", "null", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 278");
se = st.getEndingState("locked", "enabled", "null", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 279");
se = st.getEndingState("locked", "enabled", "null", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStateException", makeString(se));
logger.info("??? StateTransition testcase 280");
se = st.getEndingState("locked", "enabled", "null", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 281");
se = st.getEndingState("locked", "enabled", "null", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 282");
se = st.getEndingState("locked", "enabled", "null", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 283");
se = st.getEndingState("locked", "enabled", "null", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 284");
se = st.getEndingState("locked", "enabled", "null", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 285");
se = st.getEndingState("locked", "enabled", "null", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 286");
se = st.getEndingState("locked", "enabled", "null", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 287");
se = st.getEndingState("locked", "enabled", "null", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStateException", makeString(se));
logger.info("??? StateTransition testcase 288");
se = st.getEndingState("locked", "enabled", "null", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 289");
se = st.getEndingState("locked", "enabled", "failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 290");
se = st.getEndingState("locked", "enabled", "failed", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 291");
se = st.getEndingState("locked", "enabled", "failed", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 292");
se = st.getEndingState("locked", "enabled", "failed", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 293");
se = st.getEndingState("locked", "enabled", "failed", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 294");
se = st.getEndingState("locked", "enabled", "failed", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 295");
se = st.getEndingState("locked", "enabled", "failed", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 296");
se = st.getEndingState("locked", "enabled", "failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 297");
se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 298");
se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 299");
se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 300");
se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 301");
se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 302");
se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 303");
se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 304");
se = st.getEndingState("locked", "enabled", "failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 305");
se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 306");
se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 307");
se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 308");
se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 309");
se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 310");
se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 311");
se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 312");
se = st.getEndingState("locked", "enabled", "failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 313");
se = st.getEndingState("locked", "enabled", "failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 314");
se = st.getEndingState("locked", "enabled", "failed", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 315");
se = st.getEndingState("locked", "enabled", "failed", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 316");
se = st.getEndingState("locked", "enabled", "failed", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 317");
se = st.getEndingState("locked", "enabled", "failed", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 318");
se = st.getEndingState("locked", "enabled", "failed", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 319");
se = st.getEndingState("locked", "enabled", "failed", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 320");
se = st.getEndingState("locked", "enabled", "failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 321");
se = st.getEndingState("locked", "enabled", "dependency", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 322");
se = st.getEndingState("locked", "enabled", "dependency", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 323");
se = st.getEndingState("locked", "enabled", "dependency", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 324");
se = st.getEndingState("locked", "enabled", "dependency", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 325");
se = st.getEndingState("locked", "enabled", "dependency", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 326");
se = st.getEndingState("locked", "enabled", "dependency", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 327");
se = st.getEndingState("locked", "enabled", "dependency", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 328");
se = st.getEndingState("locked", "enabled", "dependency", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 329");
se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 330");
se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 331");
se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 332");
se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 333");
se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 334");
se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 335");
se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 336");
se = st.getEndingState("locked", "enabled", "dependency", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 337");
se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 338");
se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 339");
se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 340");
se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 341");
se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 342");
se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 343");
se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 344");
se = st.getEndingState("locked", "enabled", "dependency", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 345");
se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 346");
se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 347");
se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 348");
se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 349");
se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 350");
se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 351");
se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 352");
se = st.getEndingState("locked", "enabled", "dependency", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 353");
se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 354");
se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 355");
se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 356");
se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 357");
se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 358");
se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 359");
se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 360");
se = st.getEndingState("locked", "enabled", "dependency,failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 361");
se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 362");
se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 363");
se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 364");
se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 365");
se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 366");
se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 367");
se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 368");
se = st.getEndingState("locked", "enabled", "dependency,failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 369");
se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 370");
se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 371");
se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 372");
se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 373");
se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 374");
se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 375");
se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 376");
se = st.getEndingState("locked", "enabled", "dependency,failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 377");
se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 378");
se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("hotstandby,unlocked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 379");
se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 380");
se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 381");
se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 382");
se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 383");
se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 384");
se = st.getEndingState("locked", "enabled", "dependency,failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 385");
se = st.getEndingState("locked", "disabled", "null", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 386");
se = st.getEndingState("locked", "disabled", "null", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 387");
se = st.getEndingState("locked", "disabled", "null", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 388");
se = st.getEndingState("locked", "disabled", "null", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 389");
se = st.getEndingState("locked", "disabled", "null", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 390");
se = st.getEndingState("locked", "disabled", "null", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 391");
se = st.getEndingState("locked", "disabled", "null", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 392");
se = st.getEndingState("locked", "disabled", "null", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 393");
se = st.getEndingState("locked", "disabled", "null", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 394");
se = st.getEndingState("locked", "disabled", "null", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 395");
se = st.getEndingState("locked", "disabled", "null", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 396");
se = st.getEndingState("locked", "disabled", "null", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 397");
se = st.getEndingState("locked", "disabled", "null", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 398");
se = st.getEndingState("locked", "disabled", "null", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 399");
se = st.getEndingState("locked", "disabled", "null", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 400");
se = st.getEndingState("locked", "disabled", "null", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 401");
se = st.getEndingState("locked", "disabled", "null", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 402");
se = st.getEndingState("locked", "disabled", "null", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 403");
se = st.getEndingState("locked", "disabled", "null", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 404");
se = st.getEndingState("locked", "disabled", "null", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 405");
se = st.getEndingState("locked", "disabled", "null", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 406");
se = st.getEndingState("locked", "disabled", "null", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 407");
se = st.getEndingState("locked", "disabled", "null", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 408");
se = st.getEndingState("locked", "disabled", "null", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 409");
se = st.getEndingState("locked", "disabled", "null", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 410");
se = st.getEndingState("locked", "disabled", "null", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 411");
se = st.getEndingState("locked", "disabled", "null", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 412");
se = st.getEndingState("locked", "disabled", "null", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 413");
se = st.getEndingState("locked", "disabled", "null", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 414");
se = st.getEndingState("locked", "disabled", "null", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 415");
se = st.getEndingState("locked", "disabled", "null", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 416");
se = st.getEndingState("locked", "disabled", "null", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,null,", makeString(se));
logger.info("??? StateTransition testcase 417");
se = st.getEndingState("locked", "disabled", "failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 418");
se = st.getEndingState("locked", "disabled", "failed", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 419");
se = st.getEndingState("locked", "disabled", "failed", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 420");
se = st.getEndingState("locked", "disabled", "failed", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 421");
se = st.getEndingState("locked", "disabled", "failed", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 422");
se = st.getEndingState("locked", "disabled", "failed", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 423");
se = st.getEndingState("locked", "disabled", "failed", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 424");
se = st.getEndingState("locked", "disabled", "failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 425");
se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 426");
se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 427");
se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 428");
se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 429");
se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 430");
se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 431");
se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 432");
se = st.getEndingState("locked", "disabled", "failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 433");
se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 434");
se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 435");
se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 436");
se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 437");
se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 438");
se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 439");
se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 440");
se = st.getEndingState("locked", "disabled", "failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 441");
se = st.getEndingState("locked", "disabled", "failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 442");
se = st.getEndingState("locked", "disabled", "failed", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 443");
se = st.getEndingState("locked", "disabled", "failed", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 444");
se = st.getEndingState("locked", "disabled", "failed", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 445");
se = st.getEndingState("locked", "disabled", "failed", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 446");
se = st.getEndingState("locked", "disabled", "failed", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 447");
se = st.getEndingState("locked", "disabled", "failed", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 448");
se = st.getEndingState("locked", "disabled", "failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 449");
se = st.getEndingState("locked", "disabled", "dependency", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 450");
se = st.getEndingState("locked", "disabled", "dependency", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 451");
se = st.getEndingState("locked", "disabled", "dependency", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 452");
se = st.getEndingState("locked", "disabled", "dependency", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 453");
se = st.getEndingState("locked", "disabled", "dependency", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 454");
se = st.getEndingState("locked", "disabled", "dependency", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 455");
se = st.getEndingState("locked", "disabled", "dependency", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 456");
se = st.getEndingState("locked", "disabled", "dependency", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 457");
se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 458");
se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 459");
se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 460");
se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 461");
se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 462");
se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 463");
se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 464");
se = st.getEndingState("locked", "disabled", "dependency", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 465");
se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 466");
se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 467");
se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 468");
se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 469");
se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 470");
se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 471");
se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 472");
se = st.getEndingState("locked", "disabled", "dependency", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 473");
se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 474");
se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 475");
se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 476");
se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 477");
se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 478");
se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,enabled,null,", makeString(se));
logger.info("??? StateTransition testcase 479");
se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 480");
se = st.getEndingState("locked", "disabled", "dependency", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 481");
se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 482");
se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("null,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 483");
se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 484");
se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 485");
se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 486");
se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("null,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 487");
se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 488");
se = st.getEndingState("locked", "disabled", "dependency,failed", "null", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 489");
se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 490");
se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 491");
se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 492");
se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 493");
se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 494");
se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 495");
se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 496");
se = st.getEndingState("locked", "disabled", "dependency,failed", "coldstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 497");
se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 498");
se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 499");
se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 500");
se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 501");
se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 502");
se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 503");
se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 504");
se = st.getEndingState("locked", "disabled", "dependency,failed", "hotstandby", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 505");
se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 506");
se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "unlock");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,unlocked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 507");
se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "disableFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 508");
se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "enableNotFailed");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,", makeString(se));
logger.info("??? StateTransition testcase 509");
se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "disableDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
logger.info("??? StateTransition testcase 510");
se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "enableNoDependency");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,failed,", makeString(se));
logger.info("??? StateTransition testcase 511");
se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "promote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,StandbyStatusException", makeString(se));
logger.info("??? StateTransition testcase 512");
se = st.getEndingState("locked", "disabled", "dependency,failed", "providingservice", "demote");
- if (se != null) displayEndingState(se);
+ assertEquals("coldstandby,locked,disabled,dependency,failed,", makeString(se));
} catch (Exception ex) {
logger.error("EndingState NOT found");
throw new Exception("EndingState NOT found. " + ex);
}
-
- //if (emf.isOpen()) {
- //emf.close();
- //}
+
} catch(Exception ex) {
logger.error("Exception: {}" + ex.toString());
throw new Exception("Failure getting ending state. " + ex );
- } finally {
- if (emf != null && emf.isOpen()) {
- emf.close();
- }
}
logger.info("\n\nStateTransitionTest: Exit\n\n");
}
-
- private void displayEndingState(StateElement se)
+
+ /**
+ * Converts a state element to a comma-separated string.
+ * @param se element to be converted
+ * @return a string representing the element
+ */
+ private String makeString(StateElement se)
{
- String endingStandbyStatus = se.getEndingStandbyStatus();
+ if(se == null) {
+ return null;
+ }
+
+ StringBuilder b = new StringBuilder();
+
+ String endingStandbyStatus = se.getEndingStandbyStatus();
if (endingStandbyStatus != null) {
- endingStandbyStatus.replace(".", ",");
+ b.append(endingStandbyStatus.replace(".", ","));
+ b.append(',');
}
- logger.info("EndingAdminState = [{}]" + se.getEndingAdminState());
- logger.info("EndingOpState = [{}]" + se.getEndingOpState());
- logger.info("EndingAvailStatus = [{}]" + se.getEndingAvailStatus());
- logger.info("EndingStandbyStatus= [{}]" + endingStandbyStatus);
- logger.info("Exception = [{}]" + se.getException());
- }
-} \ No newline at end of file
+
+ b.append(se.getEndingAdminState());
+ b.append(',');
+ b.append(se.getEndingOpState());
+ b.append(',');
+ b.append(se.getEndingAvailStatus());
+ b.append(',');
+ b.append(se.getException());
+
+ return b.toString();
+ }
+}
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
deleted file mode 100644
index 6fa8114d..00000000
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/AllSeemsWellTest.java
+++ /dev/null
@@ -1,265 +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=========================================================
- */
-
-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
deleted file mode 100644
index 1efc90cc..00000000
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/IntegrityMonitorTest.java
+++ /dev/null
@@ -1,1095 +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=========================================================
- */
-
-package org.onap.policy.common.im.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Persistence;
-import javax.persistence.Query;
-import javax.persistence.TemporalType;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-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.ResourceRegistrationEntity;
-import org.onap.policy.common.im.jpa.StateManagementEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/*
- * 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 = LoggerFactory.getLogger(IntegrityMonitorTest.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);
-
- cleanMyProp();
-
- // 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");
- }
-
- 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 may occur.
- */
- //@Ignore
- @Test
- public void runAllTests() throws Exception{
- testSanityJmx();
- testIM();
- testSanityState();
- testRefreshStateAudit();
- testStateCheck();
- testGetAllForwardProgressEntity();
- testStateAudit();
- }
-
- /*
- * The following test verifies the following test cases:
- * New Install
- * New Install - Bad Dependency data
- * Recovery from bad dependency data
- * Lock
- * Lock restart
- * Unlock
- * Unlock restart
- */
- 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");
- // 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",
- im.getStateManager().getAdminState(),
- im.getStateManager().getOpState(),
- im.getStateManager().getAvailStatus(),
- im.getStateManager().getStandbyStatus());
- // add an entry to Resource registration table in the DB for the dependent resource
-
-
- et = em.getTransaction();
- et.begin();
- Query rquery = em.createQuery("Select r from ResourceRegistrationEntity r where r.resourceName=:rn");
- rquery.setParameter("rn", dependent);
-
- @SuppressWarnings("rawtypes")
- List rrList = rquery.getResultList();
- ResourceRegistrationEntity rrx = null;
- if(rrList.isEmpty()){
- // register resource by adding entry to table in DB
- logger.debug("Adding resource {} to ResourceRegistration table", dependent);
- rrx = new ResourceRegistrationEntity();
- // set columns in entry
- rrx.setResourceName(dependent);
- rrx.setResourceUrl("service:jmx:somewhere:9999");
- rrx.setNodeType("logparser");
- rrx.setSite("siteA");
- }
- em.persist(rrx);
- // flush to the DB
- em.flush();
-
- // commit transaction
- et.commit();
-
- Thread.sleep(5000); //sleep 5 sec so the FPManager has time to check dependency health
-
- boolean sanityPass = true;
- try {
- im.evaluateSanity();
- } catch (Exception e) {
- logger.error("evaluateSanity exception: ", e);
- sanityPass = false;
- }
- 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);
-
- logger.debug("\ntestSantityJmx ending properties: {}", myProp);
-
- //We know at this point that the IM is disable-dependency. We want to be
- //sure it will recover from this condition since the properties were
- //updated.
-
-
- logger.debug("\n\ntestSanityJmx ending im state\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- im.getStateManager().getAdminState(),
- im.getStateManager().getOpState(),
- im.getStateManager().getAvailStatus(),
- im.getStateManager().getStandbyStatus());
-
- //Destroy the instance
- logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
- IntegrityMonitor.deleteInstance();
- //Create a new instance. It should recover from the disabled-dependency condition
- im = IntegrityMonitor.getInstance(resourceName, myProp);
-
- logger.debug("\n\ntestSanityJmx state after creating new im\n"+
- "AdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- im.getStateManager().getAdminState(),
- im.getStateManager().getOpState(),
- im.getStateManager().getAvailStatus(),
- im.getStateManager().getStandbyStatus());
-
- //Verify the state
- assertEquals(im.getStateManager().getAdminState(), StateManagement.UNLOCKED);
- assertEquals(im.getStateManager().getOpState(), StateManagement.ENABLED);
- assertEquals(im.getStateManager().getAvailStatus(), StateManagement.NULL_VALUE);
- assertEquals(im.getStateManager().getStandbyStatus(), StateManagement.NULL_VALUE);
-
- //Test state manager via the IntegrityMonitor
- StateManagement sm = im.getStateManager();
-
- // Verify lock state
- sm.lock();
- logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
- assert(sm.getAdminState().equals(StateManagement.LOCKED));
-
- //Verify lock persists across a restart
- //Destroy the instance
- logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
- IntegrityMonitor.deleteInstance();
- //Create a new instance. It should come up with the admin state locked
- im = IntegrityMonitor.getInstance(resourceName, myProp);
- sm = im.getStateManager();
- logger.debug("\n\ntestSanityJmx restart with AdminState=locked"+
- "\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
- assert(sm.getAdminState().equals(StateManagement.LOCKED));
-
- // Verify unlock
- sm.unlock();
- logger.debug("\n\ntestSanityJmx sm.unlock\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
- assert(sm.getAdminState().equals(StateManagement.UNLOCKED));
-
- // Verify unlock restart
- //Destroy the instance
- logger.debug("\ntestSanityJmx restarting the IntegrityMonitor");
- IntegrityMonitor.deleteInstance();
- //Create a new instance. It should come up with the admin state locked
- im = IntegrityMonitor.getInstance(resourceName, myProp);
- sm = im.getStateManager();
- logger.debug("\n\ntestSanityJmx restart with AdminState=unlocked\n" +
- "AdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
-
- assert(sm.getAdminState().equals(StateManagement.UNLOCKED));
-
- logger.debug("\n\ntestSanityJmx: Exit\n\n");
- }
-
-
- public void testIM() throws Exception {
- logger.debug("\nIntegrityMonitorTest: Entering testIM\n\n");
- cleanDb();
- cleanMyProp();
- IntegrityMonitor.deleteInstance();
-
- // 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");
-
- IntegrityMonitor im = IntegrityMonitor.getInstance(resourceName, myProp);
-
- logger.debug("\n\nim initial state: \nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- im.getStateManager().getAdminState(),
- im.getStateManager().getOpState(),
- im.getStateManager().getAvailStatus(),
- im.getStateManager().getStandbyStatus());
-
- // test evaluate sanity
- boolean sanityPass = true;
- try {
- im.evaluateSanity();
- } catch (Exception e) {
- logger.error("evaluateSanity exception: ", e);
- sanityPass = false;
- }
- assertTrue(sanityPass); // expect sanity test to pass
-
- //Test startTransaction - should works since it is unlocked
- boolean transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(transPass);
-
- //Test state manager via the IntegrityMonitor
- StateManagement sm = im.getStateManager();
-
- sm.lock();
-
- logger.debug("\n\nsm.lock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
-
- assert(sm.getAdminState().equals(StateManagement.LOCKED));
-
- //test startTransaction. It should fail since it is locked
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(!transPass); //expect it to fail
-
- sm.unlock();
- logger.debug("\n\nsm.unlock()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
- assert(sm.getAdminState().equals(StateManagement.UNLOCKED));
-
- //test startTransaction. It should succeed
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(transPass); //expect it to succeed
-
- sm.disableDependency();
- logger.debug("\n\nsm.disableDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
-
- assert(sm.getOpState().equals(StateManagement.DISABLED));
- assert(sm.getAvailStatus().equals(StateManagement.DEPENDENCY));
-
- //test startTransaction. It should succeed since standby status is null and unlocked
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(transPass); //expect it to succeed
-
- sm.enableNoDependency();
-
- logger.debug("\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
- assert(sm.getOpState().equals(StateManagement.ENABLED));
- //test startTransaction. It should succeed since standby status is null and unlocked
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- System.out.println("startTransaction exception: " + e);
- transPass = false;
- }
- assertTrue(transPass); //expect it to succeed
-
-
- sm.disableFailed();
- logger.debug("\n\nsm.disableFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
-
- assert(sm.getOpState().equals(StateManagement.DISABLED));
- assert(sm.getAvailStatus().equals(StateManagement.FAILED));
- //test startTransaction. It should succeed since standby status is null and unlocked
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- System.out.println("startTransaction exception: " + e);
- transPass = false;
- }
- assertTrue(transPass); //expect it to succeed
-
- sm.enableNotFailed();
-
- logger.debug("\n\nsm.enabledNotFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
-
- assert(sm.getOpState().equals(StateManagement.ENABLED));
- //test startTransaction. It should succeed since standby status is null and unlocked
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(transPass); //expect it to succeed
-
- sm.demote();
-
- logger.debug("\n\nsm.demote()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
-
- assert(sm.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
-
- //test startTransaction. It should fail since it is standby
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(!transPass); //expect it to fail
-
- sm.promote();
-
- logger.debug("\n\nsm.promote()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
-
- assert(sm.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
-
- //test startTransaction. It should succeed since it is providing service
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(transPass); //expect it to succeed
-
-
- //Test the multi-valued availability status
- sm.disableDependency();
- sm.disableFailed();
-
- logger.debug("\n\nsm.disableDependency(), sm.disableFailed\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
-
- assert(sm.getAvailStatus().equals(StateManagement.DEPENDENCY_FAILED));
-
- //Test startTransaction. Should fail since standby status is cold standby
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(!transPass); //expect it to fail
-
- sm.enableNoDependency();
-
- logger.debug("\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
- assert(sm.getAvailStatus().equals(StateManagement.FAILED));
- //Test startTransaction. Should fail since standby status is cold standby
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(!transPass); //expect it to fail
-
- sm.disableDependency();
- sm.enableNotFailed();
-
- logger.debug("\n\nsm.disableDependency(),sm.enableNotFailed()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
-
- assert(sm.getAvailStatus().equals(StateManagement.DEPENDENCY));
- //Test startTransaction. Should fail since standby status is cold standby
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(!transPass); //expect it to fail
-
- sm.enableNoDependency();
- logger.debug("\n\nsm.enableNoDependency()\nAdminState = {}\nOpState() = {}\nAvailStatus = {}\nStandbyStatus = {}\n",
- sm.getAdminState(),
- sm.getOpState(),
- sm.getAvailStatus(),
- sm.getStandbyStatus());
- assert(sm.getOpState().equals(StateManagement.ENABLED));
- //test startTransaction. It should fail since standby status is hot standby
- transPass = true;
- try{
- im.startTransaction();
- } catch (Exception e){
- logger.error("startTransaction exception: ", e);
- transPass = false;
- }
- assertTrue(!transPass); //expect it to fail
-
- logger.debug("\n\ntestIM: Exit\n\n");
- }
-
-
- 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");
- // 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);
-
- // Add a group1 dependent resources to put an entry in the forward progress table
- ForwardProgressEntity fpe = new ForwardProgressEntity();
- ForwardProgressEntity fpe2 = new ForwardProgressEntity();
- fpe.setFpcCount(0);
- fpe.setResourceName("group1_dep1");
- fpe2.setFpcCount(0);
- fpe2.setResourceName("group1_dep2");
- et = em.getTransaction();
- et.begin();
- em.persist(fpe);
- em.persist(fpe2);
- em.flush();
- et.commit();
-
-
- // Add a group2 dependent resource to the StateManagementEntity DB table and set its admin state to locked
- // Expect sanity test to fail.
- StateManagement stateManager = new StateManagement(emf, "group2_dep1");
- stateManager.lock();
-
- new StateManagement(emf, "group1_dep1");
- new StateManagement(emf, "group1_dep2");
-
- boolean sanityPass = true;
- // 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) {
- logger.error("evaluateSanity exception: ", e);
- sanityPass = false;
- }
- assertFalse(sanityPass); // expect sanity test to fail
-
- 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");
- // 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 im = IntegrityMonitor.getInstance(resourceName, myProp);
-
- //the state here is unlocked, enabled, null, null
- StateManagementEntity sme = null;
-
- Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
-
- query.setParameter("resource", resourceName);
-
- //Just test that we are retrieving the right object
- @SuppressWarnings("rawtypes")
- List resourceList = query.getResultList();
- if (!resourceList.isEmpty()) {
- // exist
- sme = (StateManagementEntity) resourceList.get(0);
- em.refresh(sme);
-
- logger.debug("??? -- Retrieve StateManagementEntity from database --\nsme.getResourceName() = {}\n"+
- "sme.getAdminState() = {}\nsme.getOpState() = {}\nsme.getAvailStatus() = {}\nsme.getStandbyStatus() = {}",
- sme.getResourceName(),
- sme.getAdminState(),
- sme.getOpState(),
- sme.getAvailStatus(),
- sme.getStandbyStatus());
-
- assertTrue(sme.getAdminState().equals(StateManagement.UNLOCKED));
- assertTrue(sme.getOpState().equals(StateManagement.ENABLED));
- assertTrue(sme.getAvailStatus().equals(StateManagement.NULL_VALUE));
- assertTrue(sme.getStandbyStatus().equals(StateManagement.NULL_VALUE));
- logger.debug("--");
- } else {
- logger.debug("Record not found, resourceName: " + resourceName);
- assertTrue(false);
- }
-
- et = em.getTransaction();
- et.begin();
-
- sme.setStandbyStatus(StateManagement.COLD_STANDBY);
- em.persist(sme);
- em.flush();
- et.commit();
-
- // Run the refreshStateAudit
- im.executeRefreshStateAudit();
-
- //The refreshStateAudit should run and change the state to unlocked,enabled,null,hotstandby
- StateManagementEntity sme1 = null;
-
- Query query1 = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
-
- query1.setParameter("resource", resourceName);
-
- @SuppressWarnings("rawtypes")
- List resourceList1 = query1.getResultList();
- if (!resourceList1.isEmpty()) {
- // exist
- sme1 = (StateManagementEntity) resourceList1.get(0);
- em.refresh(sme1);
- logger.debug("??? -- Retrieve StateManagementEntity from database --\nsme1.getResourceName() = {}\n" +
- "sme1.getAdminState() = {}\nsme1.getOpState() = {}\nsme1.getAvailStatus() = {}\nsme1.getStandbyStatus() = {}",
- sme1.getResourceName(),
- sme1.getAdminState(),
- sme1.getOpState(),
- sme1.getAvailStatus(),
- sme1.getStandbyStatus());
-
- assertTrue(sme1.getAdminState().equals(StateManagement.UNLOCKED));
- assertTrue(sme1.getOpState().equals(StateManagement.ENABLED));
- assertTrue(sme1.getAvailStatus().equals(StateManagement.NULL_VALUE));
- assertTrue(sme1.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
- logger.debug("--");
- } else {
- logger.debug("Record not found, resourceName: " + resourceName);
- assertTrue(false);
- }
-
- 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");
- /*
- * 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.
- */
- 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);
-
- // 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();
-
- new StateManagement(emf, "group1_dep1");
-
- boolean sanityPass = true;
- //Thread.sleep(15000);
- //Thread.sleep(5000);
- try {
- im.evaluateSanity();
- } catch (Exception e) {
- logger.error("testStateCheck: After 5 sec sleep - evaluateSanity exception: ", e);
- sanityPass = false;
- }
- assertTrue(sanityPass); // expect sanity test to pass
-
- //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(10000);
- try {
- im.evaluateSanity();
- } catch (Exception e) {
- logger.error("testStateCheck: After 15 sec sleep - evaluateSanity exception: ", e);
- sanityPass = false;
- }
- assertFalse(sanityPass); // expect sanity test to fail
-
- 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, "");
- 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 im = IntegrityMonitor.getInstance(resourceName, myProp);
-
- logger.debug("\nIntegrityMonitorTest: Creating ForwardProgressEntity entries\n\n");
- // Add resource entries in the forward progress table
- ForwardProgressEntity fpe = new ForwardProgressEntity();
- ForwardProgressEntity fpe2 = new ForwardProgressEntity();
- ForwardProgressEntity fpe3 = new ForwardProgressEntity();
- fpe.setFpcCount(0);
- fpe.setResourceName("siteA_pap2");
- fpe2.setFpcCount(0);
- fpe2.setResourceName("siteB_pap1");
- fpe3.setFpcCount(0);
- fpe3.setResourceName("siteB_pap2");
- et = em.getTransaction();
- et.begin();
- em.persist(fpe);
- em.persist(fpe2);
- em.persist(fpe3);
- em.flush();
- et.commit();
-
- logger.debug("\nIntegrityMonitorTest:testGetAllForwardProgressEntity Calling im.getAllForwardProgressEntity()\n\n");
- List<ForwardProgressEntity> fpeList = im.getAllForwardProgressEntity();
-
- assertTrue(fpeList.size()==4);
-
- 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
-
- // 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 im = IntegrityMonitor.getInstance(resourceName, myProp);
- logger.debug("\nIntegrityMonitorTest: Creating ForwardProgressEntity entries\n\n");
- // Add resources to put an entry in the forward progress table
- Date staleDate = new Date(0);
- ForwardProgressEntity fpe1 = new ForwardProgressEntity();
- ForwardProgressEntity fpe2 = new ForwardProgressEntity();
- ForwardProgressEntity fpe3 = new ForwardProgressEntity();
- fpe1.setFpcCount(0);
- fpe1.setResourceName("siteA_pap2");
- fpe2.setFpcCount(0);
- fpe2.setResourceName("siteB_pap1");
- fpe3.setFpcCount(0);
- fpe3.setResourceName("siteB_pap2");
- logger.debug("\nIntegrityMonitorTest: Creating StateManagementEntity entries\n\n");
- StateManagementEntity sme1 = new StateManagementEntity();
- StateManagementEntity sme2 = new StateManagementEntity();
- StateManagementEntity sme3= new StateManagementEntity();
- sme1.setResourceName("siteA_pap2");
- sme1.setAdminState(StateManagement.UNLOCKED);
- sme1.setOpState(StateManagement.ENABLED);
- sme1.setAvailStatus(StateManagement.NULL_VALUE);
- sme1.setStandbyStatus(StateManagement.NULL_VALUE);
- sme2.setResourceName("siteB_pap1");
- sme2.setAdminState(StateManagement.UNLOCKED);
- sme2.setOpState(StateManagement.ENABLED);
- sme2.setAvailStatus(StateManagement.NULL_VALUE);
- sme2.setStandbyStatus(StateManagement.NULL_VALUE);
- sme3.setResourceName("siteB_pap2");
- sme3.setAdminState(StateManagement.UNLOCKED);
- sme3.setOpState(StateManagement.ENABLED);
- sme3.setAvailStatus(StateManagement.NULL_VALUE);
- sme3.setStandbyStatus(StateManagement.NULL_VALUE);
- et = em.getTransaction();
- et.begin();
- em.persist(fpe1);
- em.persist(fpe2);
- em.persist(fpe3);
- em.persist(sme1);
- em.persist(sme2);
- em.persist(sme3);
- em.flush();
- et.commit();
-
- Query updateQuery = em.createQuery("UPDATE ForwardProgressEntity f "
- + "SET f.lastUpdated = :newDate "
- + "WHERE f.resourceName=:resource");
- updateQuery.setParameter("newDate", staleDate, TemporalType.TIMESTAMP);
- updateQuery.setParameter("resource", fpe1.getResourceName());
-
- et = em.getTransaction();
- et.begin();
- updateQuery.executeUpdate();
- et.commit();
-
- logger.debug("\nIntegrityMonitorTest:testStateAudit Calling im.getAllForwardProgressEntity()\n\n");
- List<ForwardProgressEntity> fpeList = im.getAllForwardProgressEntity();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:ForwardProgressEntity entries");
- for(ForwardProgressEntity myFpe : fpeList){
- logger.debug("\n ResourceName: {}" +
- "\n LastUpdated: {}",
- myFpe.getResourceName(),
- myFpe.getLastUpdated());
- }
- logger.debug("\n\n");
-
- logger.debug("\nIntegrityMonitorTest:testStateAudit getting list of StateManagementEntity entries\n\n");
- Query query = em.createQuery("SELECT s FROM StateManagementEntity s");
- List<?> smeList = query.getResultList();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity entries");
- for(Object mySme : smeList){
- StateManagementEntity tmpSme = (StateManagementEntity) mySme;
- em.refresh(tmpSme);
- logger.debug("\n 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));
-
- 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();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity entries");
- for(Object mySme : smeList){
- StateManagementEntity tmpSme = (StateManagementEntity) mySme;
- em.refresh(tmpSme);
- logger.debug("\n 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.DISABLED));
-
- //Now let's add sme2 to the mix
- updateQuery = em.createQuery("UPDATE ForwardProgressEntity f "
- + "SET f.lastUpdated = :newDate "
- + "WHERE f.resourceName=:resource");
- updateQuery.setParameter("newDate", staleDate, TemporalType.TIMESTAMP);
- updateQuery.setParameter("resource", fpe2.getResourceName());
-
- et = em.getTransaction();
- et.begin();
- updateQuery.executeUpdate();
- et.commit();
-
- //Give it a chance to write the DB and run the audit
- 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");
- smeList = query.getResultList();
-
- logger.debug("\n\n");
- logger.debug("IntegrityMonitorTest:testStateAudit:StateManagementEntity (restart4) entries");
- for(Object mySme : smeList){
- StateManagementEntity tmpSme = (StateManagementEntity) mySme;
- em.refresh(tmpSme);
-
- logger.debug("\n (restart4) 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.DISABLED));
-
- em.refresh(sme2);
- assertTrue(sme2.getOpState().equals(StateManagement.DISABLED));
-
- logger.debug("\nIntegrityMonitorTest: Exit testStateAudit\n\n");
- System.out.println("\n\ntestStateAudit: Exit\n\n");
- }
-}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementEntityTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementEntityTest.java
deleted file mode 100644
index 852a04f6..00000000
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementEntityTest.java
+++ /dev/null
@@ -1,193 +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=========================================================
- */
-
-package org.onap.policy.common.im.test;
-
-import java.util.List;
-import java.util.Properties;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Persistence;
-import javax.persistence.Query;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import org.onap.policy.common.im.StateManagement;
-import org.onap.policy.common.im.jpa.StateManagementEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class StateManagementEntityTest {
- private static Logger logger = LoggerFactory.getLogger(StateManagementEntityTest.class);
-
- private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
- private static final String DEFAULT_DB_URL = "jdbc:h2:file:./sql/smTest";
- //private static final String DEFAULT_DB_URL = "jdbc:h2:file:./sql/xacml";
- private static final String DEFAULT_DB_USER = "sa";
- private static final String DEFAULT_DB_PWD = "";
-
- /*
- private static final String DEFAULT_DB_DRIVER = "org.mariadb.jdbc.Driver";
- private static final String DEFAULT_DB_URL = "jdbc:mariadb://localhost:3306/xacml";
- private static final String DEFAULT_DB_USER = "policy_user";
- private static final String DEFAULT_DB_PWD = "policy_user";
- */
-
- private static final String DB_DRIVER = "javax.persistence.jdbc.driver";
- private static final String DB_URL = "javax.persistence.jdbc.url";
- private static final String DB_USER = "javax.persistence.jdbc.user";
- private static final String DB_PWD = "javax.persistence.jdbc.password";
-
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- //@Ignore
- @Test
- public void testJPA() throws Exception {
- logger.debug("\n??? logger.infor StateManagementEntityTest: Entering\n\n");
-
- Properties myProp = new Properties();
- myProp.put(DB_DRIVER, DEFAULT_DB_DRIVER);
- myProp.put(DB_URL, DEFAULT_DB_URL);
- myProp.put(DB_USER, DEFAULT_DB_USER);
- myProp.put(DB_PWD, DEFAULT_DB_PWD);
-
- logger.debug("??? {} = {}", DB_DRIVER, DEFAULT_DB_DRIVER);
- logger.debug("??? {} = {}", DB_URL, DEFAULT_DB_URL);
- logger.debug("??? {} = {}", DB_USER, DEFAULT_DB_USER);
- logger.debug("??? {} = {}", DB_PWD, DEFAULT_DB_PWD);
-
- //Create the data schema and entity manager factory
- logger.debug("??? createEntityManagerFactory for schemaPU");
- EntityManagerFactory emf = Persistence.createEntityManagerFactory("schemaPU", myProp);
-
- // Create an entity manager to use the DB
- logger.debug("??? createEntityManager");
- EntityManager em = emf.createEntityManager();
- logger.debug("??? getTransaction");
- EntityTransaction et = em.getTransaction();
- et.begin();
- // Make sure the DB is clean
- logger.debug("??? clean StateManagementEntity");
- em.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
-
- //Define the resourceName for the StateManagement constructor
- String resourceName = "test_resource1";
-
- //
- logger.debug("Create StateManagementEntity, resourceName: {}", resourceName);
- logger.debug("??? instantiate StateManagementEntity object");
- StateManagementEntity sme = new StateManagementEntity();
-
- logger.debug("??? setResourceName : {}", resourceName);
- sme.setResourceName(resourceName);
- logger.debug("??? getResourceName : {}", sme.getResourceName());
-
- logger.debug("??? setAdminState : {}", StateManagement.UNLOCKED);
- sme.setAdminState(StateManagement.UNLOCKED);
- logger.debug("??? getAdminState : {}", sme.getAdminState());
-
- logger.debug("??? setOpState : {}", StateManagement.ENABLED);
- sme.setOpState(StateManagement.ENABLED);
- logger.debug("??? getOpState : {}", sme.getOpState());
-
- logger.debug("??? setAvailStatus : {}", StateManagement.NULL_VALUE);
- sme.setAvailStatus(StateManagement.NULL_VALUE);
- logger.debug("??? getAvailStatus : {}", sme.getAvailStatus());
-
- logger.debug("??? setStandbyStatus: {}", StateManagement.COLD_STANDBY);
- sme.setStandbyStatus(StateManagement.COLD_STANDBY);
- logger.debug("??? getStandbyStatus: {}", sme.getStandbyStatus());
-
- logger.debug("??? before persist");
- em.persist(sme);
- logger.debug("??? after persist");
-
- em.flush();
- logger.debug("??? after flush");
-
- et.commit();
- logger.debug("??? after commit");
-
- try {
- Query query = em.createQuery("Select p from StateManagementEntity p where p.resourceName=:resource");
-
- query.setParameter("resource", resourceName);
-
- //Just test that we are retrieving the right object
- @SuppressWarnings("rawtypes")
- List resourceList = query.getResultList();
- if (!resourceList.isEmpty()) {
- // exist
- StateManagementEntity sme2 = (StateManagementEntity) resourceList.get(0);
- logger.debug("??? -- Retrieve StateManagementEntity from database --\n\nsme.getResourceName() = {}\n" +
- "sme2getResourceName() = {}\n\nsme.getAdminState() = {}\nsme2.getAdminState() = {}\n\n" +
- "sme.getOpState() = {}\nsme2.getOpState() = {}\n\nsme.getAvailStatus() = {}\n" +
- "sme2.getAvailStatus() = {}\n\nsme.getStandbyStatus() = {}\nsme2.getStandbyStatus() = {}",
- sme.getResourceName(),
- sme2.getResourceName(),
- sme.getAdminState(),
- sme2.getAdminState(),
- sme.getOpState(),
- sme2.getOpState(),
- sme.getAvailStatus(),
- sme.getAvailStatus(),
- sme.getStandbyStatus(),
- sme2.getStandbyStatus());
-
-
- assert(sme2.getResourceName().equals(sme.getResourceName()));
- assert(sme2.getAdminState().equals(sme.getAdminState()));
- assert(sme2.getOpState().equals(sme.getOpState()));
- assert(sme2.getAvailStatus().equals(sme.getAvailStatus()));
- assert(sme2.getStandbyStatus().equals(sme.getStandbyStatus()));
- logger.debug("--");
- } else {
- logger.debug("Record not found, resourceName: {}", resourceName);
- }
- } catch(Exception ex) {
- logger.error("Exception on select query: " + ex.toString());
- }
-
- em.close();
- logger.debug("\n??? after close");
- logger.debug("\n\nJpaTest: Exit\n\n");
- }
-}
diff --git a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementTest.java b/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementTest.java
deleted file mode 100644
index a3c0fcd7..00000000
--- a/integrity-monitor/src/test/java/org/onap/policy/common/im/test/StateManagementTest.java
+++ /dev/null
@@ -1,315 +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=========================================================
- */
-
-package org.onap.policy.common.im.test;
-
-import java.util.Properties;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.im.StateManagement;
-import org.onap.policy.common.im.StandbyStatusException;
-import org.onap.policy.common.im.StateChangeNotifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/*
- * 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 = LoggerFactory.getLogger(StateManagementTest.class);
-
- private static final String DEFAULT_DB_DRIVER = "org.h2.Driver";
- private static final String DEFAULT_DB_URL = "jdbc:h2:file:./sql/smTest";
- private static final String DEFAULT_DB_USER = "sa";
- private static final String DEFAULT_DB_PWD = "";
-
- private static final String DB_DRIVER = "javax.persistence.jdbc.driver";
- private static final String DB_URL = "javax.persistence.jdbc.url";
- private static final String DB_USER = "javax.persistence.jdbc.user";
- private static final String DB_PWD = "javax.persistence.jdbc.password";
- //
-
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- //@Ignore
- @Test
- public void testJPA() throws Exception {
- logger.info("\n\nlogger.infor StateManagementTest: Entering\n\n");
- String resourceName = "test_resource1";
- boolean standbyExceptionThrown = false;
-
- //These parameters are in a properties file
- EntityManagerFactory emf = null;
- try {
- Properties myProp = new Properties();
- myProp.put(DB_DRIVER, DEFAULT_DB_DRIVER);
- myProp.put(DB_URL, DEFAULT_DB_URL);
- myProp.put(DB_USER, DEFAULT_DB_USER);
- myProp.put(DB_PWD, DEFAULT_DB_PWD);
-
- //Create the data schema and entity manager factory
- emf = Persistence.createEntityManagerFactory("schemaPU", myProp);
-
- StateManagement sm = new StateManagement(emf, resourceName);
- logger.info("\n\ntest lock()");
- displayState(resourceName, sm);
- logger.info("\n??? test lock()");
- logger.info("{} before adminState = {}", resourceName, sm.getAdminState());
- logger.info("{} before opState = {}", resourceName, sm.getOpState());
- logger.info("{} before availStatus = {}", resourceName, sm.getAvailStatus());
- logger.info("{} before standbyStatus= {}", resourceName, sm.getStandbyStatus());
- sm.lock();
- System.out.println("\n\nafter lock()");
- displayState(resourceName, sm);
- logger.info("{} after adminState = {}", resourceName, sm.getAdminState());
- logger.info("{} after opState = {}", resourceName, sm.getOpState());
- logger.info("{} after availStatus = {}", resourceName, sm.getAvailStatus());
- logger.info("{} after standbyStatus= {}", resourceName, sm.getStandbyStatus());
-
- logger.info("\n??? test unlock()");
- sm.unlock();
- System.out.println("\n\nafter unlock()");
- displayState(resourceName, sm);
- logger.info("{} adminState = {}", resourceName, sm.getAdminState());
- logger.info("{} opState = {}", resourceName, sm.getOpState());
- logger.info("{} availStatus = {}", resourceName, sm.getAvailStatus());
- logger.info("{} standbyStatus= {}", resourceName, sm.getStandbyStatus());
-
- logger.info("\n??? test enableNotFailed()");
- sm.enableNotFailed();
- System.out.println("\n\nafter enableNotFailed()");
- displayState(resourceName, sm);
- logger.info("{} adminState = {}", resourceName, sm.getAdminState());
- logger.info("{} opState = {}", resourceName, sm.getOpState());
- logger.info("{} availStatus = {}", resourceName, sm.getAvailStatus());
- logger.info("{} standbyStatus= {}", resourceName, sm.getStandbyStatus());
-
- logger.info("\n??? test disableFailed()");
- sm.disableFailed();
- System.out.println("\n\nafter disableFailed()");
- displayState(resourceName, sm);
- logger.info("{} adminState = {}", resourceName, sm.getAdminState());
- logger.info("{} opState = {}", resourceName, sm.getOpState());
- logger.info("{} availStatus = {}", resourceName, sm.getAvailStatus());
- logger.info("{} standbyStatus= {}", resourceName, sm.getStandbyStatus());
-
- // P4 If promote() is called while either the opState is disabled or the adminState is locked,
- // the standbystatus shall transition to coldstandby and a StandbyStatusException shall be thrown
- logger.info("\n??? promote() test case P4");
- try {
- sm.disableFailed();
- sm.lock();
- System.out.println("\n\nafter lock() and disableFailed");
- displayState(resourceName, sm);
- logger.info("{} adminState = {}", resourceName, sm.getAdminState());
- logger.info("{} opState = {}", resourceName, sm.getOpState());
- logger.info("{} standbyStatus= {}", resourceName, sm.getStandbyStatus());
- sm.promote();
- System.out.println("\n\nafter promote");
- displayState(resourceName, sm);
- } catch(StandbyStatusException ex) {
- standbyExceptionThrown = true;
- logger.info("StandbyStatusException thrown and catched");
- } catch(Exception ex) {
- logger.info("??? Exception: " + ex.toString());
- }
- assert(standbyExceptionThrown);
- assert(sm.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
- standbyExceptionThrown = false;
-
- // P3 If promote() is called while standbyStatus is coldstandby, the state shall not transition
- // and a StandbyStatusException shall be thrown
- logger.info("\n??? promote() test case P3");
- try {
- logger.info(resourceName + " standbyStatus= " + sm.getStandbyStatus());
- sm.promote();
- } catch(StandbyStatusException ex) {
- standbyExceptionThrown = true;
- logger.info("StandbyStatusException thrown and catched");
- } catch(Exception ex) {
- logger.info("??? Exception: " + ex.toString());
- }
- assert(standbyExceptionThrown);
- assert(sm.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
- logger.info("\n\nP3 after promote()");
- displayState(resourceName, sm);
- standbyExceptionThrown = false;
-
- // P2 If promote() is called while the standbyStatus is null and the opState is enabled and adminState is unlocked,
- // the state shall transition to providingservice
- logger.info("\n??? promote() test case P2");
- resourceName = "test_resource2";
- StateManagement sm2 = new StateManagement(emf, resourceName);
- sm2.enableNotFailed();
- sm2.unlock();
- logger.info("\n\nafter sm2.enableNotFailed() and sm2.unlock()");
- displayState(resourceName, sm2);
- logger.info("{} adminState = {}", resourceName, sm2.getAdminState());
- logger.info("{} opState = {}", resourceName, sm2.getOpState());
- logger.info("{} standbyStatus= {}", resourceName, sm2.getStandbyStatus());
- sm2.promote();
- logger.info("\n\nP2 after sm2.promote");
- displayState(resourceName, sm2);
- assert(sm2.getAdminState().equals(StateManagement.UNLOCKED));
- assert(sm2.getOpState().equals(StateManagement.ENABLED));
- assert(sm2.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
-
- // P5 If promote() is called while standbyStatus is providingservice, no action is taken
- logger.info("\n??? promote() test case P5");
- logger.info(resourceName + " standbyStatus= " + sm2.getStandbyStatus());
- sm2.promote();
- logger.info("\n\nP5 after sm2.promote()");
- displayState(resourceName, sm2);
- assert(sm2.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
-
- // D1 If demote() is called while standbyStatus is providingservice, the state shall transition to hotstandby
- logger.info("\n??? demote() test case D1");
- logger.info(resourceName + " standbyStatus= " + sm2.getStandbyStatus());
- sm2.demote();
- logger.info("\n\nD1 after sm2.demote()");
- displayState(resourceName, sm2);
- assert(sm2.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
-
- // D4 If demote() is called while standbyStatus is hotstandby, no action is taken
- logger.info("\n??? demote() test case D4");
- logger.info(resourceName + " standbyStatus= " + sm2.getStandbyStatus());
- sm2.demote();
- logger.info("\n\nD4 after sm2.demote()");
- displayState(resourceName, sm2);
- assert(sm2.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
-
- // D3 If demote() is called while standbyStatus is null and adminState is locked or opState is disabled,
- // the state shall transition to coldstandby
- logger.info("\n??? demote() test case D3");
- resourceName = "test_resource3";
- StateManagement sm3 = new StateManagement(emf, resourceName);
- sm3.lock();
- sm3.disableFailed();
- logger.info("\n\nD3 after sm3.lock() and sm3.disableFailed()");
- displayState(resourceName, sm3);
- logger.info("{} adminState = {}", resourceName, sm3.getAdminState());
- logger.info("{} opState = {}", resourceName, sm3.getOpState());
- logger.info("{} standbyStatus= {}", resourceName, sm3.getStandbyStatus());
- sm3.demote();
- logger.info("\n\nD3 after sm3.demote()");
- displayState(resourceName, sm3);
- assert(sm3.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
-
- // D5 If demote() is called while standbyStatus is coldstandby, no action is taken
- logger.info("\n??? demote() test case D5");
- logger.info(resourceName + " standbyStatus= " + sm3.getStandbyStatus());
- sm3.demote();
- logger.info("\n\nD5 after sm3.demote()");
- displayState(resourceName, sm3);
- assert(sm3.getStandbyStatus().equals(StateManagement.COLD_STANDBY));
-
- // D2 If demote() is called while standbyStatus is null and adminState is unlocked and opState is enabled,
- // the state shall transition to hotstandby
- logger.info("\n??? demote() test case D2");
- resourceName = "test_resource4";
- StateManagement sm4 = new StateManagement(emf, resourceName);
- sm4.unlock();
- sm4.enableNotFailed();
- logger.info("\n\nD2 after sm4.unlock() and sm4.enableNotFailed()");
- displayState(resourceName, sm4);
- logger.info("{} adminState = {}", resourceName, sm4.getAdminState());
- logger.info("{} opState = {}", resourceName, sm4.getOpState());
- logger.info("{} standbyStatus= {}", resourceName, sm4.getStandbyStatus());
- sm4.demote();
- assert(sm4.getStandbyStatus().equals(StateManagement.HOT_STANDBY));
-
- // P1 If promote() is called while standbyStatus is hotstandby, the state shall transition to providingservice.
- logger.info("\n??? promote() test case P1");
- logger.info(resourceName + " standbyStatus= " + sm4.getStandbyStatus());
- sm4.promote();
- logger.info("\n\nP1 after sm4.promote()");
- displayState(resourceName, sm4);
- assert(sm4.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE));
-
- // State change notification
- logger.info("\n??? State change notification test case 1 - lock()");
- StateChangeNotifier stateChangeNotifier = new StateChangeNotifier();
- sm.addObserver(stateChangeNotifier);
- sm.lock();
-
- logger.info("\n??? State change notification test case 2 - unlock()");
- sm.unlock();
-
- logger.info("\n??? State change notification test case 3 - enabled()");
- sm.enableNotFailed();
-
- logger.info("\n??? State change notification test case 4 - disableFailed()");
- sm.disableFailed();
-
- logger.info("\n??? State change notification test case 5 - demote()");
- sm.demote();
-
- logger.info("\n??? State change notification test case 6 - promote()");
- try {
- sm.promote();
- } catch(Exception ex) {
- logger.info("Exception from promote(): {}", ex.toString());
- }
-
- if (emf.isOpen()) {
- emf.close();
- }
- } catch(Exception ex) {
- logger.error("Exception: {}", ex.toString());
- } finally {
- if (emf.isOpen()) {
- emf.close();
- }
- }
-
- logger.info("\n\nStateManagementTest: Exit\n\n");
- }
-
- private void displayState(String resourceName, StateManagement sm)
- {
- logger.info("{} adminState = {}", resourceName, sm.getAdminState());
- logger.info("{} opState = {}", resourceName, sm.getOpState());
- logger.info("{} availStatus = {}", resourceName, sm.getAvailStatus());
- logger.info("{} standbyStatus= {}", resourceName, sm.getStandbyStatus());
- }
-}
-