summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-06-19 11:14:12 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2023-06-20 11:22:17 +0100
commita111b9631ec8a1eb3d108e21ebdac8a667cd4362 (patch)
tree7db92f09308aa01b267409ca2a5be7f19edbe878
parenta859910c602a5384ddd3e1b85e95bc800c099640 (diff)
Remove retry count support in ACM
Due the new timeout implementation, the Retry Count support could be removed. Issue-ID: POLICY-4735 Change-Id: I3b9c50a761696e00bcd1ca73dafa382c481e921d Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml3
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantParameters.java8
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantUpdateParameters.java46
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java6
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionPartecipantScanner.java15
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java78
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/TimeoutHandler.java (renamed from runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounter.java)53
-rw-r--r--runtime-acm/src/main/resources/application.yaml3
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java6
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantScannerTest.java1
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java25
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/TimeoutHandlerTest.java (renamed from runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java)50
12 files changed, 85 insertions, 209 deletions
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml
index c4c68f477..a8e45ff0a 100644
--- a/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/AcRuntimeParameters.yaml
@@ -41,9 +41,6 @@ runtime:
participantParameters:
heartBeatMs: 20000
maxStatusWaitMs: 100000
- updateParameters:
- maxRetryCount: 3
- maxWaitMs: 20000
topicParameterGroup:
topicSources:
-
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantParameters.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantParameters.java
index 248824f11..8c3a7078a 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantParameters.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantParameters.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021,2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,9 +18,7 @@
package org.onap.policy.clamp.acm.runtime.main.parameters;
-import javax.validation.Valid;
import javax.validation.constraints.Min;
-import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.springframework.validation.annotation.Validated;
@@ -38,8 +36,4 @@ public class ParticipantParameters {
@Min(100)
private long maxStatusWaitMs;
-
- @Valid
- @NotNull
- private ParticipantUpdateParameters updateParameters;
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantUpdateParameters.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantUpdateParameters.java
deleted file mode 100644
index 5ffaf39c0..000000000
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/parameters/ParticipantUpdateParameters.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * 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.clamp.acm.runtime.main.parameters;
-
-import javax.validation.constraints.Min;
-import lombok.Getter;
-import lombok.Setter;
-import org.springframework.validation.annotation.Validated;
-
-/**
- * Parameters for Participant UPDATE requests.
- */
-@Getter
-@Setter
-@Validated
-public class ParticipantUpdateParameters {
-
- /**
- * Maximum number of times to re-send a request to a PDP.
- */
- @Min(value = 1)
- private int maxRetryCount;
-
- /**
- * Maximum time to wait, in milliseconds, for a PDP response.
- */
- @Min(value = 100)
- private long maxWaitMs;
-
-}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java
index ef50a633e..7303fc84f 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspect.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ public class SupervisionAspect implements Closeable {
}
private void executeScan() {
- supervisionScanner.run(true);
+ supervisionScanner.run();
partecipantScanner.run();
}
@@ -68,7 +68,7 @@ public class SupervisionAspect implements Closeable {
public void doCheck() {
if (executor.getQueue().size() < 2) {
LOGGER.debug("Add scanning Message");
- executor.execute(() -> supervisionScanner.run(false));
+ executor.execute(() -> supervisionScanner.run());
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionPartecipantScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionPartecipantScanner.java
index b396e629c..092fc3572 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionPartecipantScanner.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionPartecipantScanner.java
@@ -36,7 +36,7 @@ import org.springframework.stereotype.Component;
public class SupervisionPartecipantScanner {
private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionPartecipantScanner.class);
- private final HandleCounter<UUID> participantStatusCounter = new HandleCounter<>();
+ private final TimeoutHandler<UUID> participantStatusTimeout = new TimeoutHandler<>();
private final ParticipantProvider participantProvider;
@@ -51,9 +51,7 @@ public class SupervisionPartecipantScanner {
final AcRuntimeParameterGroup acRuntimeParameterGroup) {
this.participantProvider = participantProvider;
- participantStatusCounter.setMaxRetryCount(
- acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
- participantStatusCounter.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
+ participantStatusTimeout.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
}
/**
@@ -71,14 +69,13 @@ public class SupervisionPartecipantScanner {
private void scanParticipantStatus(Participant participant) {
var id = participant.getParticipantId();
- if (participantStatusCounter.isFault(id)) {
+ if (participantStatusTimeout.isTimeout(id)) {
LOGGER.debug("report Participant fault");
return;
}
- if (participantStatusCounter.getDuration(id) > participantStatusCounter.getMaxWaitMs()
- && !participantStatusCounter.count(id)) {
+ if (participantStatusTimeout.getDuration(id) > participantStatusTimeout.getMaxWaitMs()) {
LOGGER.debug("report Participant fault");
- participantStatusCounter.setFault(id);
+ participantStatusTimeout.setTimeout(id);
participant.setParticipantState(ParticipantState.OFF_LINE);
participantProvider.updateParticipant(participant);
}
@@ -88,6 +85,6 @@ public class SupervisionPartecipantScanner {
* handle participant Status message.
*/
public void handleParticipantStatus(UUID id) {
- participantStatusCounter.clear(id);
+ participantStatusTimeout.clear(id);
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
index 41c7b1c74..b1bd29281 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScanner.java
@@ -47,7 +47,7 @@ import org.springframework.stereotype.Component;
public class SupervisionScanner {
private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class);
- private final HandleCounter<UUID> automationCompositionCounter = new HandleCounter<>();
+ private final TimeoutHandler<UUID> acTimeout = new TimeoutHandler<>();
private final Map<UUID, Integer> phaseMap = new HashMap<>();
private final AutomationCompositionProvider automationCompositionProvider;
@@ -74,25 +74,20 @@ public class SupervisionScanner {
this.automationCompositionStateChangePublisher = automationCompositionStateChangePublisher;
this.automationCompositionDeployPublisher = automationCompositionDeployPublisher;
- automationCompositionCounter.setMaxRetryCount(
- acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().getMaxRetryCount());
- automationCompositionCounter
- .setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
+ acTimeout.setMaxWaitMs(acRuntimeParameterGroup.getParticipantParameters().getMaxStatusWaitMs());
}
/**
* Run Scanning.
- *
- * @param counterCheck if true activate counter and retry
*/
- public void run(boolean counterCheck) {
+ public void run() {
LOGGER.debug("Scanning automation compositions in the database . . .");
var list = acDefinitionProvider.getAllAcDefinitions();
for (var acDefinition : list) {
var acList = automationCompositionProvider.getAcInstancesByCompositionId(acDefinition.getCompositionId());
for (var automationComposition : acList) {
- scanAutomationComposition(automationComposition, acDefinition.getServiceTemplate(), counterCheck);
+ scanAutomationComposition(automationComposition, acDefinition.getServiceTemplate());
}
}
@@ -100,23 +95,24 @@ public class SupervisionScanner {
}
private void scanAutomationComposition(final AutomationComposition automationComposition,
- ToscaServiceTemplate serviceTemplate, boolean counterCheck) {
+ ToscaServiceTemplate serviceTemplate) {
LOGGER.debug("scanning automation composition {} . . .", automationComposition.getInstanceId());
if (!AcmUtils.isInTransitionalState(automationComposition.getDeployState(),
- automationComposition.getLockState())) {
+ automationComposition.getLockState())
+ || StateChangeResult.FAILED.equals(automationComposition.getStateChangeResult())) {
LOGGER.debug("automation composition {} scanned, OK", automationComposition.getInstanceId());
- // Clear missed report counter on automation composition
- clearFaultAndCounter(automationComposition);
+ // Clear Timeout on automation composition
+ clearTimeout(automationComposition, true);
return;
}
- if (automationCompositionCounter.isFault(automationComposition.getInstanceId())
+ if (acTimeout.isTimeout(automationComposition.getInstanceId())
&& StateChangeResult.NO_ERROR.equals(automationComposition.getStateChangeResult())) {
// retry by the user
- LOGGER.debug("clearing fault for the ac instance");
- clearFaultAndCounter(automationComposition);
+ LOGGER.debug("clearing Timeout for the ac instance");
+ clearTimeout(automationComposition, true);
}
var completed = true;
@@ -148,6 +144,7 @@ public class SupervisionScanner {
if (DeployState.UPDATING.equals(automationComposition.getDeployState())) {
// UPDATING do not need phases
+ handleTimeout(automationComposition);
return;
}
@@ -161,10 +158,8 @@ public class SupervisionScanner {
phaseMap.put(automationComposition.getInstanceId(), nextSpNotCompleted);
sendAutomationCompositionMsg(automationComposition, serviceTemplate, nextSpNotCompleted,
firstStartPhase == nextSpNotCompleted);
- } else if (counterCheck) {
- phaseMap.put(automationComposition.getInstanceId(), nextSpNotCompleted);
- handleCounter(automationComposition, serviceTemplate, nextSpNotCompleted,
- firstStartPhase == nextSpNotCompleted);
+ } else {
+ handleTimeout(automationComposition);
}
}
}
@@ -172,42 +167,39 @@ public class SupervisionScanner {
private void complete(final AutomationComposition automationComposition) {
var deployState = automationComposition.getDeployState();
automationComposition.setDeployState(AcmUtils.deployCompleted(deployState));
- automationComposition
- .setLockState(AcmUtils.lockCompleted(deployState, automationComposition.getLockState()));
+ automationComposition.setLockState(AcmUtils.lockCompleted(deployState, automationComposition.getLockState()));
+ if (StateChangeResult.TIMEOUT.equals(automationComposition.getStateChangeResult())) {
+ automationComposition.setStateChangeResult(StateChangeResult.NO_ERROR);
+ }
if (DeployState.DELETED.equals(automationComposition.getDeployState())) {
automationCompositionProvider.deleteAutomationComposition(automationComposition.getInstanceId());
} else {
automationCompositionProvider.updateAutomationComposition(automationComposition);
}
- // Clear missed report counter on automation composition
- clearFaultAndCounter(automationComposition);
+ // Clear timeout on automation composition
+ clearTimeout(automationComposition, true);
}
- private void clearFaultAndCounter(AutomationComposition automationComposition) {
- automationCompositionCounter.clear(automationComposition.getInstanceId());
- phaseMap.remove(automationComposition.getInstanceId());
+ private void clearTimeout(AutomationComposition automationComposition, boolean cleanPhase) {
+ acTimeout.clear(automationComposition.getInstanceId());
+ if (cleanPhase) {
+ phaseMap.remove(automationComposition.getInstanceId());
+ }
}
- private void handleCounter(AutomationComposition automationComposition, ToscaServiceTemplate serviceTemplate,
- int startPhase, boolean firstStartPhase) {
+ private void handleTimeout(AutomationComposition automationComposition) {
var instanceId = automationComposition.getInstanceId();
- if (automationCompositionCounter.isFault(instanceId)) {
- LOGGER.debug("report AutomationComposition fault");
+ if (acTimeout.isTimeout(instanceId)) {
+ LOGGER.debug("The ac instance is in timeout {}", automationComposition.getInstanceId());
return;
}
- if (automationCompositionCounter.getDuration(instanceId) > automationCompositionCounter.getMaxWaitMs()) {
- if (automationCompositionCounter.count(instanceId)) {
- phaseMap.put(instanceId, startPhase);
- sendAutomationCompositionMsg(automationComposition, serviceTemplate, startPhase, firstStartPhase);
- } else {
- LOGGER.debug("report AutomationComposition fault");
- automationCompositionCounter.setFault(instanceId);
- LOGGER.debug("report timeout for the ac instance");
- automationComposition.setStateChangeResult(StateChangeResult.TIMEOUT);
- automationCompositionProvider.updateAutomationComposition(automationComposition);
- }
+ if (acTimeout.getDuration(instanceId) > acTimeout.getMaxWaitMs()) {
+ LOGGER.debug("Report timeout for the ac instance {}", automationComposition.getInstanceId());
+ acTimeout.setTimeout(instanceId);
+ automationComposition.setStateChangeResult(StateChangeResult.TIMEOUT);
+ automationCompositionProvider.updateAutomationComposition(automationComposition);
}
}
@@ -221,5 +213,7 @@ public class SupervisionScanner {
LOGGER.debug("retry message AutomationCompositionStateChange");
automationCompositionStateChangePublisher.send(automationComposition, startPhase, firstStartPhase);
}
+ // Clear timeout on automation composition
+ clearTimeout(automationComposition, false);
}
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounter.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/TimeoutHandler.java
index 9949f3c89..976c91438 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounter.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/TimeoutHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,17 +28,12 @@ import java.util.Set;
import lombok.Getter;
import lombok.Setter;
-public class HandleCounter<K> {
+public class TimeoutHandler<K> {
@Getter
@Setter
private long maxWaitMs;
- @Getter
- @Setter
- private int maxRetryCount;
-
- private Map<K, Integer> mapCounter = new HashMap<>();
- private Set<K> mapFault = new HashSet<>();
+ private Set<K> mapTimeout = new HashSet<>();
private Map<K, Long> mapTimer = new HashMap<>();
public long getDuration(K id) {
@@ -47,60 +42,34 @@ public class HandleCounter<K> {
}
/**
- * Reset timer and clear counter and fault by id.
+ * Reset timer and timeout by id.
*
* @param id the id
*/
public void clear(K id) {
- mapFault.remove(id);
- mapCounter.put(id, 0);
+ mapTimeout.remove(id);
mapTimer.put(id, getEpochMilli());
}
/**
- * Remove counter, timer and fault by id.
+ * Remove timer and timeout by id.
*
* @param id the id
*/
public void remove(K id) {
- mapFault.remove(id);
- mapCounter.remove(id);
+ mapTimeout.remove(id);
mapTimer.remove(id);
}
- public void setFault(K id) {
- mapCounter.put(id, 0);
- mapFault.add(id);
- }
-
- /**
- * Increment RetryCount by id e return true if minor or equal of maxRetryCount.
- *
- * @param id the identifier
- * @return false if count is major of maxRetryCount
- */
- public boolean count(K id) {
- int counter = mapCounter.getOrDefault(id, 0) + 1;
- if (counter <= maxRetryCount) {
- mapCounter.put(id, counter);
- return true;
- }
- return false;
- }
-
- public boolean isFault(K id) {
- return mapFault.contains(id);
+ public void setTimeout(K id) {
+ mapTimeout.add(id);
}
- public int getCounter(K id) {
- return mapCounter.getOrDefault(id, 0);
+ public boolean isTimeout(K id) {
+ return mapTimeout.contains(id);
}
protected long getEpochMilli() {
return Instant.now().toEpochMilli();
}
-
- public Set<K> keySet() {
- return mapCounter.keySet();
- }
}
diff --git a/runtime-acm/src/main/resources/application.yaml b/runtime-acm/src/main/resources/application.yaml
index 771d7006a..faef54af0 100644
--- a/runtime-acm/src/main/resources/application.yaml
+++ b/runtime-acm/src/main/resources/application.yaml
@@ -43,9 +43,6 @@ runtime:
participantParameters:
heartBeatMs: 20000
maxStatusWaitMs: 100000
- updateParameters:
- maxRetryCount: 4
- maxWaitMs: 20000
topicParameterGroup:
topicSources:
-
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
index c9985e203..0cee08ac5 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAspectTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -37,7 +37,7 @@ class SupervisionAspectTest {
var partecipantScanner = mock(SupervisionPartecipantScanner.class);
try (var supervisionAspect = new SupervisionAspect(supervisionScanner, partecipantScanner)) {
supervisionAspect.schedule();
- verify(supervisionScanner, timeout(500)).run(true);
+ verify(supervisionScanner, timeout(500)).run();
verify(partecipantScanner, timeout(500)).run();
}
}
@@ -49,7 +49,7 @@ class SupervisionAspectTest {
try (var supervisionAspect = new SupervisionAspect(supervisionScanner, partecipantScanner)) {
supervisionAspect.doCheck();
supervisionAspect.doCheck();
- verify(supervisionScanner, timeout(500).times(2)).run(false);
+ verify(supervisionScanner, timeout(500).times(2)).run();
}
}
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantScannerTest.java
index 3ad9f813c..4bab85bf5 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantScannerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantScannerTest.java
@@ -38,7 +38,6 @@ class SupervisionParticipantScannerTest {
@Test
void testScanParticipant() throws PfModelException {
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanParticipant");
- acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().setMaxWaitMs(-1);
acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1);
var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
index 7aaa6d22c..99af72801 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java
@@ -80,7 +80,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
acRuntimeParameterGroup);
- supervisionScanner.run(false);
+ supervisionScanner.run();
verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
}
@@ -101,7 +101,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
acRuntimeParameterGroup);
- supervisionScanner.run(false);
+ supervisionScanner.run();
verify(automationCompositionProvider).updateAutomationComposition(any(AutomationComposition.class));
}
@@ -123,7 +123,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
acRuntimeParameterGroup);
- supervisionScanner.run(false);
+ supervisionScanner.run();
verify(automationCompositionProvider).deleteAutomationComposition(automationComposition.getInstanceId());
}
@@ -143,12 +143,12 @@ class SupervisionScannerTest {
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
acRuntimeParameterGroup);
- supervisionScanner.run(true);
+ supervisionScanner.run();
verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
}
@Test
- void testScannerForCounterHandling() {
+ void testScannerForTimeout() {
var automationComposition = InstantiationUtils.getAutomationCompositionFromResource(AC_JSON, "Crud");
automationComposition.setDeployState(DeployState.DEPLOYING);
automationComposition.setLockState(LockState.NONE);
@@ -164,21 +164,12 @@ class SupervisionScannerTest {
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1);
- //verify retry scenario
- var scannerObj1 = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
- automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
- acRuntimeParameterGroup);
-
- scannerObj1.run(true);
- verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
-
//verify timeout scenario
- acRuntimeParameterGroup.getParticipantParameters().getUpdateParameters().setMaxRetryCount(0);
var scannerObj2 = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
acRuntimeParameterGroup);
- scannerObj2.run(true);
+ scannerObj2.run();
verify(automationCompositionProvider, times(1)).updateAutomationComposition(any(AutomationComposition.class));
}
@@ -211,7 +202,7 @@ class SupervisionScannerTest {
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
acRuntimeParameterGroup);
- supervisionScanner.run(false);
+ supervisionScanner.run();
verify(automationCompositionDeployPublisher).send(any(AutomationComposition.class),
any(ToscaServiceTemplate.class), anyInt(), anyBoolean());
@@ -245,7 +236,7 @@ class SupervisionScannerTest {
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
acRuntimeParameterGroup);
- supervisionScanner.run(false);
+ supervisionScanner.run();
verify(automationCompositionStateChangePublisher).send(any(AutomationComposition.class), anyInt(),
anyBoolean());
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/TimeoutHandlerTest.java
index e50126d27..21c5b3d2c 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/HandleCounterTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/TimeoutHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,38 +24,22 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
-class HandleCounterTest {
+class TimeoutHandlerTest {
private static final int ID = 1;
@Test
- void testCount() {
- var handleCounter = new HandleCounter<Integer>();
- handleCounter.setMaxRetryCount(2);
- assertThat(handleCounter.count(ID)).isTrue();
- assertThat(handleCounter.getCounter(ID)).isEqualTo(1);
- assertThat(handleCounter.count(ID)).isTrue();
- assertThat(handleCounter.getCounter(ID)).isEqualTo(2);
- assertThat(handleCounter.count(ID)).isFalse();
- assertThat(handleCounter.getCounter(ID)).isEqualTo(2);
-
- handleCounter.clear(ID);
- assertThat(handleCounter.count(ID)).isTrue();
- assertThat(handleCounter.getCounter(ID)).isEqualTo(1);
- }
-
- @Test
void testFault() {
- var handleCounter = new HandleCounter<Integer>();
- handleCounter.setFault(ID);
- assertThat(handleCounter.isFault(ID)).isTrue();
- handleCounter.clear(ID);
- assertThat(handleCounter.isFault(ID)).isFalse();
+ var timeoutHandler = new TimeoutHandler<Integer>();
+ timeoutHandler.setTimeout(ID);
+ assertThat(timeoutHandler.isTimeout(ID)).isTrue();
+ timeoutHandler.clear(ID);
+ assertThat(timeoutHandler.isTimeout(ID)).isFalse();
}
@Test
void testDuration() {
- var handleCounter = new HandleCounter<Integer>() {
+ var timeoutHandler = new TimeoutHandler<Integer>() {
long epochMilli = 0;
@Override
@@ -63,21 +47,21 @@ class HandleCounterTest {
return epochMilli;
}
};
- handleCounter.epochMilli = 100;
- var result = handleCounter.getDuration(ID);
+ timeoutHandler.epochMilli = 100;
+ var result = timeoutHandler.getDuration(ID);
assertThat(result).isZero();
- handleCounter.epochMilli += 100;
- result = handleCounter.getDuration(ID);
+ timeoutHandler.epochMilli += 100;
+ result = timeoutHandler.getDuration(ID);
assertThat(result).isEqualTo(100);
- handleCounter.epochMilli += 100;
- result = handleCounter.getDuration(ID);
+ timeoutHandler.epochMilli += 100;
+ result = timeoutHandler.getDuration(ID);
assertThat(result).isEqualTo(200);
- handleCounter.epochMilli += 100;
- handleCounter.clear(ID);
- result = handleCounter.getDuration(ID);
+ timeoutHandler.epochMilli += 100;
+ timeoutHandler.clear(ID);
+ result = timeoutHandler.getDuration(ID);
assertThat(result).isZero();
}
}