summaryrefslogtreecommitdiffstats
path: root/feature-active-standby-management/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'feature-active-standby-management/src/test')
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/ActiveStandbyPropertiesTest.java53
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java379
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java169
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/FactoryTest.java65
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifierTest.java284
-rw-r--r--feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java1378
-rw-r--r--feature-active-standby-management/src/test/resources/META-INF/persistence.xml48
-rw-r--r--feature-active-standby-management/src/test/resources/asw/feature-active-standby-management.properties40
-rw-r--r--feature-active-standby-management/src/test/resources/asw/feature-state-management.properties82
-rw-r--r--feature-active-standby-management/src/test/resources/feature-active-standby-management.properties39
-rw-r--r--feature-active-standby-management/src/test/resources/feature-state-management.properties83
-rw-r--r--feature-active-standby-management/src/test/resources/logback-test.xml49
12 files changed, 0 insertions, 2669 deletions
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/ActiveStandbyPropertiesTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/ActiveStandbyPropertiesTest.java
deleted file mode 100644
index 058aa5e8..00000000
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/ActiveStandbyPropertiesTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2019 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.drools.activestandby;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
-import java.util.Properties;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ActiveStandbyPropertiesTest {
-
- private Properties props;
-
- /**
- * Initializes objects.
- */
- @Before
- public void setUp() {
- props = new Properties();
- props.setProperty("abc", "hello");
- props.setProperty("def", "world");
- }
-
- @Test
- public void testInitProperties_testGetProperty_testGetProperties() {
- ActiveStandbyProperties.initProperties(props);
-
- assertSame(props, ActiveStandbyProperties.getProperties());
-
- assertEquals("hello", ActiveStandbyProperties.getProperty("abc"));
- assertEquals("world", ActiveStandbyProperties.getProperty("def"));
- }
-}
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
deleted file mode 100644
index 311f2954..00000000
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/AllSeemsWellTest.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * feature-active-standby-management
- * ================================================================================
- * Copyright (C) 2017-2019, 2021 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.drools.activestandby;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Properties;
-import java.util.concurrent.Callable;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Persistence;
-import org.apache.commons.lang3.time.DateUtils;
-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.IntegrityMonitorException;
-import org.onap.policy.common.im.MonitorTime;
-import org.onap.policy.common.im.StateManagement;
-import org.onap.policy.common.utils.time.CurrentTime;
-import org.onap.policy.common.utils.time.PseudoTimer;
-import org.onap.policy.common.utils.time.TestTimeMulti;
-import org.onap.policy.drools.core.PolicySessionFeatureApi;
-import org.onap.policy.drools.statemanagement.StateManagementFeatureApi;
-import org.onap.policy.drools.statemanagement.StateManagementFeatureApiConstants;
-import org.powermock.reflect.Whitebox;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/*
- * Testing the allSeemsWell interface to verify that it correctly affects the
- * operational state.
- */
-
-public class AllSeemsWellTest {
- private static final Logger logger = LoggerFactory.getLogger(AllSeemsWellTest.class);
-
- private static final String MONITOR_FIELD_NAME = "instance";
- private static final String HANDLER_INSTANCE_FIELD = "electionHandler";
-
- /*
- * Currently, the DroolsPdpsElectionHandler.DesignationWaiter is invoked every 1 seconds, starting
- * at the start of the next multiple of pdpUpdateInterval, but with a minimum of 5 sec cushion
- * to ensure that we wait for the DesignationWaiter to do its job, before
- * checking the results. Add a few seconds for safety
- */
-
- private static final int SLEEP_TIME_SEC = 10;
-
- /*
- * DroolsPdpsElectionHandler runs every 1 seconds, so it takes 10 seconds for the
- * checkWaitTimer() method to time out and call allSeemsWell which then requires
- * the forward progress counter to go stale which should add an additional 5 sec.
- */
-
- private static final int STALLED_ELECTION_HANDLER_SLEEP_TIME_SEC = 15;
-
- /*
- * As soon as the election hander successfully runs, it will resume the forward progress.
- * If the election handler runs ever 1 sec and test transaction is run every 1 sec and
- * then fpc is written every 1 sec and then the fpc is checked every 2 sec, that could
- * take a total of 5 sec to recognize the resumption of progress. So, add 1 for safety.
- */
- private static final int RESUMED_ELECTION_HANDLER_SLEEP_TIME_SEC = 6;
-
- private static EntityManagerFactory emfx;
- private static EntityManagerFactory emfd;
- private static EntityManager emx;
- private static EntityManager emd;
- private static EntityTransaction et;
-
- private static final String CONFIG_DIR = "src/test/resources/asw";
-
- private static CurrentTime saveTime;
- private static Factory saveFactory;
-
- private TestTimeMulti testTime;
-
- /*
- * See the IntegrityMonitor.getJmxUrl() method for the rationale behind this jmx related processing.
- */
-
- /**
- * Setup the class.
- *
- * @throws Exception exception
- */
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- String userDir = System.getProperty("user.dir");
- logger.debug("setUpClass: userDir={}", userDir);
- System.setProperty("com.sun.management.jmxremote.port", "9980");
- System.setProperty("com.sun.management.jmxremote.authenticate", "false");
-
- DroolsPdpsElectionHandler.setUnitTesting(true);
-
- saveTime = Whitebox.getInternalState(MonitorTime.class, MONITOR_FIELD_NAME);
- saveFactory = Factory.getInstance();
-
- resetInstanceObjects();
-
- //Create the data access for xacml db
- Properties stateManagementProperties = loadStateManagementProperties();
-
- emfx = Persistence.createEntityManagerFactory("junitXacmlPU", stateManagementProperties);
-
- // Create an entity manager to use the DB
- emx = emfx.createEntityManager();
-
- //Create the data access for drools db
- Properties activeStandbyProperties = loadActiveStandbyProperties();
-
- emfd = Persistence.createEntityManagerFactory("junitDroolsPU", activeStandbyProperties);
-
- // Create an entity manager to use the DB
- emd = emfd.createEntityManager();
- }
-
- /**
- * Restores the system state.
- *
- * @throws IntegrityMonitorException if the integrity monitor cannot be shut down
- */
- @AfterClass
- public static void tearDownClass() throws IntegrityMonitorException {
- resetInstanceObjects();
-
- Whitebox.setInternalState(MonitorTime.class, MONITOR_FIELD_NAME, saveTime);
- Factory.setInstance(saveFactory);
-
- DroolsPdpsElectionHandler.setUnitTesting(false);
-
- emd.close();
- emfd.close();
-
- emx.close();
- emfx.close();
- }
-
- /**
- * Setup.
- *
- * @throws Exception exception
- */
- @Before
- public void setUp() throws Exception {
- resetInstanceObjects();
-
- // set test time
- testTime = new TestTimeMulti();
- Whitebox.setInternalState(MonitorTime.class, MONITOR_FIELD_NAME, testTime);
-
- Factory factory = mock(Factory.class);
- when(factory.makeTimer()).thenAnswer(ans -> new PseudoTimer(testTime));
- Factory.setInstance(factory);
- }
-
- private static void resetInstanceObjects() throws IntegrityMonitorException {
- IntegrityMonitor.setUnitTesting(true);
- IntegrityMonitor.deleteInstance();
- IntegrityMonitor.setUnitTesting(false);
-
- Whitebox.setInternalState(ActiveStandbyFeature.class, HANDLER_INSTANCE_FIELD, (Object) null);
-
- }
-
- /**
- * Clean the xacml database.
- */
- public void cleanXacmlDb() {
- et = emx.getTransaction();
-
- et.begin();
- // Make sure we leave the DB clean
- emx.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- emx.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- emx.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
- emx.flush();
- et.commit();
- }
-
- /**
- * Clean the drools database.
- */
- public void cleanDroolsDb() {
- et = emd.getTransaction();
-
- et.begin();
- // Make sure we leave the DB clean
- emd.createQuery("DELETE FROM DroolsPdpEntity").executeUpdate();
- emd.flush();
- et.commit();
- }
-
-
- // Tests hot standby when there is only one PDP.
-
- //@Ignore
- @Test
- public void testAllSeemsWell() throws Exception {
-
- logger.debug("\n\ntestAllSeemsWell: Entering\n\n");
- cleanXacmlDb();
- cleanDroolsDb();
-
- Properties stateManagementProperties = loadStateManagementProperties();
-
- logger.debug("testAllSeemsWell: Creating emfXacml");
- final EntityManagerFactory emfXacml = Persistence.createEntityManagerFactory(
- "junitXacmlPU", stateManagementProperties);
-
- Properties activeStandbyProperties = loadActiveStandbyProperties();
- final String thisPdpId = activeStandbyProperties
- .getProperty(ActiveStandbyProperties.NODE_NAME);
-
- logger.debug("testAllSeemsWell: Creating emfDrools");
- EntityManagerFactory emfDrools = Persistence.createEntityManagerFactory(
- "junitDroolsPU", activeStandbyProperties);
-
- DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfDrools);
-
- logger.debug("testAllSeemsWell: Cleaning up tables");
- conn.deleteAllPdps();
-
- /*
- * Insert this PDP as not designated. Initial standby state will be
- * either null or cold standby. Demoting should transit state to
- * hot standby.
- */
-
- logger.debug("testAllSeemsWell: Inserting PDP={} as not designated", thisPdpId);
- Date yesterday = DateUtils.addDays(testTime.getDate(), -1);
- DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, false, 4, yesterday);
- conn.insertPdp(pdp);
- DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
- logger.debug("testAllSeemsWell: After insertion, PDP={} has DESIGNATED={}",
- thisPdpId, droolsPdpEntity.isDesignated());
- assertFalse(droolsPdpEntity.isDesignated());
-
- logger.debug("testAllSeemsWell: Instantiating stateManagement object");
- StateManagement sm = new StateManagement(emfXacml, "dummy");
- sm.deleteAllStateManagementEntities();
-
-
- // Now we want to create a StateManagementFeature and initialize it. It will be
- // discovered by the ActiveStandbyFeature when the election handler initializes.
-
- StateManagementFeatureApi stateManagementFeatureApi = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- stateManagementFeatureApi = feature;
- logger.debug("testAllSeemsWell stateManagementFeature.getResourceName(): {}",
- stateManagementFeatureApi.getResourceName());
- break;
- }
- assertNotNull(stateManagementFeatureApi);
-
- final StateManagementFeatureApi smf = stateManagementFeatureApi;
-
- // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
- // that has been created.
- ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- activeStandbyFeature = feature;
- logger.debug("testAllSeemsWell activeStandbyFeature.getResourceName(): {}",
- activeStandbyFeature.getResourceName());
- break;
- }
- assertNotNull(activeStandbyFeature);
-
-
- logger.debug("testAllSeemsWell: Demoting PDP={}", thisPdpId);
- // demoting should cause state to transit to hotstandby
- smf.demote();
-
-
- logger.debug("testAllSeemsWell: Sleeping {} s, to allow JpaDroolsPdpsConnector "
- + "time to check droolspdpentity table", SLEEP_TIME_SEC);
- waitForCondition(() -> conn.getPdp(thisPdpId).isDesignated(), SLEEP_TIME_SEC);
-
- // Verify that this formerly un-designated PDP in HOT_STANDBY is now designated and providing service.
-
- droolsPdpEntity = conn.getPdp(thisPdpId);
- logger.debug("testAllSeemsWell: After sm.demote() invoked, DESIGNATED= {} "
- + "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId);
- assertTrue(droolsPdpEntity.isDesignated());
- String standbyStatus = smf.getStandbyStatus(thisPdpId);
- logger.debug("testAllSeemsWell: After demotion, PDP= {} "
- + "has standbyStatus= {}", thisPdpId, standbyStatus);
- assertTrue(standbyStatus != null && standbyStatus.equals(StateManagement.PROVIDING_SERVICE));
-
- //Now we want to stall the election handler and see the if AllSeemsWell will make the
- //standbystatus = coldstandby
-
- DroolsPdpsElectionHandler.setStalled(true);
-
- logger.debug("testAllSeemsWell: Sleeping {} s, to allow checkWaitTimer to recognize "
- + "the election handler has stalled and for the testTransaction to fail to "
- + "increment forward progress and for the lack of forward progress to be recognized.",
- STALLED_ELECTION_HANDLER_SLEEP_TIME_SEC);
-
-
- //It takes 10x the update interval (1 sec) before the watcher will declare the election handler dead
- //and that just stops forward progress counter. So, the fp monitor must then run to determine
- // if the fpc has stalled. That will take about another 5 sec.
- waitForCondition(() -> smf.getStandbyStatus().equals(StateManagement.COLD_STANDBY),
- STALLED_ELECTION_HANDLER_SLEEP_TIME_SEC);
-
- logger.debug("testAllSeemsWell: After isStalled=true, PDP= {} "
- + "has standbyStatus= {}", thisPdpId, smf.getStandbyStatus(thisPdpId));
- assertEquals(StateManagement.COLD_STANDBY, smf.getStandbyStatus());
-
- //Now lets resume the election handler
- DroolsPdpsElectionHandler.setStalled(false);
-
- waitForCondition(() -> smf.getStandbyStatus().equals(StateManagement.PROVIDING_SERVICE),
- RESUMED_ELECTION_HANDLER_SLEEP_TIME_SEC);
-
- logger.debug("testAllSeemsWell: After isStalled=false, PDP= {} "
- + "has standbyStatus= {}", thisPdpId, smf.getStandbyStatus(thisPdpId));
-
- assertEquals(StateManagement.PROVIDING_SERVICE, smf.getStandbyStatus());
-
- //resumedElectionHandlerSleepTime = 5000;
- logger.debug("\n\ntestAllSeemsWell: Exiting\n\n");
-
- }
-
- private static Properties loadStateManagementProperties() throws IOException {
- try (FileInputStream input = new FileInputStream(CONFIG_DIR + "/feature-state-management.properties")) {
- Properties props = new Properties();
- props.load(input);
- return props;
- }
- }
-
- private static Properties loadActiveStandbyProperties() throws IOException {
- try (FileInputStream input =
- new FileInputStream(CONFIG_DIR + "/feature-active-standby-management.properties")) {
- Properties props = new Properties();
- props.load(input);
- return props;
- }
- }
-
- private void waitForCondition(Callable<Boolean> testCondition, int timeoutInSeconds) throws InterruptedException {
- testTime.waitUntil(testCondition);
- }
-}
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
deleted file mode 100644
index 78902ec7..00000000
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/DroolsPdpObjectTest.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2019 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.drools.activestandby;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
-import java.util.Date;
-import lombok.Getter;
-import lombok.Setter;
-import org.junit.Before;
-import org.junit.Test;
-
-public class DroolsPdpObjectTest {
- private static final String PDP_ID = "my-id";
- private static final String PDP_ID2 = "my-id2";
- private static final String SITE = "my-site";
- private static final String SITE2 = "my-site2";
- private static final int PRIORITY = 11;
- private static final int PRIORITY2 = 12;
-
- private MyPdp pdp;
-
- @Before
- public void setUp() {
- pdp = makePdp(PDP_ID, SITE, PRIORITY);
- }
-
- @Test
- public void testEqualsObject() {
- // self
- assertEquals(pdp, pdp);
-
- // same id
- MyPdp pdp2 = new MyPdp();
- pdp2.setPdpId(PDP_ID);
- assertEquals(pdp, pdp2);
-
- // different id
- pdp2.setPdpId(PDP_ID2);
- assertNotEquals(pdp, pdp2);
-
- // different type of object
- assertNotEquals(pdp, "");
- }
-
- @Test
- public void testHashCode() {
- int hc = pdp.hashCode();
-
- // same data should yield same hash code
- assertEquals(hc, pdp.hashCode());
- assertEquals(hc, makePdp(PDP_ID, SITE, PRIORITY).hashCode());
-
- // different data should yield different hash code
- assertNotEquals(hc, makePdp(PDP_ID2, SITE, PRIORITY).hashCode());
-
- // these fields have no impact on hash code
- assertEquals(hc, makePdp(PDP_ID, SITE, PRIORITY2).hashCode());
- assertEquals(hc, makePdp(PDP_ID, SITE2, PRIORITY).hashCode());
-
- // should not throw an exception
- new MyPdp().hashCode();
- }
-
- @Test
- public void testNullSafeCompare() {
- // self, when null
- pdp.setSite(null);
- assertEquals(0, pdp.comparePriority(pdp));
-
- // both null
- MyPdp pdp2 = makePdp(PDP_ID, null, PRIORITY);
- assertEquals(0, pdp.comparePriority(pdp2));
-
- // left null
- pdp2 = makePdp(PDP_ID, SITE, PRIORITY);
- assertEquals(-1, pdp.comparePriority(pdp2));
-
- // right null - note: args are reversed
- pdp2 = makePdp(PDP_ID, SITE, PRIORITY);
- assertEquals(1, pdp2.comparePriority(pdp));
- }
-
- @Test
- public void testComparePriorityDroolsPdp() {
- // self
- assertEquals(0, pdp.comparePriority(pdp));
-
- // same
- MyPdp pdp2 = makePdp(PDP_ID, SITE, PRIORITY);
- assertEquals(0, pdp.comparePriority(pdp2));
-
- // different site
- pdp2 = makePdp(PDP_ID, SITE2, PRIORITY);
- assertEquals(SITE.compareTo(SITE2), pdp.comparePriority(pdp2));
-
- // different priority
- pdp2 = makePdp(PDP_ID, SITE, PRIORITY2);
- assertEquals(PRIORITY - PRIORITY2, pdp.comparePriority(pdp2));
-
- // different id
- pdp2 = makePdp(PDP_ID2, SITE, PRIORITY);
- assertEquals(PDP_ID.compareTo(PDP_ID2), pdp.comparePriority(pdp2));
- }
-
- @Test
- public void testComparePriorityDroolsPdpString() {
- final int result = 1000;
-
- // override other comparison method so we know if it's called
- MyPdp pdp2 = new MyPdp() {
- @Override
- public int comparePriority(DroolsPdp other) {
- return result;
- }
- };
-
- pdp2.setPdpId(PDP_ID);
- pdp2.setSite(SITE2);
- pdp2.setPriority(PRIORITY);
-
- // should use overridden comparison method
- assertEquals(result, pdp2.comparePriority(pdp, null));
- assertEquals(result, pdp2.comparePriority(pdp, ""));
-
- // should use normal comparison method
- assertEquals(SITE2.compareTo(SITE), pdp2.comparePriority(pdp, SITE));
- }
-
- private MyPdp makePdp(String id, String site, int priority) {
- MyPdp pdp2 = new MyPdp();
-
- pdp2.setSite(site);
- pdp2.setPdpId(id);
- pdp2.setPriority(priority);
-
- return pdp2;
- }
-
- @Getter
- @Setter
- private class MyPdp extends DroolsPdpObject {
- private String pdpId;
- private boolean designated;
- private int priority;
- private Date updatedDate;
- private String site;
- private Date designatedDate;
- }
-}
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/FactoryTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/FactoryTest.java
deleted file mode 100644
index 8a166954..00000000
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/FactoryTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2019 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.drools.activestandby;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class FactoryTest {
- private static Factory saveFactory;
-
- private Factory factory;
-
- @BeforeClass
- public static void setUpBeforeClass() {
- saveFactory = Factory.getInstance();
- assertNotNull(saveFactory);
- }
-
- @AfterClass
- public static void tearDownAfterClass() {
- Factory.setInstance(saveFactory);
- }
-
- @Before
- public void setUp() {
- factory = new Factory();
- }
-
- @Test
- public void testMakeTimer() {
- assertNotNull(factory.makeTimer());
- }
-
- @Test
- public void testGetInstance_testSetInstance() {
- Factory.setInstance(factory);
- assertSame(factory, Factory.getInstance());
-
- // repeat - should be the same
- assertSame(factory, Factory.getInstance());
- }
-}
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifierTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifierTest.java
deleted file mode 100644
index a6dba1a6..00000000
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/PmStandbyStateChangeNotifierTest.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2019-2021 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.drools.activestandby;
-
-import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.Properties;
-import java.util.Timer;
-import java.util.TimerTask;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.policy.common.im.StateManagement;
-import org.onap.policy.drools.system.PolicyEngine;
-
-@RunWith(MockitoJUnitRunner.class)
-public class PmStandbyStateChangeNotifierTest {
- private static final String UNSUPPORTED_STATUS = "unsupported status";
- private static final String PDP_ID = "my-pdp";
- private static final long UPDATE_INTERVAL = 100;
- private static final long WAIT_INTERVAL = 2 * UPDATE_INTERVAL + 2000;
-
- private static Factory saveFactory;
-
- @Mock
- private Factory factory;
-
- @Mock
- private PolicyEngine engmgr;
-
- @Mock
- private Timer timer;
-
- @Mock
- private StateManagement mgmt;
-
- private PmStandbyStateChangeNotifier notifier;
-
- /**
- * Initializes the properties.
- */
- @BeforeClass
- public static void setUpBeforeClass() {
- Properties props = new Properties();
- props.setProperty(ActiveStandbyProperties.NODE_NAME, PDP_ID);
- props.setProperty(ActiveStandbyProperties.PDP_UPDATE_INTERVAL, String.valueOf(UPDATE_INTERVAL));
-
- ActiveStandbyProperties.initProperties(props);
-
- saveFactory = Factory.getInstance();
- }
-
- @AfterClass
- public static void tearDownAfterClass() {
- Factory.setInstance(saveFactory);
- }
-
- /**
- * Initializes objects, including the notifier.
- */
- @Before
- public void setUp() {
- Factory.setInstance(factory);
- when(factory.makeTimer()).thenReturn(timer);
-
- notifier = new MyNotifier();
- }
-
- @Test
- public void testHandleStateChange_Null() {
- notifier.update(mgmt, null);
- verify(engmgr).deactivate();
- assertEquals(StateManagement.NULL_VALUE, notifier.getPreviousStandbyStatus());
-
- // repeat - nothing else should be done
- when(mgmt.getStandbyStatus()).thenReturn(StateManagement.NULL_VALUE);
- notifier.update(mgmt, null);
- verify(engmgr, times(1)).deactivate();
- assertEquals(StateManagement.NULL_VALUE, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testHandleStateChange_Null_Ex() {
- doThrow(new MyException()).when(engmgr).deactivate();
-
- // should not throw an exception
- notifier.update(mgmt, null);
- assertEquals(PmStandbyStateChangeNotifier.NONE, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testHandleStateChange_HotOrCold() {
- when(mgmt.getStandbyStatus()).thenReturn(StateManagement.HOT_STANDBY);
- notifier.update(mgmt, null);
- verify(engmgr).deactivate();
- assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY, notifier.getPreviousStandbyStatus());
-
- // repeat - nothing else should be done
- when(mgmt.getStandbyStatus()).thenReturn(StateManagement.COLD_STANDBY);
- notifier.update(mgmt, null);
- verify(engmgr, times(1)).deactivate();
- assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testHandleStateChange_HotOrCold_Ex() {
- doThrow(new MyException()).when(engmgr).deactivate();
-
- // should not throw an exception
- when(mgmt.getStandbyStatus()).thenReturn(StateManagement.HOT_STANDBY);
- notifier.update(mgmt, null);
- assertEquals(PmStandbyStateChangeNotifier.NONE, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testHandleStateChange_ProvidingService() {
- when(mgmt.getStandbyStatus()).thenReturn(StateManagement.PROVIDING_SERVICE);
- notifier.update(mgmt, null);
- verify(engmgr, never()).activate();
- assertEquals(PmStandbyStateChangeNotifier.NONE, notifier.getPreviousStandbyStatus());
-
- ArgumentCaptor<TimerTask> captor = ArgumentCaptor.forClass(TimerTask.class);
- verify(timer).schedule(captor.capture(), eq(WAIT_INTERVAL));
-
- // execute the timer task
- captor.getValue().run();
-
- verify(engmgr).activate();
- assertEquals(StateManagement.PROVIDING_SERVICE, notifier.getPreviousStandbyStatus());
-
- // repeat - nothing else should be done
- notifier.update(mgmt, null);
- verify(engmgr, never()).deactivate();
- verify(engmgr, times(1)).activate();
- verify(timer, times(1)).schedule(captor.capture(), eq(WAIT_INTERVAL));
- assertEquals(StateManagement.PROVIDING_SERVICE, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testHandleStateChange_ProvidingService_BeforeActivation() {
- when(mgmt.getStandbyStatus()).thenReturn(StateManagement.PROVIDING_SERVICE);
- notifier.update(mgmt, null);
-
- // repeat - nothing else should be done
- notifier.update(mgmt, null);
- verify(engmgr, never()).deactivate();
- verify(engmgr, never()).activate();
-
- verify(timer, times(1)).schedule(any(), eq(WAIT_INTERVAL));
- assertEquals(PmStandbyStateChangeNotifier.NONE, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testHandleStateChange_ProvidingService_Ex() {
- when(factory.makeTimer()).thenThrow(new MyException());
-
- when(mgmt.getStandbyStatus()).thenReturn(StateManagement.PROVIDING_SERVICE);
- notifier.update(mgmt, null);
-
- assertEquals(PmStandbyStateChangeNotifier.NONE, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testHandleStateChange_Unsupported() {
- when(mgmt.getStandbyStatus()).thenReturn(UNSUPPORTED_STATUS);
- notifier.update(mgmt, null);
-
- verify(engmgr).deactivate();
- assertEquals(PmStandbyStateChangeNotifier.UNSUPPORTED, notifier.getPreviousStandbyStatus());
-
- // repeat - nothing else should be done
- notifier.update(mgmt, null);
- verify(engmgr, times(1)).deactivate();
- assertEquals(PmStandbyStateChangeNotifier.UNSUPPORTED, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testHandleStateChange_Unsupported_Ex() {
- doThrow(new MyException()).when(engmgr).deactivate();
-
- // should not throw an exception
- when(mgmt.getStandbyStatus()).thenReturn(UNSUPPORTED_STATUS);
- notifier.update(mgmt, null);
- assertEquals(PmStandbyStateChangeNotifier.NONE, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testCancelTimer() {
- when(mgmt.getStandbyStatus()).thenReturn(StateManagement.PROVIDING_SERVICE);
- notifier.update(mgmt, null);
-
- when(mgmt.getStandbyStatus()).thenReturn(null);
- notifier.update(mgmt, null);
-
- verify(timer).cancel();
- }
-
- @Test
- public void testDelayActivateClass() {
- when(mgmt.getStandbyStatus()).thenReturn(StateManagement.PROVIDING_SERVICE);
- notifier.update(mgmt, null);
- verify(engmgr, never()).activate();
- assertEquals(PmStandbyStateChangeNotifier.NONE, notifier.getPreviousStandbyStatus());
-
- ArgumentCaptor<TimerTask> captor = ArgumentCaptor.forClass(TimerTask.class);
- verify(timer).schedule(captor.capture(), eq(WAIT_INTERVAL));
-
- // execute the timer task
- captor.getValue().run();
-
- verify(engmgr).activate();
- assertEquals(StateManagement.PROVIDING_SERVICE, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testDelayActivateClass_Ex() {
- when(mgmt.getStandbyStatus()).thenReturn(StateManagement.PROVIDING_SERVICE);
- notifier.update(mgmt, null);
- verify(engmgr, never()).activate();
- assertEquals(PmStandbyStateChangeNotifier.NONE, notifier.getPreviousStandbyStatus());
-
- ArgumentCaptor<TimerTask> captor = ArgumentCaptor.forClass(TimerTask.class);
- verify(timer).schedule(captor.capture(), eq(WAIT_INTERVAL));
-
- doThrow(new MyException()).when(engmgr).activate();
-
- // execute the timer task
- captor.getValue().run();
-
- assertEquals(PmStandbyStateChangeNotifier.NONE, notifier.getPreviousStandbyStatus());
- }
-
- @Test
- public void testGetPolicyEngineManager() {
- // use real object with real method - no exception expected
- assertThatCode(() -> new PmStandbyStateChangeNotifier().getPolicyEngineManager()).doesNotThrowAnyException();
- }
-
- private class MyNotifier extends PmStandbyStateChangeNotifier {
- @Override
- protected PolicyEngine getPolicyEngineManager() {
- return engmgr;
- }
- }
-
- private static class MyException extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- public MyException() {
- super("expected exception");
- }
- }
-}
diff --git a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java b/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
deleted file mode 100644
index 52f8b27a..00000000
--- a/feature-active-standby-management/src/test/java/org/onap/policy/drools/activestandby/StandbyStateManagementTest.java
+++ /dev/null
@@ -1,1378 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * feature-active-standby-management
- * ================================================================================
- * Copyright (C) 2017-2019 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.drools.activestandby;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-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 org.apache.commons.lang3.time.DateUtils;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.im.AdministrativeStateException;
-import org.onap.policy.common.im.IntegrityMonitor;
-import org.onap.policy.common.im.IntegrityMonitorException;
-import org.onap.policy.common.im.MonitorTime;
-import org.onap.policy.common.im.StandbyStatusException;
-import org.onap.policy.common.im.StateManagement;
-import org.onap.policy.common.utils.time.CurrentTime;
-import org.onap.policy.common.utils.time.PseudoTimer;
-import org.onap.policy.common.utils.time.TestTimeMulti;
-import org.onap.policy.drools.core.PolicySessionFeatureApi;
-import org.onap.policy.drools.statemanagement.StateManagementFeatureApi;
-import org.onap.policy.drools.statemanagement.StateManagementFeatureApiConstants;
-import org.powermock.reflect.Whitebox;
-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 StandbyStateManagementTest {
- private static final Logger logger = LoggerFactory.getLogger(StandbyStateManagementTest.class);
-
- private static final String MONITOR_FIELD_NAME = "instance";
- private static final String HANDLER_INSTANCE_FIELD = "electionHandler";
-
- /*
- * Currently, the DroolsPdpsElectionHandler.DesignationWaiter is invoked every 1 seconds, starting
- * at the start of the next multiple of pdpUpdateInterval, but with a minimum of 5 sec cushion
- * to ensure that we wait for the DesignationWaiter to do its job, before
- * checking the results. Add a few seconds for safety
- */
-
- private static final long SLEEP_TIME = 10000;
-
- /*
- * DroolsPdpsElectionHandler runs every 1 seconds, so a 6 second sleep should be
- * plenty to ensure it has time to re-promote this PDP.
- */
-
- private static final long ELECTION_WAIT_SLEEP_TIME = 6000;
-
- /*
- * Sleep a few seconds after each test to allow interrupt (shutdown) recovery.
- */
-
- private static final long INTERRUPT_RECOVERY_TIME = 5000;
-
- private static EntityManagerFactory emfx;
- private static EntityManagerFactory emfd;
- private static EntityManager emx;
- private static EntityManager emd;
- private static EntityTransaction et;
-
- private static final String CONFIG_DIR = "src/test/resources";
-
- private static CurrentTime saveTime;
- private static Factory saveFactory;
-
- private TestTimeMulti testTime;
-
- /*
- * This cannot be shared by tests, as each integrity monitor may manipulate it by
- * adding its own property values.
- */
- private Properties activeStandbyProperties;
-
- /*
- * See the IntegrityMonitor.getJmxUrl() method for the rationale behind this jmx related processing.
- */
-
- /**
- * Setup the class.
- *
- * @throws Exception exception
- */
- @BeforeClass
- public static void setUpClass() throws Exception {
-
- String userDir = System.getProperty("user.dir");
- logger.debug("setUpClass: userDir={}", userDir);
- System.setProperty("com.sun.management.jmxremote.port", "9980");
- System.setProperty("com.sun.management.jmxremote.authenticate", "false");
-
- saveTime = Whitebox.getInternalState(MonitorTime.class, MONITOR_FIELD_NAME);
- saveFactory = Factory.getInstance();
-
- resetInstanceObjects();
-
- //Create the data access for xacml db
- Properties smProps = loadStateManagementProperties();
-
- emfx = Persistence.createEntityManagerFactory("junitXacmlPU", smProps);
-
- // Create an entity manager to use the DB
- emx = emfx.createEntityManager();
-
- //Create the data access for drools db
- Properties asbProps = loadActiveStandbyProperties();
-
- emfd = Persistence.createEntityManagerFactory("junitDroolsPU", asbProps);
-
- // Create an entity manager to use the DB
- emd = emfd.createEntityManager();
- }
-
- /**
- * Restores the system state.
- *
- * @throws IntegrityMonitorException if the integrity monitor cannot be shut down
- */
- @AfterClass
- public static void tearDownClass() throws IntegrityMonitorException {
- resetInstanceObjects();
-
- Whitebox.setInternalState(MonitorTime.class, MONITOR_FIELD_NAME, saveTime);
- Factory.setInstance(saveFactory);
-
- emd.close();
- emfd.close();
-
- emx.close();
- emfx.close();
- }
-
- /**
- * Setup.
- *
- * @throws Exception exception
- */
- @Before
- public void setUp() throws Exception {
- resetInstanceObjects();
- cleanXacmlDb();
- cleanDroolsDb();
-
- /*
- * set test time
- *
- * All threads use the test time object for sleeping. As a result, we don't have
- * to wait more than an instant for them to complete their work, thus we'll use
- * a very small REAL wait time in the constructor.
- */
- testTime = new TestTimeMulti(5);
- Whitebox.setInternalState(MonitorTime.class, MONITOR_FIELD_NAME, testTime);
-
- Factory factory = mock(Factory.class);
- when(factory.makeTimer()).thenAnswer(ans -> new PseudoTimer(testTime));
- Factory.setInstance(factory);
-
- activeStandbyProperties = loadActiveStandbyProperties();
- }
-
- private static void resetInstanceObjects() throws IntegrityMonitorException {
- IntegrityMonitor.setUnitTesting(true);
- IntegrityMonitor.deleteInstance();
- IntegrityMonitor.setUnitTesting(false);
-
- Whitebox.setInternalState(ActiveStandbyFeature.class, HANDLER_INSTANCE_FIELD, (Object) null);
-
- }
-
- /**
- * Clean up the xacml database.
- *
- */
- public void cleanXacmlDb() {
- et = emx.getTransaction();
-
- et.begin();
- // Make sure we leave the DB clean
- emx.createQuery("DELETE FROM StateManagementEntity").executeUpdate();
- emx.createQuery("DELETE FROM ResourceRegistrationEntity").executeUpdate();
- emx.createQuery("DELETE FROM ForwardProgressEntity").executeUpdate();
- emx.flush();
- et.commit();
- }
-
- /**
- * Clean up the drools db.
- */
- public void cleanDroolsDb() {
- et = emd.getTransaction();
-
- et.begin();
- // Make sure we leave the DB clean
- emd.createQuery("DELETE FROM DroolsPdpEntity").executeUpdate();
- emd.flush();
- et.commit();
- }
-
- /**
- * Test the standby state change notifier.
- *
- * @throws Exception exception
- */
- @Test
- public void testPmStandbyStateChangeNotifier() throws Exception {
- logger.debug("\n\ntestPmStandbyStateChangeNotifier: Entering\n\n");
-
- logger.debug("testPmStandbyStateChangeNotifier: Reading activeStandbyProperties");
-
- String resourceName = "testPMS";
- activeStandbyProperties.setProperty("resource.name", resourceName);
- ActiveStandbyProperties.initProperties(activeStandbyProperties);
-
- logger.debug("testPmStandbyStateChangeNotifier: Getting StateManagement instance");
-
- StateManagement sm = new StateManagement(emfx, resourceName);
-
- //Create an instance of the Observer
- PmStandbyStateChangeNotifier pmNotifier = new PmStandbyStateChangeNotifier();
-
- //Register the PmStandbyStateChangeNotifier Observer
- sm.addObserver(pmNotifier);
-
- //At this point the standbystatus = 'null'
- sm.lock();
- assertEquals(StateManagement.NULL_VALUE, pmNotifier.getPreviousStandbyStatus());
-
- sm.unlock();
- assertEquals(StateManagement.NULL_VALUE, pmNotifier.getPreviousStandbyStatus());
-
- //Adding standbystatus=hotstandby
- sm.demote();
- System.out.println(pmNotifier.getPreviousStandbyStatus());
- assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
- pmNotifier.getPreviousStandbyStatus());
-
- //Now making standbystatus=coldstandby
- sm.lock();
- assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
- pmNotifier.getPreviousStandbyStatus());
-
- //standbystatus = hotstandby
- sm.unlock();
- assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
- pmNotifier.getPreviousStandbyStatus());
-
- //standbystatus = providingservice
- sm.promote();
- //The previousStandbyStatus is not updated until after the delay activation expires
- assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
- pmNotifier.getPreviousStandbyStatus());
-
- //Sleep long enough for the delayActivationTimer to run
- sleep(5000);
- assertEquals(StateManagement.PROVIDING_SERVICE, pmNotifier.getPreviousStandbyStatus());
-
- //standbystatus = providingservice
- sm.promote();
- assertEquals(StateManagement.PROVIDING_SERVICE, pmNotifier.getPreviousStandbyStatus());
-
- //standbystatus = coldstandby
- sm.lock();
- assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
- pmNotifier.getPreviousStandbyStatus());
-
- //standbystatus = hotstandby
- sm.unlock();
- assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
- pmNotifier.getPreviousStandbyStatus());
-
- //standbystatus = hotstandby
- sm.demote();
- assertEquals(PmStandbyStateChangeNotifier.HOTSTANDBY_OR_COLDSTANDBY,
- pmNotifier.getPreviousStandbyStatus());
- }
-
- /**
- * Test sanitize designated list.
- *
- * @throws Exception exception
- */
- @Test
- public void testSanitizeDesignatedList() throws Exception {
-
- logger.debug("\n\ntestSanitizeDesignatedList: Entering\n\n");
-
- // Get a DroolsPdpsConnector
-
- final DroolsPdpsConnector droolsPdpsConnector = new JpaDroolsPdpsConnector(emfd);
-
- // Create 4 pdpd all not designated
-
- DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, testTime.getDate());
- DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, testTime.getDate());
- DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, testTime.getDate());
- DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, testTime.getDate());
-
- List<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
- listOfDesignated.add(pdp1);
- listOfDesignated.add(pdp2);
- listOfDesignated.add(pdp3);
- listOfDesignated.add(pdp4);
-
- // Now we want to create a StateManagementFeature and initialize it. It will be
- // discovered by the ActiveStandbyFeature when the election handler initializes.
-
- StateManagementFeatureApi stateManagementFeature = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- stateManagementFeature = feature;
- logger.debug("testColdStandby stateManagementFeature.getResourceName(): {}",
- stateManagementFeature.getResourceName());
- break;
- }
- assertNotNull(stateManagementFeature);
-
-
- DroolsPdpsElectionHandler droolsPdpsElectionHandler = new DroolsPdpsElectionHandler(droolsPdpsConnector, pdp1);
-
- listOfDesignated = droolsPdpsElectionHandler.santizeDesignatedList(listOfDesignated);
-
- logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size = {}\n\n", listOfDesignated.size());
-
- assertEquals(4, listOfDesignated.size());
-
- // Now make 2 designated
-
- pdp1.setDesignated(true);
- pdp2.setDesignated(true);
-
- listOfDesignated = droolsPdpsElectionHandler.santizeDesignatedList(listOfDesignated);
-
- logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size after 2 designated = {}\n\n",
- listOfDesignated.size());
-
- assertEquals(2, listOfDesignated.size());
- assertTrue(listOfDesignated.contains(pdp1));
- assertTrue(listOfDesignated.contains(pdp2));
-
-
- // Now all are designated. But, we have to add back the previously non-designated nodes
-
- pdp3.setDesignated(true);
- pdp4.setDesignated(true);
- listOfDesignated.add(pdp3);
- listOfDesignated.add(pdp4);
-
- listOfDesignated = droolsPdpsElectionHandler.santizeDesignatedList(listOfDesignated);
-
- logger.debug("\n\ntestSanitizeDesignatedList: listOfDesignated.size after all designated = {}\n\n",
- listOfDesignated.size());
-
- assertEquals(4, listOfDesignated.size());
-
- }
-
- /**
- * Test Compute most recent primary.
- *
- * @throws Exception exception
- */
- @Test
- public void testComputeMostRecentPrimary() throws Exception {
-
- logger.debug("\n\ntestComputeMostRecentPrimary: Entering\n\n");
-
- final DroolsPdpsConnector droolsPdpsConnector = new JpaDroolsPdpsConnector(emfd);
-
-
- // Create 4 pdpd all not designated
-
-
- long designatedDateMs = testTime.getMillis();
- DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, testTime.getDate());
- pdp1.setDesignatedDate(new Date(designatedDateMs - 2));
-
- DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, testTime.getDate());
- //oldest
- pdp2.setDesignatedDate(new Date(designatedDateMs - 3));
-
- DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, testTime.getDate());
- pdp3.setDesignatedDate(new Date(designatedDateMs - 1));
-
- DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, testTime.getDate());
- //most recent
- pdp4.setDesignatedDate(new Date(designatedDateMs));
-
- ArrayList<DroolsPdp> listOfAllPdps = new ArrayList<DroolsPdp>();
- listOfAllPdps.add(pdp1);
- listOfAllPdps.add(pdp2);
- listOfAllPdps.add(pdp3);
- listOfAllPdps.add(pdp4);
-
-
- ArrayList<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
- listOfDesignated.add(pdp1);
- listOfDesignated.add(pdp2);
- listOfDesignated.add(pdp3);
- listOfDesignated.add(pdp4);
-
- // Because the way we sanitize the listOfDesignated, it will always contain all hot standby
- // or all designated members.
-
- // Now we want to create a StateManagementFeature and initialize it. It will be
- // discovered by the ActiveStandbyFeature when the election handler initializes.
-
- StateManagementFeatureApi stateManagementFeature = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- stateManagementFeature = feature;
- logger.debug("testComputeMostRecentPrimary stateManagementFeature.getResourceName(): {}",
- stateManagementFeature.getResourceName());
- break;
- }
- assertNotNull(stateManagementFeature);
-
- DroolsPdpsElectionHandler droolsPdpsElectionHandler = new DroolsPdpsElectionHandler(droolsPdpsConnector, pdp1);
-
- DroolsPdp mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(
- listOfAllPdps, listOfDesignated);
-
- logger.debug("\n\ntestComputeMostRecentPrimary: mostRecentPrimary.getPdpId() = {}\n\n",
- mostRecentPrimary.getPdpId());
-
-
- // If all of the pdps are included in the listOfDesignated and none are designated, it will choose
- // the one which has the most recent designated date.
-
-
- assertEquals("pdp4", mostRecentPrimary.getPdpId());
-
-
- // Now let's designate all of those on the listOfDesignated. It will choose the first one designated
-
-
- pdp1.setDesignated(true);
- pdp2.setDesignated(true);
- pdp3.setDesignated(true);
- pdp4.setDesignated(true);
-
- mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-
- logger.debug("\n\ntestComputeMostRecentPrimary: All designated all on list, "
- + "mostRecentPrimary.getPdpId() = {}\n\n",
- mostRecentPrimary.getPdpId());
-
-
- // If all of the pdps are included in the listOfDesignated and all are designated, it will choose
- // the one which was designated first
-
-
- assertEquals("pdp2", mostRecentPrimary.getPdpId());
-
-
- // Now we will designate only 2 and put just them in the listOfDesignated. The algorithm will now
- // look for the most recently designated pdp which is not currently designated.
-
-
- pdp3.setDesignated(false);
- pdp4.setDesignated(false);
-
- listOfDesignated.remove(pdp3);
- listOfDesignated.remove(pdp4);
-
- mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-
- logger.debug("\n\ntestComputeMostRecentPrimary: mostRecentPrimary.getPdpId() = {}\n\n",
- mostRecentPrimary.getPdpId());
-
- assertEquals("pdp4", mostRecentPrimary.getPdpId());
-
-
-
- // Now we will have none designated and put two of them in the listOfDesignated. The algorithm will now
- // look for the most recently designated pdp regardless of whether it is currently marked as designated.
-
-
- pdp1.setDesignated(false);
- pdp2.setDesignated(false);
-
- mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-
- logger.debug("\n\ntestComputeMostRecentPrimary: 2 on list mostRecentPrimary.getPdpId() = {}\n\n",
- mostRecentPrimary.getPdpId());
-
- assertEquals("pdp4", mostRecentPrimary.getPdpId());
-
-
- // If we have only one pdp on in the listOfDesignated,
- // the most recently designated pdp will be chosen, regardless
- // of its designation status
-
-
- listOfDesignated.remove(pdp1);
-
- mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-
- logger.debug("\n\ntestComputeMostRecentPrimary: 1 on list mostRecentPrimary.getPdpId() = {}\n\n",
- mostRecentPrimary.getPdpId());
-
- assertEquals("pdp4", mostRecentPrimary.getPdpId());
-
-
- // Finally, if none are on the listOfDesignated, it will again choose the most recently designated pdp.
-
-
- listOfDesignated.remove(pdp2);
-
- mostRecentPrimary = droolsPdpsElectionHandler.computeMostRecentPrimary(listOfAllPdps, listOfDesignated);
-
- logger.debug("\n\ntestComputeMostRecentPrimary: 0 on list mostRecentPrimary.getPdpId() = {}\n\n",
- mostRecentPrimary.getPdpId());
-
- assertEquals("pdp4", mostRecentPrimary.getPdpId());
-
- }
-
- /**
- * Test compute designated PDP.
- *
- * @throws Exception exception
- */
- @Test
- public void testComputeDesignatedPdp() throws Exception {
-
- logger.debug("\n\ntestComputeDesignatedPdp: Entering\n\n");
-
- final DroolsPdpsConnector droolsPdpsConnector = new JpaDroolsPdpsConnector(emfd);
-
-
- // Create 4 pdpd all not designated. Two on site1. Two on site2
-
-
- long designatedDateMs = testTime.getMillis();
- DroolsPdp pdp1 = new DroolsPdpImpl("pdp1", false, 4, testTime.getDate());
- pdp1.setDesignatedDate(new Date(designatedDateMs - 2));
- pdp1.setSite("site1");
-
- DroolsPdp pdp2 = new DroolsPdpImpl("pdp2", false, 4, testTime.getDate());
- pdp2.setDesignatedDate(new Date(designatedDateMs - 3));
- pdp2.setSite("site1");
-
- //oldest
- DroolsPdp pdp3 = new DroolsPdpImpl("pdp3", false, 4, testTime.getDate());
- pdp3.setDesignatedDate(new Date(designatedDateMs - 4));
- pdp3.setSite("site2");
-
- DroolsPdp pdp4 = new DroolsPdpImpl("pdp4", false, 4, testTime.getDate());
- //most recent
- pdp4.setDesignatedDate(new Date(designatedDateMs));
- pdp4.setSite("site2");
-
- ArrayList<DroolsPdp> listOfAllPdps = new ArrayList<DroolsPdp>();
- listOfAllPdps.add(pdp1);
- listOfAllPdps.add(pdp2);
- listOfAllPdps.add(pdp3);
- listOfAllPdps.add(pdp4);
-
-
- ArrayList<DroolsPdp> listOfDesignated = new ArrayList<DroolsPdp>();
-
-
- // We will first test an empty listOfDesignated. As we know from the previous JUnit,
- // the pdp with the most designated date will be chosen for mostRecentPrimary
-
- // Now we want to create a StateManagementFeature and initialize it. It will be
- // discovered by the ActiveStandbyFeature when the election handler initializes.
-
- StateManagementFeatureApi stateManagementFeature = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- stateManagementFeature = feature;
- logger.debug("testComputeDesignatedPdp stateManagementFeature.getResourceName(): {}",
- stateManagementFeature.getResourceName());
- break;
- }
- assertNotNull(stateManagementFeature);
-
-
- DroolsPdpsElectionHandler droolsPdpsElectionHandler = new DroolsPdpsElectionHandler(droolsPdpsConnector, pdp1);
-
- DroolsPdp mostRecentPrimary = pdp4;
-
- DroolsPdp designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
-
-
- // The designatedPdp should be null
-
- assertNull(designatedPdp);
-
-
- // Now let's try having only one pdp in listOfDesignated, but not in the same site as the most recent primary
-
- listOfDesignated.add(pdp2);
-
- designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
-
-
- // Now the designatedPdp should be the one and only selection in the listOfDesignated
-
-
- assertEquals(designatedPdp.getPdpId(), pdp2.getPdpId());
-
-
- // Now let's put 2 pdps in the listOfDesignated, neither in the same site as the mostRecentPrimary
-
-
- listOfDesignated.add(pdp1);
-
- designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
-
-
- // The designatedPdp should now be the one with the lowest lexiographic score - pdp1
-
-
- assertEquals(designatedPdp.getPdpId(), pdp1.getPdpId());
-
-
- // Finally, we will have 2 pdps in the listOfDesignated, one in the same site with the mostRecentPrimary
-
-
- listOfDesignated.remove(pdp1);
- listOfDesignated.add(pdp3);
-
- designatedPdp = droolsPdpsElectionHandler.computeDesignatedPdp(listOfDesignated, mostRecentPrimary);
-
-
- // The designatedPdp should now be the one on the same site as the mostRecentPrimary
-
-
- assertEquals(designatedPdp.getPdpId(), pdp3.getPdpId());
- }
-
- /**
- * Test cold standby.
- *
- * @throws Exception exception
- */
- @Test
- public void testColdStandby() throws Exception {
-
- logger.debug("\n\ntestColdStandby: Entering\n\n");
-
- final String thisPdpId = activeStandbyProperties.getProperty(ActiveStandbyProperties.NODE_NAME);
-
- DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfd);
-
- logger.debug("testColdStandby: Inserting PDP={} as designated", thisPdpId);
- DroolsPdp pdp = new DroolsPdpImpl(thisPdpId, true, 4, testTime.getDate());
- conn.insertPdp(pdp);
- DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
- logger.debug("testColdStandby: After insertion, DESIGNATED= {} "
- + "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId);
- assertTrue(droolsPdpEntity.isDesignated());
-
- /*
- * When the Standby Status changes (from providingservice) to hotstandby
- * or coldstandby,the Active/Standby selection algorithm must stand down
- * if thePDP-D is currently the lead/active node and allow another PDP-D
- * to take over.
- *
- * It must also call lock on all engines in the engine management.
- */
-
-
- /*
- * Yes, this is kludgy, but we have a chicken and egg problem here: we
- * need a StateManagement object to invoke the
- * deleteAllStateManagementEntities method.
- */
- logger.debug("testColdStandby: Instantiating stateManagement object");
-
- StateManagement sm = new StateManagement(emfx, "dummy");
- sm.deleteAllStateManagementEntities();
-
- // Now we want to create a StateManagementFeature and initialize it. It will be
- // discovered by the ActiveStandbyFeature when the election handler initializes.
-
- StateManagementFeatureApi smf = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- smf = feature;
- logger.debug("testColdStandby stateManagementFeature.getResourceName(): {}", smf.getResourceName());
- break;
- }
- assertNotNull(smf);
-
- // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
- // that has been created.
- ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- activeStandbyFeature = feature;
- logger.debug("testColdStandby activeStandbyFeature.getResourceName(): {}",
- activeStandbyFeature.getResourceName());
- break;
- }
- assertNotNull(activeStandbyFeature);
-
- // Artificially putting a PDP into service is really a two step process, 1)
- // inserting it as designated and 2) promoting it so that its standbyStatus
- // is providing service.
-
- logger.debug("testColdStandby: Runner started; Sleeping "
- + INTERRUPT_RECOVERY_TIME + "ms before promoting PDP= {}",
- thisPdpId);
- sleep(INTERRUPT_RECOVERY_TIME);
-
- logger.debug("testColdStandby: Promoting PDP={}", thisPdpId);
- smf.promote();
-
- String standbyStatus = sm.getStandbyStatus(thisPdpId);
- logger.debug("testColdStandby: Before locking, PDP= {} has standbyStatus= {}",
- thisPdpId, standbyStatus);
-
- logger.debug("testColdStandby: Locking smf");
- smf.lock();
-
- sleep(INTERRUPT_RECOVERY_TIME);
-
- // Verify that the PDP is no longer designated.
-
- droolsPdpEntity = conn.getPdp(thisPdpId);
- logger.debug("testColdStandby: After lock sm.lock() invoked, "
- + "DESIGNATED= {} for PDP={}", droolsPdpEntity.isDesignated(), thisPdpId);
- assertFalse(droolsPdpEntity.isDesignated());
-
- logger.debug("\n\ntestColdStandby: Exiting\n\n");
- }
-
- // Tests hot standby when there is only one PDP.
-
- /**
- * Test hot standby 1.
- *
- * @throws Exception exception
- */
- @Test
- public void testHotStandby1() throws Exception {
-
- logger.debug("\n\ntestHotStandby1: Entering\n\n");
-
- final String thisPdpId = activeStandbyProperties
- .getProperty(ActiveStandbyProperties.NODE_NAME);
-
- DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfd);
-
- /*
- * Insert this PDP as not designated. Initial standby state will be
- * either null or cold standby. Demoting should transit state to
- * hot standby.
- */
-
- logger.debug("testHotStandby1: Inserting PDP={} as not designated", thisPdpId);
- Date yesterday = DateUtils.addDays(testTime.getDate(), -1);
- DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, false, 4, yesterday);
- conn.insertPdp(pdp);
- DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
- logger.debug("testHotStandby1: After insertion, PDP={} has DESIGNATED={}",
- thisPdpId, droolsPdpEntity.isDesignated());
- assertFalse(droolsPdpEntity.isDesignated());
-
- logger.debug("testHotStandby1: Instantiating stateManagement object");
- StateManagement sm = new StateManagement(emfx, "dummy");
- sm.deleteAllStateManagementEntities();
-
-
- // Now we want to create a StateManagementFeature and initialize it. It will be
- // discovered by the ActiveStandbyFeature when the election handler initializes.
-
- StateManagementFeatureApi smf = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- smf = feature;
- logger.debug("testHotStandby1 stateManagementFeature.getResourceName(): {}", smf.getResourceName());
- break;
- }
- assertNotNull(smf);
-
- // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
- // that has been created.
- ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- activeStandbyFeature = feature;
- logger.debug("testHotStandby1 activeStandbyFeature.getResourceName(): {}",
- activeStandbyFeature.getResourceName());
- break;
- }
- assertNotNull(activeStandbyFeature);
-
-
- logger.debug("testHotStandby1: Demoting PDP={}", thisPdpId);
- // demoting should cause state to transit to hotstandby
- smf.demote();
-
-
- logger.debug("testHotStandby1: Sleeping {} ms, to allow JpaDroolsPdpsConnector "
- + "time to check droolspdpentity table", SLEEP_TIME);
- sleep(SLEEP_TIME);
-
-
- // Verify that this formerly un-designated PDP in HOT_STANDBY is now designated and providing service.
-
- droolsPdpEntity = conn.getPdp(thisPdpId);
- logger.debug("testHotStandby1: After sm.demote() invoked, DESIGNATED= {} "
- + "for PDP= {}", droolsPdpEntity.isDesignated(), thisPdpId);
- assertTrue(droolsPdpEntity.isDesignated());
- String standbyStatus = smf.getStandbyStatus(thisPdpId);
- logger.debug("testHotStandby1: After demotion, PDP= {} "
- + "has standbyStatus= {}", thisPdpId, standbyStatus);
- assertTrue(standbyStatus != null && standbyStatus.equals(StateManagement.PROVIDING_SERVICE));
-
- logger.debug("testHotStandby1: Stopping policyManagementRunner");
-
- logger.debug("\n\ntestHotStandby1: Exiting\n\n");
- }
-
- /*
- * Tests hot standby when two PDPs are involved.
- */
-
- /**
- * Test hot standby 2.
- *
- * @throws Exception exception
- */
- @Test
- public void testHotStandby2() throws Exception {
-
- logger.info("\n\ntestHotStandby2: Entering\n\n");
-
- final String thisPdpId = activeStandbyProperties
- .getProperty(ActiveStandbyProperties.NODE_NAME);
-
- DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfd);
-
-
- // Insert a PDP that's designated but not current.
-
- String activePdpId = "pdp2";
- logger.info("testHotStandby2: Inserting PDP={} as stale, designated PDP", activePdpId);
- Date yesterday = DateUtils.addDays(testTime.getDate(), -1);
- DroolsPdp pdp = new DroolsPdpImpl(activePdpId, true, 4, yesterday);
- conn.insertPdp(pdp);
- DroolsPdpEntity droolsPdpEntity = conn.getPdp(activePdpId);
- logger.info("testHotStandby2: After insertion, PDP= {}, which is "
- + "not current, has DESIGNATED= {}", activePdpId, droolsPdpEntity.isDesignated());
- assertTrue(droolsPdpEntity.isDesignated());
-
- /*
- * Promote the designated PDP.
- *
- * We have a chicken and egg problem here: we need a StateManagement
- * object to invoke the deleteAllStateManagementEntities method.
- */
-
-
- logger.info("testHotStandby2: Promoting PDP={}", activePdpId);
- StateManagement sm = new StateManagement(emfx, "dummy");
- sm.deleteAllStateManagementEntities();
-
-
- sm = new StateManagement(emfx, activePdpId); //pdp2
-
- // Artificially putting a PDP into service is really a two step process, 1)
- // inserting it as designated and 2) promoting it so that its standbyStatus
- // is providing service.
-
- /*
- * Insert this PDP as not designated. Initial standby state will be
- * either null or cold standby. Demoting should transit state to
- * hot standby.
- */
-
-
- logger.info("testHotStandby2: Inserting PDP= {} as not designated", thisPdpId);
- pdp = new DroolsPdpImpl(thisPdpId, false, 4, yesterday);
- conn.insertPdp(pdp);
- droolsPdpEntity = conn.getPdp(thisPdpId);
- logger.info("testHotStandby2: After insertion, PDP={} "
- + "has DESIGNATED= {}", thisPdpId, droolsPdpEntity.isDesignated());
- assertFalse(droolsPdpEntity.isDesignated());
-
-
- // Now we want to create a StateManagementFeature and initialize it. It will be
- // discovered by the ActiveStandbyFeature when the election handler initializes.
-
- StateManagementFeatureApi sm2 = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- sm2 = feature;
- logger.debug("testHotStandby2 stateManagementFeature.getResourceName(): {}", sm2.getResourceName());
- break;
- }
- assertNotNull(sm2);
-
- // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
- // that has been created.
- ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- activeStandbyFeature = feature;
- logger.debug("testHotStandby2 activeStandbyFeature.getResourceName(): {}",
- activeStandbyFeature.getResourceName());
- break;
- }
- assertNotNull(activeStandbyFeature);
-
- logger.info("testHotStandby2: Runner started; Sleeping {} "
- + "ms before promoting/demoting", INTERRUPT_RECOVERY_TIME);
- sleep(INTERRUPT_RECOVERY_TIME);
-
- logger.info("testHotStandby2: Runner started; promoting PDP={}", activePdpId);
- //At this point, the newly created pdp will have set the state to disabled/failed/cold standby
- //because it is stale. So, it cannot be promoted. We need to call sm.enableNotFailed() so we
- //can promote it and demote the other pdp - else the other pdp will just spring back to providingservice
- sm.enableNotFailed(); //pdp2
- sm.promote();
- String standbyStatus = sm.getStandbyStatus(activePdpId);
- logger.info("testHotStandby2: After promoting, PDP= {} has standbyStatus= {}", activePdpId, standbyStatus);
-
- // demoting PDP should ensure that state transits to hotstandby
- logger.info("testHotStandby2: Runner started; demoting PDP= {}", thisPdpId);
- sm2.demote(); //pdp1
- standbyStatus = sm.getStandbyStatus(thisPdpId);
- logger.info("testHotStandby2: After demoting, PDP={} has standbyStatus= {}", thisPdpId, standbyStatus);
-
- logger.info("testHotStandby2: Sleeping {} ms, to allow JpaDroolsPdpsConnector "
- + "time to check droolspdpentity table", SLEEP_TIME);
- sleep(SLEEP_TIME);
-
- /*
- * Verify that this PDP, demoted to HOT_STANDBY, is now
- * re-designated and providing service.
- */
-
- droolsPdpEntity = conn.getPdp(thisPdpId);
- logger.info("testHotStandby2: After demoting PDP={}"
- + ", DESIGNATED= {}"
- + " for PDP= {}", activePdpId, droolsPdpEntity.isDesignated(), thisPdpId);
- assertTrue(droolsPdpEntity.isDesignated());
- standbyStatus = sm2.getStandbyStatus(thisPdpId);
- logger.info("testHotStandby2: After demoting PDP={}"
- + ", PDP={} has standbyStatus= {}",
- activePdpId, thisPdpId, standbyStatus);
- assertTrue(standbyStatus != null
- && standbyStatus.equals(StateManagement.PROVIDING_SERVICE));
-
- logger.info("testHotStandby2: Stopping policyManagementRunner");
-
- logger.info("\n\ntestHotStandby2: Exiting\n\n");
- }
-
- /*
- * 1) Inserts and designates this PDP, then verifies that startTransaction
- * is successful.
- *
- * 2) Demotes PDP, and verifies that because there is only one PDP, it will
- * be immediately re-promoted, thus allowing startTransaction to be
- * successful.
- *
- * 3) Locks PDP and verifies that startTransaction results in
- * AdministrativeStateException.
- *
- * 4) Unlocks PDP and verifies that startTransaction results in
- * StandbyStatusException.
- *
- * 5) Promotes PDP and verifies that startTransaction is once again
- * successful.
- */
-
- /**
- * Test locking.
- *
- * @throws Exception exception
- */
- @Test
- public void testLocking1() throws Exception {
- logger.debug("testLocking1: Entry");
-
- final String thisPdpId = activeStandbyProperties
- .getProperty(ActiveStandbyProperties.NODE_NAME);
-
- DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfd);
-
- /*
- * Insert this PDP as designated. Initial standby state will be
- * either null or cold standby.
- */
-
- logger.debug("testLocking1: Inserting PDP= {} as designated", thisPdpId);
- DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, true, 4, testTime.getDate());
- conn.insertPdp(pdp);
- DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
- logger.debug("testLocking1: After insertion, PDP= {} has DESIGNATED= {}",
- thisPdpId, droolsPdpEntity.isDesignated());
- assertTrue(droolsPdpEntity.isDesignated());
-
- logger.debug("testLocking1: Instantiating stateManagement object");
- StateManagement smDummy = new StateManagement(emfx, "dummy");
- smDummy.deleteAllStateManagementEntities();
-
- // Now we want to create a StateManagementFeature and initialize it. It will be
- // discovered by the ActiveStandbyFeature when the election handler initializes.
-
- StateManagementFeatureApi sm = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- sm = feature;
- logger.debug("testLocking1 stateManagementFeature.getResourceName(): {}", sm.getResourceName());
- break;
- }
- assertNotNull(sm);
-
- // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
- // that has been created.
- ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- activeStandbyFeature = feature;
- logger.debug("testLocking1 activeStandbyFeature.getResourceName(): {}",
- activeStandbyFeature.getResourceName());
- break;
- }
- assertNotNull(activeStandbyFeature);
-
- logger.debug("testLocking1: Runner started; Sleeping "
- + INTERRUPT_RECOVERY_TIME + "ms before promoting PDP={}",
- thisPdpId);
- sleep(INTERRUPT_RECOVERY_TIME);
-
- logger.debug("testLocking1: Promoting PDP={}", thisPdpId);
- sm.promote();
-
- logger.debug("testLocking1: Sleeping {} ms, to allow time for "
- + "policy-management.Main class to come up, designated= {}",
- SLEEP_TIME, conn.getPdp(thisPdpId).isDesignated());
- sleep(SLEEP_TIME);
-
- logger.debug("testLocking1: Waking up and invoking startTransaction on active PDP={}"
- + ", designated= {}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
-
-
- IntegrityMonitor droolsPdpIntegrityMonitor = IntegrityMonitor.getInstance();
- try {
- droolsPdpIntegrityMonitor.startTransaction();
- droolsPdpIntegrityMonitor.endTransaction();
- logger.debug("testLocking1: As expected, transaction successful");
- } catch (AdministrativeStateException e) {
- logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
- assertTrue(false);
- } catch (StandbyStatusException e) {
- logger.error("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
- assertTrue(false);
- } catch (Exception e) {
- logger.error("testLocking1: Unexpectedly caught Exception, ", e);
- assertTrue(false);
- }
-
- // demoting should cause state to transit to hotstandby, followed by re-promotion,
- // since there is only one PDP.
- logger.debug("testLocking1: demoting PDP={}", thisPdpId);
- sm.demote();
-
- logger.debug("testLocking1: sleeping" + ELECTION_WAIT_SLEEP_TIME
- + " to allow election handler to re-promote PDP={}", thisPdpId);
- sleep(ELECTION_WAIT_SLEEP_TIME);
-
- logger.debug("testLocking1: Invoking startTransaction on re-promoted PDP={}"
- + ", designated={}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
- try {
- droolsPdpIntegrityMonitor.startTransaction();
- droolsPdpIntegrityMonitor.endTransaction();
- logger.debug("testLocking1: As expected, transaction successful");
- } catch (AdministrativeStateException e) {
- logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
- assertTrue(false);
- } catch (StandbyStatusException e) {
- logger.error("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
- assertTrue(false);
- } catch (Exception e) {
- logger.error("testLocking1: Unexpectedly caught Exception, ", e);
- assertTrue(false);
- }
-
- // locking should cause state to transit to cold standby
- logger.debug("testLocking1: locking PDP={}", thisPdpId);
- sm.lock();
-
- // Just to avoid any race conditions, sleep a little after locking
- logger.debug("testLocking1: Sleeping a few millis after locking, to avoid race condition");
- sleep(100);
-
- logger.debug("testLocking1: Invoking startTransaction on locked PDP= {}"
- + ", designated= {}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
- try {
- droolsPdpIntegrityMonitor.startTransaction();
- logger.error("testLocking1: startTransaction unexpectedly successful");
- assertTrue(false);
- } catch (AdministrativeStateException e) {
- logger.debug("testLocking1: As expected, caught AdministrativeStateException, ", e);
- } catch (StandbyStatusException e) {
- logger.error("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
- assertTrue(false);
- } catch (Exception e) {
- logger.error("testLocking1: Unexpectedly caught Exception, ", e);
- assertTrue(false);
- } finally {
- droolsPdpIntegrityMonitor.endTransaction();
- }
-
- // unlocking should cause state to transit to hot standby and then providing service
- logger.debug("testLocking1: unlocking PDP={}", thisPdpId);
- sm.unlock();
-
- // Just to avoid any race conditions, sleep a little after locking
- logger.debug("testLocking1: Sleeping a few millis after unlocking, to avoid race condition");
- sleep(ELECTION_WAIT_SLEEP_TIME);
-
- logger.debug("testLocking1: Invoking startTransaction on unlocked PDP="
- + thisPdpId
- + ", designated="
- + conn.getPdp(thisPdpId).isDesignated());
- try {
- droolsPdpIntegrityMonitor.startTransaction();
- logger.error("testLocking1: startTransaction successful as expected");
- } catch (AdministrativeStateException e) {
- logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
- assertTrue(false);
- } catch (StandbyStatusException e) {
- logger.debug("testLocking1: Unexpectedly caught StandbyStatusException, ", e);
- assertTrue(false);
- } catch (Exception e) {
- logger.error("testLocking1: Unexpectedly caught Exception, ", e);
- assertTrue(false);
- } finally {
- droolsPdpIntegrityMonitor.endTransaction();
- }
-
- // demoting should cause state to transit to hot standby
- logger.debug("testLocking1: demoting PDP={}", thisPdpId);
- sm.demote();
-
- logger.debug("testLocking1: Invoking startTransaction on demoted PDP={}"
- + ", designated={}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
- try {
- droolsPdpIntegrityMonitor.startTransaction();
- droolsPdpIntegrityMonitor.endTransaction();
- logger.debug("testLocking1: Unexpectedly, transaction successful");
- assertTrue(false);
- } catch (AdministrativeStateException e) {
- logger.error("testLocking1: Unexpectedly caught AdministrativeStateException, ", e);
- assertTrue(false);
- } catch (StandbyStatusException e) {
- logger.error("testLocking1: As expected caught StandbyStatusException, ", e);
- } catch (Exception e) {
- logger.error("testLocking1: Unexpectedly caught Exception, ", e);
- assertTrue(false);
- }
-
- logger.debug("\n\ntestLocking1: Exiting\n\n");
- }
-
-
- /*
- * 1) Inserts and designates this PDP, then verifies that startTransaction
- * is successful.
- *
- * 2) Inserts another PDP in hotstandby.
- *
- * 3) Demotes this PDP, and verifies 1) that other PDP is not promoted (because one
- * PDP cannot promote another PDP) and 2) that this PDP is re-promoted.
- */
-
- /**
- * Test locking 2.
- *
- * @throws Exception exception
- */
- @Test
- public void testLocking2() throws Exception {
-
- logger.debug("\n\ntestLocking2: Entering\n\n");
-
- final String thisPdpId = activeStandbyProperties
- .getProperty(ActiveStandbyProperties.NODE_NAME);
-
- DroolsPdpsConnector conn = new JpaDroolsPdpsConnector(emfd);
-
- /*
- * Insert this PDP as designated. Initial standby state will be
- * either null or cold standby. Demoting should transit state to
- * hot standby.
- */
-
- logger.debug("testLocking2: Inserting PDP= {} as designated", thisPdpId);
- DroolsPdpImpl pdp = new DroolsPdpImpl(thisPdpId, true, 3, testTime.getDate());
- conn.insertPdp(pdp);
- DroolsPdpEntity droolsPdpEntity = conn.getPdp(thisPdpId);
- logger.debug("testLocking2: After insertion, PDP= {} has DESIGNATED= {}",
- thisPdpId, droolsPdpEntity.isDesignated());
- assertTrue(droolsPdpEntity.isDesignated());
-
- logger.debug("testLocking2: Instantiating stateManagement object and promoting PDP={}", thisPdpId);
- StateManagement smDummy = new StateManagement(emfx, "dummy");
- smDummy.deleteAllStateManagementEntities();
-
- // Now we want to create a StateManagementFeature and initialize it. It will be
- // discovered by the ActiveStandbyFeature when the election handler initializes.
-
- StateManagementFeatureApi sm = null;
- for (StateManagementFeatureApi feature : StateManagementFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- sm = feature;
- logger.debug("testLocking2 stateManagementFeature.getResourceName(): {}", sm.getResourceName());
- break;
- }
- assertNotNull(sm);
-
- // Create an ActiveStandbyFeature and initialize it. It will discover the StateManagementFeature
- // that has been created.
- ActiveStandbyFeatureApi activeStandbyFeature = null;
- for (ActiveStandbyFeatureApi feature : ActiveStandbyFeatureApiConstants.getImpl().getList()) {
- ((PolicySessionFeatureApi) feature).globalInit(null, CONFIG_DIR);
- activeStandbyFeature = feature;
- logger.debug("testLocking2 activeStandbyFeature.getResourceName(): {}",
- activeStandbyFeature.getResourceName());
- break;
- }
- assertNotNull(activeStandbyFeature);
-
- /*
- * Insert another PDP as not designated. Initial standby state will be
- * either null or cold standby. Demoting should transit state to
- * hot standby.
- */
-
- String standbyPdpId = "pdp2";
- logger.debug("testLocking2: Inserting PDP= {} as not designated", standbyPdpId);
- Date yesterday = DateUtils.addDays(testTime.getDate(), -1);
- pdp = new DroolsPdpImpl(standbyPdpId, false, 4, yesterday);
- conn.insertPdp(pdp);
- droolsPdpEntity = conn.getPdp(standbyPdpId);
- logger.debug("testLocking2: After insertion, PDP={} has DESIGNATED= {}",
- standbyPdpId, droolsPdpEntity.isDesignated());
- assertFalse(droolsPdpEntity.isDesignated());
-
- logger.debug("testLocking2: Demoting PDP= {}", standbyPdpId);
- final StateManagement sm2 = new StateManagement(emfx, standbyPdpId);
-
- logger.debug("testLocking2: Runner started; Sleeping {} ms "
- + "before promoting/demoting", INTERRUPT_RECOVERY_TIME);
- sleep(INTERRUPT_RECOVERY_TIME);
-
- logger.debug("testLocking2: Promoting PDP= {}", thisPdpId);
- sm.promote();
-
- // demoting PDP should ensure that state transits to hotstandby
- logger.debug("testLocking2: Demoting PDP={}", standbyPdpId);
- sm2.demote();
-
- logger.debug("testLocking2: Sleeping {} ms, to allow time for to come up", SLEEP_TIME);
- sleep(SLEEP_TIME);
-
- logger.debug("testLocking2: Waking up and invoking startTransaction on active PDP={}"
- + ", designated= {}", thisPdpId, conn.getPdp(thisPdpId).isDesignated());
-
- IntegrityMonitor droolsPdpIntegrityMonitor = IntegrityMonitor.getInstance();
-
- try {
- droolsPdpIntegrityMonitor.startTransaction();
- droolsPdpIntegrityMonitor.endTransaction();
- logger.debug("testLocking2: As expected, transaction successful");
- } catch (AdministrativeStateException e) {
- logger.error("testLocking2: Unexpectedly caught AdministrativeStateException, ", e);
- assertTrue(false);
- } catch (StandbyStatusException e) {
- logger.error("testLocking2: Unexpectedly caught StandbyStatusException, ", e);
- assertTrue(false);
- } catch (Exception e) {
- logger.error("testLocking2: Unexpectedly caught Exception, ", e);
- assertTrue(false);
- }
-
- // demoting should cause state to transit to hotstandby followed by re-promotion.
- logger.debug("testLocking2: demoting PDP={}", thisPdpId);
- sm.demote();
-
- logger.debug("testLocking2: sleeping {}"
- + " to allow election handler to re-promote PDP={}", ELECTION_WAIT_SLEEP_TIME, thisPdpId);
- sleep(ELECTION_WAIT_SLEEP_TIME);
-
- logger.debug("testLocking2: Waking up and invoking startTransaction "
- + "on re-promoted PDP= {}, designated= {}",
- thisPdpId, conn.getPdp(thisPdpId).isDesignated());
- try {
- droolsPdpIntegrityMonitor.startTransaction();
- droolsPdpIntegrityMonitor.endTransaction();
- logger.debug("testLocking2: As expected, transaction successful");
- } catch (AdministrativeStateException e) {
- logger.error("testLocking2: Unexpectedly caught AdministrativeStateException, ", e);
- assertTrue(false);
- } catch (StandbyStatusException e) {
- logger.error("testLocking2: Unexpectedly caught StandbyStatusException, ", e);
- assertTrue(false);
- } catch (Exception e) {
- logger.error("testLocking2: Unexpectedly caught Exception, ", e);
- assertTrue(false);
- }
-
- logger.debug("testLocking2: Verifying designated status for PDP= {}", standbyPdpId);
- assertFalse(conn.getPdp(standbyPdpId).isDesignated());
-
- logger.debug("\n\ntestLocking2: Exiting\n\n");
- }
-
- private static Properties loadStateManagementProperties() throws IOException {
- try (FileInputStream input = new FileInputStream(CONFIG_DIR + "/feature-state-management.properties")) {
- Properties props = new Properties();
- props.load(input);
- return props;
- }
- }
-
- private static Properties loadActiveStandbyProperties() throws IOException {
- try (FileInputStream input =
- new FileInputStream(CONFIG_DIR + "/feature-active-standby-management.properties")) {
- Properties props = new Properties();
- props.load(input);
- return props;
- }
- }
-
- private void sleep(long sleepms) throws InterruptedException {
- testTime.waitFor(sleepms);
- }
-}
diff --git a/feature-active-standby-management/src/test/resources/META-INF/persistence.xml b/feature-active-standby-management/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index ecbf22b7..00000000
--- a/feature-active-standby-management/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- feature-active-standby-management
- ================================================================================
- 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=========================================================
- -->
-
-<persistence version="2.1"
- xmlns="http://xmlns.jcp.org/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
- <persistence-unit name="junitDroolsPU"
- transaction-type="RESOURCE_LOCAL">
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
- <class>org.onap.policy.drools.activestandby.DroolsPdpEntity</class>
- <properties>
- <property
- name="javax.persistence.schema-generation.database.action"
- value="drop-and-create" />
- </properties>
- </persistence-unit>
- <persistence-unit name="junitXacmlPU"
- transaction-type="RESOURCE_LOCAL">
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
- <class>org.onap.policy.common.im.jpa.StateManagementEntity</class>
- <class>org.onap.policy.common.im.jpa.ForwardProgressEntity</class>
- <class>org.onap.policy.common.im.jpa.ResourceRegistrationEntity</class>
- <properties>
- <property
- name="javax.persistence.schema-generation.database.action"
- value="drop-and-create" />
- </properties>
- </persistence-unit>
-</persistence>
diff --git a/feature-active-standby-management/src/test/resources/asw/feature-active-standby-management.properties b/feature-active-standby-management/src/test/resources/asw/feature-active-standby-management.properties
deleted file mode 100644
index 23a1f6db..00000000
--- a/feature-active-standby-management/src/test/resources/asw/feature-active-standby-management.properties
+++ /dev/null
@@ -1,40 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# feature-active-standby-management
-# ================================================================================
-# Copyright (C) 2017, 2021 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=========================================================
-###
-
-# DB properties
-eclipselink.target-database=Auto
-javax.persistence.jdbc.driver = org.h2.Driver
-javax.persistence.jdbc.url = jdbc:h2:mem:asw_activestandbymanagement
-javax.persistence.jdbc.user = sa
-javax.persistence.jdbc.password =
-
-# Must be unique across the system
-resource.name=pdp1
-# Name of the site in which this node is hosted
-site_name=pdp_1
-
-# Needed by DroolsPdpsElectionHandler
-pdp.checkInterval=1500
-pdp.updateInterval=1000
-
-# Need long timeout, because testTransaction is only run every 1 seconds.
-pdp.timeout=3000
-#how long do we wait for the pdp table to populate on initial startup
-pdp.initialWait=1000
diff --git a/feature-active-standby-management/src/test/resources/asw/feature-state-management.properties b/feature-active-standby-management/src/test/resources/asw/feature-state-management.properties
deleted file mode 100644
index e03ebd2b..00000000
--- a/feature-active-standby-management/src/test/resources/asw/feature-state-management.properties
+++ /dev/null
@@ -1,82 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# feature-active-standby-management
-# ================================================================================
-# Copyright (C) 2017, 2021 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=========================================================
-###
-
-# DB properties
-eclipselink.target-database=Auto
-javax.persistence.jdbc.driver = org.h2.Driver
-javax.persistence.jdbc.url = jdbc:h2:mem:asw_statemanagement
-javax.persistence.jdbc.user = sa
-javax.persistence.jdbc.password =
-
-# DroolsPDPIntegrityMonitor Properties
-
-http.server.services=TEST
-http.server.services.TEST.host=0.0.0.0
-http.server.services.TEST.port=9982
-#These properties will default to the following if no other values are provided:
-# http.server.services.TEST.restClasses=org.onap.policy.drools.statemanagement.IntegrityMonitorRestManager
-# http.server.services.TEST.managed=false
-# http.server.services.TEST.swagger=true
-
-#IntegrityMonitor Properties
-
-# Must be unique across the system
-resource.name=pdp1
-# Name of the site in which this node is hosted
-site_name = pdp_1
-# How often in sec the forward progress monitor checks for forward progress
-fp_monitor_interval = 2
-# Failed counter threshold before failover
-failed_counter_threshold = 1
-# Interval between test transactions when no traffic seconds
-test_trans_interval = 1
-# Interval between writes of the FPC to the DB seconds
-write_fpc_interval = 1
-# Node type Note: Make sure you don't leave any trailing spaces, or you'll get an 'invalid node type' error!
-node_type = pdp_drools
-# Dependency groups are groups of resources upon which a node operational state is dependent upon.
-# Each group is a comma-separated list of resource names and groups are separated by a semicolon. For example:
-# dependency_groups=site_1.astra_1,site_1.astra_2;site_1.brms_1,site_1.brms_2;site_1.logparser_1;site_1.pypdp_1
-dependency_groups=
-# When set to true, dependent health checks are performed by using JMX to invoke test() on the dependent.
-# The default false is to use state checks for health.
-test_via_jmx=true
-# This is the max number of seconds beyond which a non incrementing FPC is considered a failure
-max_fpc_update_interval=5
-# Run the state audit every 60 seconds (60000 ms). The state audit finds stale DB entries in the
-# forwardprogressentity table and marks the node as disabled/failed in the statemanagemententity
-# table. NOTE! It will only run on nodes that have a standbystatus = providingservice.
-# A value of <= 0 will turn off the state audit.
-state_audit_interval_ms= -1
-# The refresh state audit is run every (default) 10 minutes (600000 ms) to clean up any state corruption in the
-# DB statemanagemententity table. It only refreshes the DB state entry for the local node. That is, it does not
-# refresh the state of any other nodes. A value <= 0 will turn the audit off. Any other value will override
-# the default of 600000 ms.
-refresh_state_audit_interval_ms=-1
-
-
-# Repository audit properties
-# Flag to control the execution of the subsystemTest for the Nexus Maven repository
-repository.audit.is.active=false
-repository.audit.ignore.errors=true
-
-# DB Audit Properties
-# Flag to control the execution of the subsystemTest for the Database
-db.audit.is.active=false
diff --git a/feature-active-standby-management/src/test/resources/feature-active-standby-management.properties b/feature-active-standby-management/src/test/resources/feature-active-standby-management.properties
deleted file mode 100644
index 5a1f9607..00000000
--- a/feature-active-standby-management/src/test/resources/feature-active-standby-management.properties
+++ /dev/null
@@ -1,39 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# feature-active-standby-management
-# ================================================================================
-# Copyright (C) 2017, 2021 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=========================================================
-###
-
-# DB properties
-eclipselink.target-database=Auto
-javax.persistence.jdbc.driver = org.h2.Driver
-javax.persistence.jdbc.url = jdbc:h2:mem:activestandbymanagement
-javax.persistence.jdbc.user = sa
-javax.persistence.jdbc.password =
-
-# Must be unique across the system
-resource.name=pdp1
-# Name of the site in which this node is hosted
-site_name=pdp_1
-
-# Needed by DroolsPdpsElectionHandler
-pdp.checkInterval=1500
-pdp.updateInterval=1000
-# Need long timeout, because testTransaction is only run every 10 seconds.
-pdp.timeout=3000
-#how long do we wait for the pdp table to populate on initial startup
-pdp.initialWait=1000
diff --git a/feature-active-standby-management/src/test/resources/feature-state-management.properties b/feature-active-standby-management/src/test/resources/feature-state-management.properties
deleted file mode 100644
index 6e4f61f3..00000000
--- a/feature-active-standby-management/src/test/resources/feature-state-management.properties
+++ /dev/null
@@ -1,83 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# feature-active-standby-management
-# ================================================================================
-# Copyright (C) 2017, 2019, 2021 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=========================================================
-###
-
-# DB properties
-eclipselink.target-database=Auto
-javax.persistence.jdbc.driver = org.h2.Driver
-javax.persistence.jdbc.url = jdbc:h2:mem:statemanagement
-javax.persistence.jdbc.user = sa
-javax.persistence.jdbc.password =
-
-# DroolsPDPIntegrityMonitor Properties
-#Test interface host and port defaults may be overwritten here
-http.server.services.TEST.host=0.0.0.0
-http.server.services.TEST.port=9981
-#These properties will default to the following if no other values are provided:
-# http.server.services.TEST.restClasses=org.onap.policy.drools.statemanagement.IntegrityMonitorRestManager
-# http.server.services.TEST.managed=false
-# http.server.services.TEST.swagger=true
-
-#IntegrityMonitor Properties
-
-# Must be unique across the system
-resource.name=pdp1
-# Name of the site in which this node is hosted
-site_name = pdp_1
-# Forward Progress Monitor update interval seconds
-fp_monitor_interval = 2
-# Failed counter threshold before failover
-failed_counter_threshold = 1
-# Interval between test transactions when no traffic seconds
-test_trans_interval = 1
-# Interval between writes of the FPC to the DB seconds
-write_fpc_interval = 1
-# Node type Note: Make sure you don't leave any trailing spaces, or you'll get an 'invalid node type' error!
-node_type = pdp_drools
-# Dependency groups are groups of resources upon which a node operational state is dependent upon.
-# Each group is a comma-separated list of resource names and groups are separated by a semicolon. For example:
-# dependency_groups=site_1.astra_1,site_1.astra_2;site_1.brms_1,site_1.brms_2;site_1.logparser_1;site_1.pypdp_1
-dependency_groups=
-# When set to true, dependent health checks are performed by using JMX to invoke test() on the dependent.
-# The default false is to use state checks for health.
-test_via_jmx=true
-# This is the max number of seconds beyond which a non incrementing FPC is considered a failure
-max_fpc_update_interval=5
-# Run the state audit every 60 seconds (60000 ms). The state audit finds stale DB entries in the
-# forwardprogressentity table and marks the node as disabled/failed in the statemanagemententity
-# table. NOTE! It will only run on nodes that have a standbystatus = providingservice.
-# A value of <= 0 will turn off the state audit.
-state_audit_interval_ms=-1
-# The refresh state audit is run every (default) 10 minutes (600000 ms) to clean up any state corruption in the
-# DB statemanagemententity table. It only refreshes the DB state entry for the local node. That is, it does not
-# refresh the state of any other nodes. A value <= 0 will turn the audit off. Any other value will override
-# the default of 600000 ms.
-refresh_state_audit_interval_ms=-1
-
-
-# Repository audit properties
-# Flag to control the execution of the subsystemTest for the Nexus Maven repository
-repository.audit.is.active=false
-repository.audit.ignore.errors=true
-repository.audit.interval_sec=86400
-repository.audit.failure.threshold=3
-
-# DB Audit Properties
-# Flag to control the execution of the subsystemTest for the Database
-db.audit.is.active=false
diff --git a/feature-active-standby-management/src/test/resources/logback-test.xml b/feature-active-standby-management/src/test/resources/logback-test.xml
deleted file mode 100644
index 583b9667..00000000
--- a/feature-active-standby-management/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- feature-state-management
- ================================================================================
- 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=========================================================
- -->
-
-<!-- Controls the output of logs for JUnit tests -->
-
-<configuration>
-
- <appender name="STDOUT"
- class="ch.qos.logback.core.ConsoleAppender">
- <encoder
- class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
- <Pattern>
- %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
- </Pattern>
- </encoder>
- </appender>
- <appender name="FILE"
- class="ch.qos.logback.core.FileAppender">
- <file>logs/debug.log</file>
- <encoder>
- <Pattern>
- %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
- </Pattern>
- </encoder>
- </appender>
-
- <root level="debug">
- <appender-ref ref="STDOUT" />
- <appender-ref ref="FILE" />
- </root>
-
-</configuration>