summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/test/java
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2022-10-18 12:08:45 -0500
committerjhh <jorge.hernandez-herrero@att.com>2022-10-19 08:31:02 -0500
commit6652164b384221018bf605b1d5fb809425b26a8e (patch)
tree6e440f5379010f5bbb20841384c55b86da37b533 /feature-lifecycle/src/test/java
parente58a8c52dadfe14b8b77c8eb7c236697c710ddd5 (diff)
Support optional cluster name in policy engine
This allows also for correlation with running pod hostnames in the case of multiple drools pdp flavors coexist. Issue-ID: POLICY-4403 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I81affeeec622e6c0e9627651bf34c0775a796827 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/test/java')
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java4
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java8
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java6
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java8
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java12
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java6
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java4
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java4
8 files changed, 27 insertions, 25 deletions
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
index 0ad776cc..8c3aeef1 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
@@ -30,6 +30,7 @@ import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import org.junit.AfterClass;
@@ -106,6 +107,7 @@ public class LifecycleFsmTest {
LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
LoggerUtils.setLevel("org.onap.policy.drools", "INFO");
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
+ PolicyEngineConstants.getManager().configure(new Properties());
fsm = new LifecycleFsm() {
@Override
@@ -240,7 +242,7 @@ public class LifecycleFsmTest {
assertEquals(fsm.getGroup(), status.getStatistics().getPdpGroupName());
assertEquals(fsm.getSubGroup(), status.getStatistics().getPdpSubGroupName());
- assertEquals(PolicyEngineConstants.PDP_NAME, status.getStatistics().getPdpInstanceId());
+ assertEquals(PolicyEngineConstants.getManager().getPdpName(), status.getStatistics().getPdpInstanceId());
assertEquals(6, status.getStatistics().getPolicyDeploySuccessCount());
assertEquals(2, status.getStatistics().getPolicyDeployFailCount());
assertEquals(8, status.getStatistics().getPolicyDeployCount());
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
index c97133b5..5d56143d 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2021-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -160,7 +160,7 @@ public class LifecycleFsmUpdateTest {
Files.deleteIfExists(Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
"foo-controller.properties.bak"));
} catch (IOException ignored) { // NOSONAR
- ; // checkstyle
+ // checkstyle
}
ControllerSupport.setStaticField(LifecycleFeature.class, "fsm", savedFsm);
@@ -186,7 +186,7 @@ public class LifecycleFsmUpdateTest {
change.setPdpGroup("A");
change.setPdpSubgroup("a");
change.setState(PdpState.ACTIVE);
- change.setName(fsm.getName());
+ change.setName(fsm.getPdpName());
fsm.setSubGroup("a");
fsm.source.offer(new StandardCoder().encode(change));
@@ -359,7 +359,7 @@ public class LifecycleFsmUpdateTest {
protected PdpUpdate getPdpUpdate(List<ToscaPolicy> policiesToDeploy, List<ToscaPolicy> policiesToUndeploy) {
PdpUpdate update = new PdpUpdate();
- update.setName(PolicyEngineConstants.PDP_NAME);
+ update.setName(PolicyEngineConstants.getManager().getPdpName());
update.setPdpGroup("A");
update.setPdpSubgroup("a");
update.setPoliciesToBeDeployed(policiesToDeploy);
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
index f37e8ef7..67efa72a 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -77,7 +77,7 @@ public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest
change.setPdpGroup("A");
change.setPdpSubgroup("a");
change.setState(PdpState.ACTIVE);
- change.setName(fsm.getName());
+ change.setName(fsm.getPdpName());
fsm.setSubGroup("a");
fsm.source.offer(new StandardCoder().encode(change));
@@ -116,7 +116,7 @@ public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest
getPolicyFromFile(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_CONTROLLER_POLICY_NAME);
PdpUpdate update = new PdpUpdate();
- update.setName(PolicyEngineConstants.PDP_NAME);
+ update.setName(PolicyEngineConstants.getManager().getPdpName());
update.setPdpGroup("W");
update.setPdpSubgroup("w");
update.setPoliciesToBeDeployed(List.of(policyNativeController));
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
index f4c33140..d00c8a41 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -75,7 +75,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
change.setPdpGroup("A");
change.setPdpSubgroup("a");
change.setState(PdpState.ACTIVE);
- change.setName(fsm.getName());
+ change.setName(fsm.getPdpName());
fsm.setSubGroup("a");
fsm.source.offer(new StandardCoder().encode(change));
@@ -161,7 +161,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertNotEquals("b", fsm.getSubGroup());
- change.setName(fsm.getName());
+ change.setName(fsm.getPdpName());
fsm.source.offer(new StandardCoder().encode(change));
assertEquals(PdpState.ACTIVE, fsm.state());
assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
@@ -189,7 +189,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
// TODO: extract repeated similar assertion blocks into their own helper methods
PdpUpdate update = new PdpUpdate();
- update.setName(PolicyEngineConstants.PDP_NAME);
+ update.setName(PolicyEngineConstants.getManager().getPdpName());
update.setPdpGroup("W");
update.setPdpSubgroup("w");
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
index d99f011d..d6c94996 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -143,7 +143,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(0, controllerSupport.getController().getDrools().factCount("junits"));
PdpUpdate update = new PdpUpdate();
- update.setName(PolicyEngineConstants.PDP_NAME);
+ update.setName(PolicyEngineConstants.getManager().getPdpName());
update.setPdpGroup("Z");
update.setPdpSubgroup("z");
@@ -269,7 +269,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertNull(fsm.getSubGroup());
PdpUpdate update = new PdpUpdate();
- update.setName(PolicyEngineConstants.PDP_NAME);
+ update.setName(PolicyEngineConstants.getManager().getPdpName());
update.setPdpGroup("A");
update.setPdpSubgroup("a");
@@ -294,7 +294,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(0, controllerSupport.getController().getDrools().factCount("junits"));
/* correct name */
- change.setName(fsm.getName());
+ change.setName(fsm.getPdpName());
fsm.source.offer(new StandardCoder().encode(change));
assertEquals(PdpState.ACTIVE, fsm.state());
@@ -330,8 +330,8 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals("foo", status.getPdpType());
assertEquals(PdpState.TERMINATED, status.getState());
assertEquals(PdpHealthStatus.HEALTHY, status.getHealthy());
- assertEquals(PolicyEngineConstants.PDP_NAME, status.getName());
- assertEquals(fsm.getName(), status.getName());
+ assertEquals(PolicyEngineConstants.getManager().getPdpName(), status.getName());
+ assertEquals(fsm.getPdpName(), status.getName());
assertEquals(PdpMessageType.PDP_STATUS, status.getMessageName());
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
index eeac888d..7b210db8 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 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.
@@ -75,8 +75,8 @@ public abstract class LifecycleStateRunningTest {
try {
Files.deleteIfExists(Paths.get(SystemPersistenceConstants.getManager().getConfigurationPath().toString(),
CONTROLLER_NAME + "-controller.properties.bak"));
- } catch (IOException e) {
- ;
+ } catch (IOException ignored) {
+ // ignored
}
SystemPersistenceConstants.getManager().setConfigurationDir(null);
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
index 3d8d08b7..23643302 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -139,7 +139,7 @@ public class LifecycleStateTerminatedTest {
@Test
public void testUpdate() {
PdpUpdate update = new PdpUpdate();
- update.setName(PolicyEngineConstants.PDP_NAME);
+ update.setName(PolicyEngineConstants.getManager().getPdpName());
update.setPdpGroup("A");
update.setPdpSubgroup("a");
update.setPoliciesToBeDeployed(Collections.emptyList());
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
index 2d8b8688..b6f354e4 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2022 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.
@@ -50,7 +50,7 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
* Test initialization.
*/
@Before
- public void init() throws IOException, CoderException {
+ public void init() {
fsm = makeFsmWithPseudoTime();
}