aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/test/java/org/onap
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2024-07-30 14:16:58 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2024-08-01 09:00:56 +0100
commit0c43d421586d24312dd6932e9a99e71fa8243b6b (patch)
treeb4fa7fa236af0df07c00f98a5af454c0eee890e8 /runtime-acm/src/test/java/org/onap
parent6de7fc00ed09d873ea2508ecf8b4e771a97d4b98 (diff)
Allow migration to be performed in stages in ACM runtime
Issue-ID: POLICY-5090 Change-Id: I17ebe6e9bd9b6cf60684d10ba3e661ea183dd353 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/test/java/org/onap')
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java9
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java7
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionScannerTest.java31
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java2
4 files changed, 28 insertions, 21 deletions
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
index 23709728d..90633e706 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
@@ -296,7 +296,7 @@ class AutomationCompositionInstantiationProviderTest {
assertThatThrownBy(
() -> instantiationProvider.updateAutomationComposition(compositionId, automationCompositionUpdate))
- .hasMessageMatching(message);
+ .hasMessageMatching(message);
}
@Test
@@ -343,6 +343,7 @@ class AutomationCompositionInstantiationProviderTest {
var compositionTargetId = acDefinitionTarget.getCompositionId();
automationCompositionTarget.setCompositionTargetId(compositionTargetId);
when(acDefinitionProvider.findAcDefinition(compositionTargetId)).thenReturn(Optional.of(acDefinitionTarget));
+ when(acDefinitionProvider.getAcDefinition(compositionTargetId)).thenReturn(acDefinitionTarget);
when(acProvider.updateAutomationComposition(any())).thenReturn(automationCompositionTarget);
var supervisionAcHandler = mock(SupervisionAcHandler.class);
@@ -363,7 +364,7 @@ class AutomationCompositionInstantiationProviderTest {
var instantiationResponse = instantiationProvider.updateAutomationComposition(compositionId,
automationCompositionTarget);
- verify(supervisionAcHandler).migrate(any());
+ verify(supervisionAcHandler).migrate(any(), any());
InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationCompositionTarget);
}
@@ -425,18 +426,18 @@ class AutomationCompositionInstantiationProviderTest {
var acDefinitionTarget = CommonTestData.createAcDefinition(serviceTemplate, AcTypeState.PRIMED);
var compositionTargetId = acDefinitionTarget.getCompositionId();
when(acDefinitionProvider.findAcDefinition(compositionTargetId)).thenReturn(Optional.of(acDefinitionTarget));
+ when(acDefinitionProvider.getAcDefinition(compositionTargetId)).thenReturn(acDefinitionTarget);
automationComposition.setCompositionTargetId(compositionTargetId);
var instantiationResponse = instantiationProvider
.updateAutomationComposition(automationComposition.getCompositionId(), automationComposition);
- verify(supervisionAcHandler).migrate(any());
+ verify(supervisionAcHandler).migrate(any(), any());
verify(acProvider).updateAutomationComposition(automationComposition);
InstantiationUtils.assertInstantiationResponse(instantiationResponse, automationComposition);
}
-
@Test
void testInstantiationMigrationPrecheck() {
var acDefinitionProvider = mock(AcDefinitionProvider.class);
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
index 2d9c1280b..5f87db30c 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandlerTest.java
@@ -353,8 +353,9 @@ class SupervisionAcHandlerTest {
acCompositionMigrationPublisher, mock(ParticipantSyncPublisher.class), null);
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Migrate");
- handler.migrate(automationComposition);
- verify(acCompositionMigrationPublisher, timeout(1000)).send(any(AutomationComposition.class));
+ var serviceTemplate = InstantiationUtils.getToscaServiceTemplate(TOSCA_SERVICE_TEMPLATE_YAML);
+ handler.migrate(automationComposition, serviceTemplate);
+ verify(acCompositionMigrationPublisher, timeout(1000)).send(any(AutomationComposition.class), anyInt());
}
@Test
@@ -366,7 +367,7 @@ class SupervisionAcHandlerTest {
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_CREATE_JSON, "Migrate");
handler.migratePrecheck(automationComposition);
- verify(acCompositionMigrationPublisher, timeout(1000)).send(any(AutomationComposition.class));
+ verify(acCompositionMigrationPublisher, timeout(1000)).send(any(AutomationComposition.class), anyInt());
}
@Test
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 6bdab706c..f7ccfe61e 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
@@ -102,7 +102,7 @@ class SupervisionScannerTest {
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
var supervisionScanner = new SupervisionScanner(mock(AutomationCompositionProvider.class), acDefinitionProvider,
mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class),
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
supervisionScanner.run();
verify(acDefinitionProvider, times(0)).updateAcDefinitionState(any(), any(), any(), any());
}
@@ -114,7 +114,7 @@ class SupervisionScannerTest {
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
var supervisionScanner = new SupervisionScanner(mock(AutomationCompositionProvider.class), acDefinitionProvider,
mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class),
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
supervisionScanner.run();
// Ac Definition in Priming state
verify(acDefinitionProvider, times(0)).updateAcDefinitionState(any(), any(), any(), any());
@@ -122,7 +122,7 @@ class SupervisionScannerTest {
acRuntimeParameterGroup.getParticipantParameters().setMaxStatusWaitMs(-1);
supervisionScanner = new SupervisionScanner(mock(AutomationCompositionProvider.class), acDefinitionProvider,
mock(AutomationCompositionStateChangePublisher.class), mock(AutomationCompositionDeployPublisher.class),
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
supervisionScanner.run();
// set Timeout
verify(acDefinitionProvider).updateAcDefinitionState(acDefinition.getCompositionId(), acDefinition.getState(),
@@ -165,7 +165,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, createAcDefinitionProvider(),
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
// not in transition
supervisionScanner.run();
@@ -194,7 +194,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, createAcDefinitionProvider(),
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
supervisionScanner.run();
verify(automationCompositionProvider).updateAcState(any(AutomationComposition.class));
@@ -215,7 +215,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, createAcDefinitionProvider(),
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
supervisionScanner.run();
verify(automationCompositionProvider).deleteAutomationComposition(automationComposition.getInstanceId());
@@ -234,7 +234,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, createAcDefinitionProvider(),
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
supervisionScanner.run();
verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
@@ -265,12 +265,12 @@ class SupervisionScannerTest {
// verify timeout scenario
var scannerObj2 = new SupervisionScanner(automationCompositionProvider, createAcDefinitionProvider(),
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
automationComposition.setStateChangeResult(StateChangeResult.NO_ERROR);
automationComposition.setLastMsg(TimestampHelper.now());
scannerObj2.run();
- verify(automationCompositionProvider, times(1)).updateAutomationComposition(any(AutomationComposition.class));
+ verify(automationCompositionProvider, times(1)).updateAcState(any(AutomationComposition.class));
assertEquals(StateChangeResult.TIMEOUT, automationComposition.getStateChangeResult());
//already in TIMEOUT
@@ -314,7 +314,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, createAcDefinitionProvider(),
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
supervisionScanner.run();
@@ -348,9 +348,14 @@ class SupervisionScannerTest {
var automationCompositionStateChangePublisher = mock(AutomationCompositionStateChangePublisher.class);
var acRuntimeParameterGroup = CommonTestData.geParameterGroup("dbScanner");
- var supervisionScanner = new SupervisionScanner(automationCompositionProvider, createAcDefinitionProvider(),
+ var definitionTarget = createAutomationCompositionDefinition(AcTypeState.PRIMED, StateChangeResult.NO_ERROR);
+ definitionTarget.setCompositionId(compositionTargetId);
+ var acDefinitionProvider = createAcDefinitionProvider();
+ when(acDefinitionProvider.getAcDefinition(compositionTargetId)).thenReturn(definitionTarget);
+
+ var supervisionScanner = new SupervisionScanner(automationCompositionProvider, acDefinitionProvider,
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
supervisionScanner.run();
verify(automationCompositionProvider, times(0)).updateAutomationComposition(any(AutomationComposition.class));
@@ -393,7 +398,7 @@ class SupervisionScannerTest {
var supervisionScanner = new SupervisionScanner(automationCompositionProvider, createAcDefinitionProvider(),
automationCompositionStateChangePublisher, automationCompositionDeployPublisher,
- mock(ParticipantSyncPublisher.class), acRuntimeParameterGroup);
+ mock(ParticipantSyncPublisher.class), null, acRuntimeParameterGroup);
supervisionScanner.run();
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
index 77b47f4e3..7fd0aa2e2 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/comm/SupervisionMessagesTest.java
@@ -231,7 +231,7 @@ class SupervisionMessagesTest {
publisher.active(topicSink);
var automationComposition =
InstantiationUtils.getAutomationCompositionFromResource(AC_INSTANTIATION_UPDATE_JSON, "Crud");
- publisher.send(automationComposition);
+ publisher.send(automationComposition, 0);
verify(topicSink).send(anyString());
}