diff options
Diffstat (limited to 'feature-lifecycle/src/test')
5 files changed, 54 insertions, 12 deletions
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 |