diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2019-04-16 23:09:49 -0500 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2019-04-16 23:10:46 -0500 |
commit | a2e7d569974b018235e821d7bc0bb7a43d75aa2c (patch) | |
tree | e9d669efdc6af9796e0865d95b1b263a1f9edfb1 /feature-lifecycle/src | |
parent | fde980c4377e237eec08be75bdb7d6ae8fa33b78 (diff) |
Add response section to PAP status message
Change-Id: I26bf9f515c8639c030e8beb9e8b37a6a632da686
Issue-ID: POLICY-1655
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src')
7 files changed, 58 insertions, 14 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java index 8e1e9937..ada29ede 100644 --- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java +++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java @@ -147,7 +147,7 @@ public class LifecycleFsm implements Startable { * Start a controller event. */ public synchronized void start(@NonNull PolicyController controller) { - logger.info("lifecycle event: start controller: {}" + controller.getName()); + logger.info("lifecycle event: start controller: {}", controller.getName()); for (ToscaPolicyTypeIdentifier id : controller.getPolicyTypes()) { policyTypesMap.put(id, controller); } @@ -237,7 +237,7 @@ public class LifecycleFsm implements Startable { status.setResponse(response); } - return client.send(statusPayload(state)); + return client.send(status); } protected void setGroupAction(String group, String subgroup) { diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java index 38ea0917..2dacdd1d 100644 --- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java +++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java @@ -20,6 +20,7 @@ package org.onap.policy.drools.lifecycle; +import java.util.Collections; import lombok.NonNull; import lombok.ToString; import org.onap.policy.drools.system.PolicyController; @@ -53,6 +54,7 @@ public class LifecycleStateActive extends LifecycleStateRunning { @Override protected boolean stateChangeToPassive(PdpStateChange change) { + undeployPolicies(Collections.emptyList()); fsm.transitionToAction(new LifecycleStatePassive(fsm)); return fsm.statusAction(response(change.getRequestId(), PdpResponseStatus.SUCCESS, null)); } diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java index d5ac423a..c22a0d88 100644 --- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java +++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java @@ -58,6 +58,12 @@ public class ControllerSupport { * Create controller. */ public PolicyController createController() throws IOException { + try { + getController(); + } catch (IllegalArgumentException e) { + ; + } + ReleaseId coordinates = KieUtils.installArtifact(Paths.get(JUNIT_KMODULE_PATH).toFile(), Paths.get(JUNIT_KMODULE_POM_PATH).toFile(), 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 554f2ef0..d28ab14c 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 @@ -195,22 +195,16 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest { PdpUpdate update = new PdpUpdate(); update.setName(NetworkUtil.getHostname()); - update.setPdpGroup("Z"); - update.setPdpSubgroup("z"); + update.setPdpGroup("W"); + update.setPdpSubgroup("w"); update.setPolicies(Collections.emptyList()); - long originalInterval = fsm.getStatusTimerSeconds(); - long interval = 10 * originalInterval; - update.setPdpHeartbeatIntervalMs(interval * 1000L); - fsm.start(controllerSupport.getController()); - assertTrue(fsm.update(update)); assertEquals(PdpState.ACTIVE, fsm.state()); - assertEquals(interval, fsm.getStatusTimerSeconds()); - assertEquals("Z", fsm.getGroup()); - assertEquals("z", fsm.getSubgroup()); + assertEquals("W", fsm.getGroup()); + assertEquals("w", fsm.getSubgroup()); String restartV1 = new String(Files.readAllBytes(Paths.get("src/test/resources/tosca-policy-operational-restart.json"))); @@ -316,6 +310,15 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest { assertTrue(factPolicies.stream().anyMatch((ff) -> Objects.equals(toscaPolicyFirewall, ff))); assertEquals(2, fsm.policiesMap.size()); + long originalInterval = fsm.getStatusTimerSeconds(); + long interval = 10 * originalInterval; + update.setPdpHeartbeatIntervalMs(interval * 1000L); + + assertTrue(fsm.update(update)); + + assertEquals(PdpState.ACTIVE, fsm.state()); + assertEquals(interval, fsm.getStatusTimerSeconds()); + fsm.shutdown(); } } 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 775dc8b0..b96779aa 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 @@ -180,6 +180,12 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest { assertTrue(fsm.update(update)); + int qlength = fsm.client.getSink().getRecentEvents().length; + PdpStatus lastStatus = new StandardCoder() + .decode(fsm.client.getSink().getRecentEvents()[qlength - 1], PdpStatus.class); + assertEquals(update.getRequestId(), lastStatus.getRequestId()); + assertEquals(update.getRequestId(), lastStatus.getResponse().getResponseTo()); + assertEquals(PdpState.PASSIVE, fsm.state()); assertEquals(interval, fsm.getStatusTimerSeconds()); assertEquals("Z", fsm.getGroup()); 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 6da9dc12..25cce3a9 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 @@ -42,7 +42,7 @@ public abstract class LifecycleStateRunningTest { LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO"); LoggerUtil.setLevel("org.onap.policy.common.endpoints", "WARN"); LoggerUtil.setLevel("org.onap.policy.drools", "INFO"); - SystemPersistence.manager.setConfigurationDir("src/test/resources"); + SystemPersistence.manager.setConfigurationDir("target/test-classes"); controllerSupport.createController(); } @@ -51,7 +51,6 @@ public abstract class LifecycleStateRunningTest { */ @AfterClass public static void tearDown() { - controllerSupport.destroyController(); try { Files.deleteIfExists(Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), CONTROLLER_NAME + "-controller.properties.bak")); diff --git a/feature-lifecycle/src/test/resources/logback-test.xml b/feature-lifecycle/src/test/resources/logback-test.xml new file mode 100644 index 00000000..bde0b5e8 --- /dev/null +++ b/feature-lifecycle/src/test/resources/logback-test.xml @@ -0,0 +1,28 @@ +<!-- + ============LICENSE_START======================================================= + 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========================================================= +--> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%M:%line - %msg%n</pattern> + </encoder> + </appender> + <root level="INFO"> + <appender-ref ref="STDOUT" /> + </root> +</configuration>
\ No newline at end of file |