Add restore DB test in CSIT 95/141595/1
authorFrancescoFioraEst <francesco.fiora@est.tech>
Mon, 28 Jul 2025 15:55:03 +0000 (16:55 +0100)
committerFrancescoFioraEst <francesco.fiora@est.tech>
Mon, 28 Jul 2025 16:10:57 +0000 (17:10 +0100)
Issue-ID: POLICY-5417
Change-Id: I4b440fe79dc65bb7f3cc5bd9bf82c073e42725be
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
csit/resources/Dockerfile
csit/resources/tests/data/ac-instance-migration-restored.yaml [new file with mode: 0644]
csit/resources/tests/data/query/compositiondefinition-from.sql [new file with mode: 0644]
csit/resources/tests/data/query/compositiondefinition-to.sql [new file with mode: 0644]
csit/resources/tests/data/query/compositiondefinition-update.sql [new file with mode: 0644]
csit/resources/tests/data/query/instance.sql [new file with mode: 0644]
csit/resources/tests/data/script/execute-query.sh [new file with mode: 0755]
csit/resources/tests/policy-clamp-test.robot

index 8f0190b..dc9344e 100644 (file)
@@ -2,7 +2,7 @@ FROM nexus3.onap.org:10001/library/python:3.13-slim-bullseye
 ARG CSIT_SCRIPT=${CSIT_SCRIPT}
 ARG ROBOT_FILE=${ROBOT_FILE}
 ENV ROBOT_WORKSPACE=/opt/robotworkspace ROBOT_FILE=$ROBOT_FILE TEST_ENV=$TEST_ENV
-RUN apt-get update && apt-get install -y gcc; \
+RUN apt-get update && apt-get install -y gcc postgresql-client; \
     python3 -m pip -qq install --upgrade pip; \
     python3 -m pip -qq install --upgrade confluent-kafka; \
     python3 -m pip -qq install --upgrade --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" 'robotframework-onap==0.6.0.*' --pre; \
diff --git a/csit/resources/tests/data/ac-instance-migration-restored.yaml b/csit/resources/tests/data/ac-instance-migration-restored.yaml
new file mode 100644 (file)
index 0000000..e37706a
--- /dev/null
@@ -0,0 +1,74 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 2025 OpenInfra Foundation Europe. 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+name: Test-Instance-Migration-To
+version: 2.0.1
+compositionId: d30b8017-4d64-4693-84d7-de9c4226b9f8
+instanceId: dd36aaa4-580f-4193-a52b-37c3a955b11a
+compositionTargetId: 6c1cf107-a2ca-4485-8129-02f9fae64d64
+description: Demo automation composition instance 0
+elements:
+
+  989c62b3-8918-41b9-a747-d21eb79c6c34:
+    id: 989c62b3-8918-41b9-a747-d21eb79c6c34
+    definition:
+      name: onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement
+      version: 1.2.4
+    description: Starter Automation Composition Element for the Demo
+    properties:
+      deployTimeoutMs: 200000
+      undeployTimeoutMs: 150000
+      updateTimeoutMs: 200000
+      migrateTimeoutMs: 200000
+      deleteTimeoutMs: 100000
+      baseUrl: http://10.101.0.249:30800
+      configurationEntities:
+        - configurationEntityId:
+          myParameterToUpdate: text updated for migration
+
+  989c62b3-8918-41b9-a747-d21eb79c6c35:
+    id: 989c62b3-8918-41b9-a747-d21eb79c6c35
+    definition:
+      name: onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement
+      version: 1.2.4
+    description: Bridge Automation Composition Element for the Demo
+    properties:
+      deployTimeoutMs: 200000
+      undeployTimeoutMs: 150000
+      updateTimeoutMs: 200000
+      migrateTimeoutMs: 200000
+      deleteTimeoutMs: 100000
+      baseUrl: http://10.101.0.249:30801
+      configurationEntities:
+        - configurationEntityId:
+          myParameterToUpdate: TEXTPLACEHOLDER
+
+  989c62b3-8918-41b9-a747-d21eb79c6c37:
+    id: 989c62b3-8918-41b9-a747-d21eb79c6c37
+    definition:
+      name: onap.policy.clamp.ac.element.Sim_NewAutomationCompositionElement
+      version: 1.2.4
+    description: Sink Automation Composition Element for the Demo
+    properties:
+      deployTimeoutMs: 200000
+      undeployTimeoutMs: 150000
+      updateTimeoutMs: 200000
+      migrateTimeoutMs: 200000
+      deleteTimeoutMs: 100000
+      configurationEntities:
+        - configurationEntityId:
+          myParameterToUpdate: text updated for migration
diff --git a/csit/resources/tests/data/query/compositiondefinition-from.sql b/csit/resources/tests/data/query/compositiondefinition-from.sql
new file mode 100644 (file)
index 0000000..7f72f86
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 OpenInfra Foundation Europe. 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.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+INSERT INTO automationcompositiondefinition (compositionid, name, servicetemplate, state, statechangeresult, version, lastmsg)
+VALUES ('d30b8017-4d64-4693-84d7-de9c4226b9f8', 'Test-Migration-From', '{"tosca_definitions_version":"tosca_simple_yaml_1_3","data_types":{"onap.datatypes.ToscaConceptIdentifier:0.0.0":{"properties":{"name":{"name":"name","type":"string","type_version":"0.0.0","required":true},"version":{"name":"version","type":"string","type_version":"0.0.0","required":true}},"name":"onap.datatypes.ToscaConceptIdentifier","version":"0.0.0","derived_from":"tosca.datatypes.Root","metadata":{}}},"node_types":{"org.onap.policy.clamp.acm.Participant:1.0.1":{"properties":{"provider":{"name":"provider","type":"string","type_version":"0.0.0","required":false}},"name":"org.onap.policy.clamp.acm.Participant","version":"1.0.1","derived_from":"tosca.nodetypes.Root","metadata":{}},"org.onap.policy.clamp.acm.AutomationCompositionElement:1.0.1":{"properties":{"provider":{"name":"provider","type":"string","type_version":"0.0.0","description":"Specifies the organization that provides the automation composition element","required":false,"metadata":{"common":"true"}},"startPhase":{"name":"startPhase","type":"integer","type_version":"0.0.0","description":"A value indicating the start phase in which this automation composition element will be started, the first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped in reverse start phase order. Automation Composition Elements with the same start phase are started and stopped simultaneously","required":false,"constraints":[{"greater_or_equal":"0"}],"metadata":{"common":"true"}},"stage":{"name":"stage","type":"map","type_version":"0.0.0","description":"A map of list indicating for each operation the stages in which this automation composition element will be started, the first stage is zero. Automation Composition Elements are started in their stage order. Automation Composition Elements with the same stage are started simultaneously.","required":false}},"name":"org.onap.policy.clamp.acm.AutomationCompositionElement","version":"1.0.1","derived_from":"tosca.nodetypes.Root","metadata":{}},"org.onap.policy.clamp.acm.AutomationComposition:1.0.1":{"properties":{"provider":{"name":"provider","type":"string","type_version":"0.0.0","description":"Specifies the organization that provides the automation composition element","required":false,"metadata":{"common":"true"}},"elements":{"name":"elements","type":"list","type_version":"0.0.0","description":"Specifies a list of automation composition element definitions that make up this automation composition definition","required":true,"entry_schema":{"type":"onap.datatypes.ToscaConceptIdentifier","type_version":"0.0.0"},"metadata":{"common":"true"}}},"name":"org.onap.policy.clamp.acm.AutomationComposition","version":"1.0.1","derived_from":"tosca.nodetypes.Root","metadata":{}},"org.onap.policy.clamp.acm.SimAutomationCompositionElement:1.0.0":{"properties":{"baseUrl":{"name":"baseUrl","type":"string","type_version":"0.0.0","description":"The base URL to be prepended to each path, identifies the host for the REST endpoints.","required":true,"metadata":{"sensitive":"true"}},"httpHeaders":{"name":"httpHeaders","type":"map","type_version":"0.0.0","description":"HTTP headers to send on REST requests","required":false,"entry_schema":{"type":"string","type_version":"0.0.0"}},"configurationEntities":{"name":"configurationEntities","type":"map","type_version":"0.0.0","description":"The connfiguration entities the Automation Composition Element is managing and their associated REST requests","required":true,"entry_schema":{"type":"map","type_version":"0.0.0"}}},"name":"org.onap.policy.clamp.acm.SimAutomationCompositionElement","version":"1.0.0","derived_from":"org.onap.policy.clamp.acm.AutomationCompositionElement","metadata":{}}},"topology_template":{"node_templates":{"org.onap.policy.clamp.acm.SimParticipant:2.3.4":{"type":"org.onap.policy.clamp.acm.Participant","type_version":"1.0.1","properties":{"provider":"ONAP"},"name":"org.onap.policy.clamp.acm.SimParticipant","version":"2.3.4","metadata":{},"description":"Participant Simulator"},"onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement:1.2.3":{"type":"org.onap.policy.clamp.acm.SimAutomationCompositionElement","type_version":"1.0.0","properties":{"provider":"ONAP","startPhase":0,"stage":{"prepare":[1,2],"migrate":[1,2]}},"name":"onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement","version":"1.2.3","metadata":{},"description":"Automation composition element for the http requests of AC Element Starter microservice"},"onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement:1.2.3":{"type":"org.onap.policy.clamp.acm.SimAutomationCompositionElement","type_version":"1.0.0","properties":{"provider":"ONAP","startPhase":0,"stage":{"prepare":[0,1],"migrate":[0,1]}},"name":"onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement","version":"1.2.3","metadata":{},"description":"Automation composition element for the http requests of AC Element Bridge microservice"},"onap.policy.clamp.ac.element.Sim_SinkAutomationCompositionElement:1.2.3":{"type":"org.onap.policy.clamp.acm.SimAutomationCompositionElement","type_version":"1.0.0","properties":{"provider":"ONAP","startPhase":0,"stage":{"prepare":[0,2],"migrate":[0,2]}},"name":"onap.policy.clamp.ac.element.Sim_SinkAutomationCompositionElement","version":"1.2.3","metadata":{},"description":"Automation composition element for the http requests of AC Element Sink microservice"},"onap.policy.clamp.ac.element.AutomationCompositionDefinition:1.2.3":{"type":"org.onap.policy.clamp.acm.AutomationComposition","type_version":"1.0.1","properties":{"provider":"ONAP","elements":[{"name":"onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement","version":"1.2.3"},{"name":"onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement","version":"1.2.3"},{"name":"onap.policy.clamp.ac.element.Sim_SinkAutomationCompositionElement","version":"1.2.3"}]},"name":"onap.policy.clamp.ac.element.AutomationCompositionDefinition","version":"1.2.3","metadata":{},"description":"Automation composition for Demo"}},"policies":{}},"name":"Test-Migration-From","version":"1.0.0","metadata":{"primeTimeoutMs":200000,"deprimeTimeoutMs":100000,"compositionId":"d30b8017-4d64-4693-84d7-de9c4226b9f8"}}', 2, 0, '1.0.0', '2025-07-16 09:48:22.255172');
+
+INSERT INTO nodetemplatestate (nodetemplatestateid, compositionid, message, nodetemplate_name, nodetemplate_version, outproperties, participantid, state)
+VALUES ('27e9302f-245e-46ff-9501-ddc8f0ff515c', 'd30b8017-4d64-4693-84d7-de9c4226b9f8', 'Primed', 'onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement', '1.2.3', '{"InternalState":"PRIMED"}', '101c62b3-8918-41b9-a747-d21eb79c6c90', 2);
+
+INSERT INTO nodetemplatestate (nodetemplatestateid, compositionid, message, nodetemplate_name, nodetemplate_version, outproperties, participantid, state)
+VALUES ('68b5e9e3-1803-46e8-af0e-c3590efdc0c2', 'd30b8017-4d64-4693-84d7-de9c4226b9f8', 'Primed', 'onap.policy.clamp.ac.element.Sim_SinkAutomationCompositionElement', '1.2.3', '{"InternalState":"PRIMED"}', '101c62b3-8918-41b9-a747-d21eb79c6c90', 2);
+
+INSERT INTO nodetemplatestate (nodetemplatestateid, compositionid, message, nodetemplate_name, nodetemplate_version, outproperties, participantid, state)
+VALUES ('5c5f9e51-96c6-4626-88f9-db458cf9ef99', 'd30b8017-4d64-4693-84d7-de9c4226b9f8', 'Primed', 'onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement', '1.2.3', '{"InternalState":"PRIMED"}', '101c62b3-8918-41b9-a747-d21eb79c6c90', 2);
diff --git a/csit/resources/tests/data/query/compositiondefinition-to.sql b/csit/resources/tests/data/query/compositiondefinition-to.sql
new file mode 100644 (file)
index 0000000..7a4ab76
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 OpenInfra Foundation Europe. 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.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+INSERT INTO automationcompositiondefinition (compositionid, name, servicetemplate, state, statechangeresult, version, lastmsg)
+VALUES ('6c1cf107-a2ca-4485-8129-02f9fae64d64', 'Test-Migration-To', '{"tosca_definitions_version":"tosca_simple_yaml_1_3","data_types":{"onap.datatypes.ToscaConceptIdentifier:0.0.0":{"properties":{"name":{"name":"name","type":"string","type_version":"0.0.0","required":true},"version":{"name":"version","type":"string","type_version":"0.0.0","required":true}},"name":"onap.datatypes.ToscaConceptIdentifier","version":"0.0.0","derived_from":"tosca.datatypes.Root","metadata":{}}},"node_types":{"org.onap.policy.clamp.acm.Participant:1.0.1":{"properties":{"provider":{"name":"provider","type":"string","type_version":"0.0.0","required":false}},"name":"org.onap.policy.clamp.acm.Participant","version":"1.0.1","derived_from":"tosca.nodetypes.Root","metadata":{}},"org.onap.policy.clamp.acm.AutomationCompositionElement:1.0.1":{"properties":{"provider":{"name":"provider","type":"string","type_version":"0.0.0","description":"Specifies the organization that provides the automation composition element","required":false,"metadata":{"common":"true"}},"startPhase":{"name":"startPhase","type":"integer","type_version":"0.0.0","description":"A value indicating the start phase in which this automation composition element will be started, the first start phase is zero. Automation Composition Elements are started in their start_phase order and stopped in reverse start phase order. Automation Composition Elements with the same start phase are started and stopped simultaneously","required":false,"constraints":[{"greater_or_equal":"0"}],"metadata":{"common":"true"}},"stage":{"name":"stage","type":"map","type_version":"0.0.0","description":"A map of list indicating for each operation the stages in which this automation composition element will be started, the first stage is zero. Automation Composition Elements are started in their stage order. Automation Composition Elements with the same stage are started simultaneously.","required":false}},"name":"org.onap.policy.clamp.acm.AutomationCompositionElement","version":"1.0.1","derived_from":"tosca.nodetypes.Root","metadata":{}},"org.onap.policy.clamp.acm.AutomationComposition:1.0.1":{"properties":{"provider":{"name":"provider","type":"string","type_version":"0.0.0","description":"Specifies the organization that provides the automation composition element","required":false,"metadata":{"common":"true"}},"elements":{"name":"elements","type":"list","type_version":"0.0.0","description":"Specifies a list of automation composition element definitions that make up this automation composition definition","required":true,"entry_schema":{"type":"onap.datatypes.ToscaConceptIdentifier","type_version":"0.0.0"},"metadata":{"common":"true"}}},"name":"org.onap.policy.clamp.acm.AutomationComposition","version":"1.0.1","derived_from":"tosca.nodetypes.Root","metadata":{}},"org.onap.policy.clamp.acm.SimAutomationCompositionElement:1.0.0":{"properties":{"baseUrl":{"name":"baseUrl","type":"string","type_version":"0.0.0","description":"The base URL to be prepended to each path, identifies the host for the REST endpoints.","required":true,"metadata":{"sensitive":"true"}},"httpHeaders":{"name":"httpHeaders","type":"map","type_version":"0.0.0","description":"HTTP headers to send on REST requests","required":false,"entry_schema":{"type":"string","type_version":"0.0.0"}},"configurationEntities":{"name":"configurationEntities","type":"map","type_version":"0.0.0","description":"The connfiguration entities the Automation Composition Element is managing and their associated REST requests","required":true,"entry_schema":{"type":"map","type_version":"0.0.0"}}},"name":"org.onap.policy.clamp.acm.SimAutomationCompositionElement","version":"1.0.0","derived_from":"org.onap.policy.clamp.acm.AutomationCompositionElement","metadata":{}}},"topology_template":{"node_templates":{"org.onap.policy.clamp.acm.SimParticipant:2.3.4":{"type":"org.onap.policy.clamp.acm.Participant","type_version":"1.0.1","properties":{"provider":"ONAP"},"name":"org.onap.policy.clamp.acm.SimParticipant","version":"2.3.4","metadata":{},"description":"Participant Simulator"},"onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement:1.2.4":{"type":"org.onap.policy.clamp.acm.SimAutomationCompositionElement","type_version":"1.0.0","properties":{"provider":"ONAP","startPhase":0,"stage":{"prepare":[1,2],"migrate":[1,2]}},"name":"onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement","version":"1.2.4","metadata":{},"description":"Automation composition element for the http requests of AC Element Starter microservice"},"onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement:1.2.4":{"type":"org.onap.policy.clamp.acm.SimAutomationCompositionElement","type_version":"1.0.0","properties":{"provider":"ONAP","startPhase":0,"stage":{"prepare":[0,1],"migrate":[0,1]}},"name":"onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement","version":"1.2.4","metadata":{},"description":"Automation composition element for the http requests of AC Element Bridge microservice"},"onap.policy.clamp.ac.element.Sim_NewAutomationCompositionElement:1.2.4":{"type":"org.onap.policy.clamp.acm.SimAutomationCompositionElement","type_version":"1.0.0","properties":{"provider":"ONAP","startPhase":0,"stage":{"prepare":[0,2],"migrate":[0,2]}},"name":"onap.policy.clamp.ac.element.Sim_NewAutomationCompositionElement","version":"1.2.4","metadata":{},"description":"Automation composition element for the http requests of AC Element Sink microservice"},"onap.policy.clamp.ac.element.AutomationCompositionDefinition:1.2.4":{"type":"org.onap.policy.clamp.acm.AutomationComposition","type_version":"1.0.1","properties":{"provider":"ONAP","elements":[{"name":"onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement","version":"1.2.4"},{"name":"onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement","version":"1.2.4"},{"name":"onap.policy.clamp.ac.element.Sim_NewAutomationCompositionElement","version":"1.2.4"}]},"name":"onap.policy.clamp.ac.element.AutomationCompositionDefinition","version":"1.2.4","metadata":{},"description":"Automation composition for Demo"}},"policies":{}},"name":"Test-Migration-To","version":"1.0.0","metadata":{"compositionId":"6c1cf107-a2ca-4485-8129-02f9fae64d64"}}', 2, 0, '1.0.0', '2025-07-16 09:48:44.215309');
+
+INSERT INTO nodetemplatestate (nodetemplatestateid, compositionid, message, nodetemplate_name, nodetemplate_version, outproperties, participantid, state)
+VALUES ('799543ff-de85-4835-bf32-2ff5f61d0dfe', '6c1cf107-a2ca-4485-8129-02f9fae64d64', 'Primed', 'onap.policy.clamp.ac.element.Sim_NewAutomationCompositionElement', '1.2.4', '{"InternalState":"PRIMED"}', '101c62b3-8918-41b9-a747-d21eb79c6c90', 2);
+
+INSERT INTO nodetemplatestate (nodetemplatestateid, compositionid, message, nodetemplate_name, nodetemplate_version, outproperties, participantid, state)
+VALUES ('3d34ca20-1b16-4f2c-971a-6ed52a0dafff', '6c1cf107-a2ca-4485-8129-02f9fae64d64', 'Primed', 'onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement', '1.2.4', '{"InternalState":"PRIMED"}', '101c62b3-8918-41b9-a747-d21eb79c6c90', 2);
+
+INSERT INTO nodetemplatestate (nodetemplatestateid, compositionid, message, nodetemplate_name, nodetemplate_version, outproperties, participantid, state)
+VALUES ('d6a4a446-cfcb-45ad-a63e-3c6393471e42', '6c1cf107-a2ca-4485-8129-02f9fae64d64', 'Primed', 'onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement', '1.2.4', '{"InternalState":"PRIMED"}', '101c62b3-8918-41b9-a747-d21eb79c6c90', 2);
+
diff --git a/csit/resources/tests/data/query/compositiondefinition-update.sql b/csit/resources/tests/data/query/compositiondefinition-update.sql
new file mode 100644 (file)
index 0000000..a76716a
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 OpenInfra Foundation Europe. 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.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+UPDATE nodetemplatestate
+  SET outproperties = '{"InternalState":"PRIMED","myParameterToUpdate":"MyTextUpdated"}'
+  WHERE nodetemplatestateid = '3d34ca20-1b16-4f2c-971a-6ed52a0dafff';
+
+UPDATE automationcompositiondefinition
+  SET revisionid = 'adc5e211-84a7-448f-8749-78a195f51f64'
+  WHERE compositionid = '6c1cf107-a2ca-4485-8129-02f9fae64d64';
diff --git a/csit/resources/tests/data/query/instance.sql b/csit/resources/tests/data/query/instance.sql
new file mode 100644 (file)
index 0000000..d333446
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 OpenInfra Foundation Europe. 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.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+INSERT INTO automationcomposition (instanceid, compositionid, compositiontargetid, deploystate, description, lockstate, name, statechangeresult, version, lastmsg, phase, substate, revisionId)
+VALUES ('dd36aaa4-580f-4193-a52b-37c3a955b11a', 'd30b8017-4d64-4693-84d7-de9c4226b9f8', NULL, 0, 'Demo automation composition instance 0', 0, 'Test-Instance-Migration-From', 0, '2.0.1', '2025-07-16 09:53:15.512496', NULL, 0, 'e999d17c-5b80-476f-96cc-1acfb38194ee');
+
+INSERT INTO automationcompositionelement (elementid, definition_name, definition_version, deploystate, description, instanceid, lockstate, message, operationalstate, outproperties, participantid, properties, restarting, usestate, substate, stage)
+VALUES ('989c62b3-8918-41b9-a747-d21eb79c6c36', 'onap.policy.clamp.ac.element.Sim_SinkAutomationCompositionElement', '1.2.3', 0, 'Sink Automation Composition Element for the Demo', 'dd36aaa4-580f-4193-a52b-37c3a955b11a', 0, 'Deployed', NULL, '{"InternalState":"DEPLOYED"}', '101c62b3-8918-41b9-a747-d21eb79c6c90', '{"deployTimeoutMs":200000,"undeployTimeoutMs":150000,"updateTimeoutMs":200000,"migrateTimeoutMs":200000,"deleteTimeoutMs":100000,"baseUrl":"ENCRYPTED:ZuDP803svc1ThgeVcYeQvA0kL8gpz2Qzg9unk3zm+XSi8RSTlDQ2qgSzROz7QOit","httpHeaders":{"Content-Type":"application/json","Authorization":"Basic YWNtVXNlcjp6YiFYenRHMzQ="},"configurationEntities":[{"configurationEntityId":{"name":"onap.policy.clamp.ac.sink","version":"1.0.0"},"restSequence":[{"restRequestId":{"name":"request3","version":"1.0.1"},"httpMethod":"POST","path":"/onap/policy/clamp/acelement/v2/activate","body":"{ \"receiverId\": { \"name\": \"onap.policy.clamp.ac.sink\", \"version\": \"1.0.0\" }, \"timerMs\": 20000, \"elementType\": \"SINK\", \"topicParameterGroup\": { \"server\": \"message-router\", \"listenerTopic\": \"POLICY_UPDATE_MSG\", \"publisherTopic\": \"AC_ELEMENT_MSG\", \"fetchTimeout\": 15000, \"topicCommInfrastructure\": \"dmaap\" } }","expectedResponse":201}],"myParameterToUpdate":"text"}]}', NULL, NULL, 0, NULL);
+
+INSERT INTO automationcompositionelement (elementid, definition_name, definition_version, deploystate, description, instanceid, lockstate, message, operationalstate, outproperties, participantid, properties, restarting, usestate, substate, stage)
+VALUES ('989c62b3-8918-41b9-a747-d21eb79c6c34', 'onap.policy.clamp.ac.element.Sim_StarterAutomationCompositionElement', '1.2.3', 0, 'Starter Automation Composition Element for the Demo', 'dd36aaa4-580f-4193-a52b-37c3a955b11a', 0, 'Deployed', NULL, '{"InternalState":"DEPLOYED"}', '101c62b3-8918-41b9-a747-d21eb79c6c90', '{"deployTimeoutMs":200000,"undeployTimeoutMs":150000,"updateTimeoutMs":200000,"migrateTimeoutMs":200000,"deleteTimeoutMs":100000,"baseUrl":"ENCRYPTED:1IPD8QRnRhnFlUfrHIoRRuzPYHV0z88DhwXYa+KhZqv6iUh1JiVoN28oAIYFq1i6","httpHeaders":{"Content-Type":"application/json","Authorization":"Basic YWNtVXNlcjp6YiFYenRHMzQ="},"configurationEntities":[{"configurationEntityId":{"name":"onap.policy.clamp.ac.starter","version":"1.0.0"},"restSequence":[{"restRequestId":{"name":"request1","version":"1.0.1"},"httpMethod":"POST","path":"/onap/policy/clamp/acelement/v2/activate","body":"{ \"receiverId\": { \"name\": \"onap.policy.clamp.ac.startertobridge\", \"version\": \"1.0.0\" }, \"timerMs\": 20000, \"elementType\": \"STARTER\", \"topicParameterGroup\": { \"server\": \"message-router:3904\", \"listenerTopic\": \"POLICY_UPDATE_MSG\", \"publisherTopic\": \"AC_ELEMENT_MSG\", \"fetchTimeout\": 15000, \"topicCommInfrastructure\": \"dmaap\" } }","expectedResponse":201}],"myParameterToUpdate":"text"}]}', NULL, NULL, 0, NULL);
+
+INSERT INTO automationcompositionelement (elementid, definition_name, definition_version, deploystate, description, instanceid, lockstate, message, operationalstate, outproperties, participantid, properties, restarting, usestate, substate, stage)
+VALUES ('989c62b3-8918-41b9-a747-d21eb79c6c35', 'onap.policy.clamp.ac.element.Sim_BridgeAutomationCompositionElement', '1.2.3', 0, 'Bridge Automation Composition Element for the Demo', 'dd36aaa4-580f-4193-a52b-37c3a955b11a', 0, 'Deployed', NULL, '{"InternalState":"DEPLOYED"}', '101c62b3-8918-41b9-a747-d21eb79c6c90', '{"deployTimeoutMs":200000,"undeployTimeoutMs":150000,"updateTimeoutMs":200000,"migrateTimeoutMs":200000,"deleteTimeoutMs":100000,"baseUrl":"ENCRYPTED:Q4bNY29WKbV4o/vi15DMyWnWla6lTTwbn5ZRfR1nspd5xL9vDvtl8FYBA7Sj6mHI","httpHeaders":{"Content-Type":"application/json","Authorization":"Basic YWNtVXNlcjp6YiFYenRHMzQ="},"configurationEntities":[{"configurationEntityId":{"name":"onap.policy.clamp.ac.bridge","version":"1.0.0"},"restSequence":[{"restRequestId":{"name":"request2","version":"1.0.1"},"httpMethod":"POST","path":"/onap/policy/clamp/acelement/v2/activate","body":"{ \"receiverId\": { \"name\": \"onap.policy.clamp.ac.bridgetosink\", \"version\": \"1.0.0\" }, \"timerMs\": 20000, \"elementType\": \"BRIDGE\", \"topicParameterGroup\": { \"server\": \"message-router:3904\", \"listenerTopic\": \"POLICY_UPDATE_MSG\", \"publisherTopic\": \"AC_ELEMENT_MSG\", \"fetchTimeout\": 15000, \"topicCommInfrastructure\": \"dmaap\" } }","expectedResponse":201}],"myParameterToUpdate":"text"}]}', NULL, NULL, 0, NULL);
diff --git a/csit/resources/tests/data/script/execute-query.sh b/csit/resources/tests/data/script/execute-query.sh
new file mode 100755 (executable)
index 0000000..13b998e
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+# ============LICENSE_START====================================================
+# Copyright (C) 2025 OpenInfra Foundation Europe. 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END======================================================
+
+export PGPASSWORD=policy_user
+
+scriptPath=$1
+
+PSQL="psql -h postgres -U policy_user -w -d clampacm"
+${PSQL} <"${scriptPath}"
+rc=$?
+if [ ${rc} -ne 0 ]; then
+  return ${rc}
+fi
+
+exit 0
index 99ab4a0..c9d7f9a 100644 (file)
@@ -5,6 +5,7 @@ Library     OperatingSystem
 Library     String
 Library     json
 Library     yaml
+Library    Process
 Resource    common-library.robot
 
 *** Test Cases ***
@@ -37,6 +38,48 @@ RegisterParticipants
     Log    Received response from runtime acm ${resp.text}
     Should Be Equal As Strings    ${resp.status_code}     202
 
+InsertDataIntoDatabase
+    [Documentation]  Insert restored data into the Database.
+    ${result}=    Run Process    ${CURDIR}/data/script/execute-query.sh    ${CURDIR}/data/query/compositiondefinition-from.sql
+    Should Be Equal As Strings    ${result.rc}     0
+    ${result}=    Run Process    ${CURDIR}/data/script/execute-query.sh    ${CURDIR}/data/query/compositiondefinition-to.sql
+    Should Be Equal As Strings    ${result.rc}     0
+    ${result}=    Run Process    ${CURDIR}/data/script/execute-query.sh    ${CURDIR}/data/query/instance.sql
+    Should Be Equal As Strings    ${result.rc}     0
+
+AcMigrationRestored
+    [Documentation]  Migration of an automation composition restored.
+    set Suite variable  ${compositionIdRestored}  d30b8017-4d64-4693-84d7-de9c4226b9f8
+    set Suite variable  ${InstanceIdRestored}  dd36aaa4-580f-4193-a52b-37c3a955b11a
+    set Suite variable  ${compositionTargetIdRestored}  6c1cf107-a2ca-4485-8129-02f9fae64d64
+    SetParticipantSimSuccess
+    ${auth}=    ClampAuth
+    ${postyaml}=  Get file  ${CURDIR}/data/ac-instance-migration-restored.yaml
+    ${resp}=   MakeYamlPostRequest  ACM  ${POLICY_RUNTIME_ACM_IP}  /onap/policy/clamp/acm/v2/compositions/${compositionIdRestored}/instances  ${postyaml}  ${auth}
+    Should Be Equal As Strings    ${resp.status_code}     200
+    Wait Until Keyword Succeeds    2 min    5 sec    VerifyDeployStatus  ${compositionTargetIdRestored}  ${InstanceIdRestored}  DEPLOYED
+
+UpdateDataDatabase
+    [Documentation]  Update restored data into the Database.
+    ${result}=    Run Process    ${CURDIR}/data/script/execute-query.sh    ${CURDIR}/data/query/compositiondefinition-update.sql
+    Should Be Equal As Strings    ${result.rc}     0
+
+ReviewAutomationCompositionRestored
+    [Documentation]  Review automation composition restored.
+    ${postjson}=  Get file  ${CURDIR}/data/ReviewAC.json
+    ChangeStatusAutomationComposition  ${compositionTargetIdRestored}   ${InstanceIdRestored}  ${postjson}
+    Wait Until Keyword Succeeds    10 min    5 sec    VerifySubStatus  ${compositionTargetIdRestored}  ${InstanceIdRestored}
+    VerifyCompositionParticipantSim   'MyTextUpdated'
+
+AcDeleteRestored
+    [Documentation]  Undeploy and delete of an automation composition restored.
+    UndeployAndDeleteAutomationComposition  ${compositionTargetIdRestored}  ${InstanceIdRestored}
+
+DeleteACDefinitionsRestored
+    [Documentation]  Deprime and delete of the compositions definition restored.
+    DePrimeAndDeleteACDefinition   ${compositionIdRestored}
+    DePrimeAndDeleteACDefinition   ${compositionTargetIdRestored}
+
 CommissionAcDefinitionTimeout
     [Documentation]  Commission automation composition definition Timeout.
     ${postyaml}=  Get file  ${CURDIR}/data/ac-definition-timeout.yaml
@@ -53,10 +96,7 @@ TimeoutPrimeACDefinition
 DeleteACDefinitionTimeout
     [Documentation]  DePrime and Delete automation composition definition Timeout.
     SetParticipantSimSuccess
-    ${postjson}=  Get file  ${CURDIR}/data/ACDepriming.json
-    PrimeACDefinition  ${postjson}  ${compositionTimeoutId}
-    Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionTimeoutId}  COMMISSIONED
-    DeleteACDefinition  ${compositionTimeoutId}
+    DePrimeAndDeleteACDefinition  ${compositionTimeoutId}
 
 CommissionAutomationCompositionSimple
     [Documentation]  Commission simple automation composition definition.
@@ -99,15 +139,9 @@ UnInstantiateAutomationCompositionSimple
     DeleteAutomationComposition  ${simpleCompositionId}  ${simpleInstanceId}
     Wait Until Keyword Succeeds    1 min    5 sec    VerifyUninstantiated  ${simpleCompositionId}
 
-DePrimeACDefinitionSimple
-    [Documentation]  DePrime simple automation composition definition
-    ${postjson}=  Get file  ${CURDIR}/data/ACDepriming.json
-    PrimeACDefinition  ${postjson}  ${simpleCompositionId}
-    Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${simpleCompositionId}  COMMISSIONED
-
 DeleteACDefinitionSimple
-    [Documentation]  Delete simple automation composition definition.
-    DeleteACDefinition  ${simpleCompositionId}
+    [Documentation]  DePrime and Delete simple automation composition definition.
+    DePrimeAndDeleteACDefinition  ${simpleCompositionId}
 
 CommissionAutomationComposition
     [Documentation]  Commission automation composition definition.
@@ -191,11 +225,7 @@ DeployAutomationCompositionTimeout
 DeleteAutomationCompositionTimeout
     [Documentation]  Delete automation composition timeout.
     SetParticipantSimSuccess
-    ${postjson}=  Get file  ${CURDIR}/data/UndeployAC.json
-    ChangeStatusAutomationComposition  ${compositionFromId}  ${instanceTimeoutId}  ${postjson}
-    Wait Until Keyword Succeeds    10 min    5 sec    VerifyDeployStatus  ${compositionFromId}  ${instanceTimeoutId}  UNDEPLOYED
-    DeleteAutomationComposition  ${compositionFromId}  ${instanceTimeoutId}
-    Wait Until Keyword Succeeds    1 min    5 sec    VerifyUninstantiated  ${compositionFromId}
+    UndeployAndDeleteAutomationComposition  ${compositionFromId}  ${instanceTimeoutId}
 
 InstantiateAutomationCompositionMigrationFrom
     [Documentation]  Instantiate automation composition migration.
@@ -380,11 +410,10 @@ FailAutomationCompositionMigration
     Should Be Equal As Strings    ${resp.status_code}     200
     Wait Until Keyword Succeeds    2 min    5 sec    VerifyStateChangeResult  ${compositionToId}  ${instanceMigrationId}  FAILED
 
-UnDeployAutomationComposition
-    [Documentation]  UnDeploy automation composition.
-    ${postjson}=  Get file  ${CURDIR}/data/UndeployAC.json
-    ChangeStatusAutomationComposition  ${compositionId}   ${instanceId}  ${postjson}
-    Wait Until Keyword Succeeds    10 min    5 sec    VerifyDeployStatus  ${compositionId}  ${instanceId}  UNDEPLOYED
+UnInstantiateAutomationComposition
+    [Documentation]  UnDeploy and Delete automation composition instance.
+    SetParticipantSimSuccess
+    UndeployAndDeleteAutomationComposition  ${compositionId}  ${instanceId}
 
 FailUnDeployAutomationCompositionMigrationTo
     [Documentation]  Fail UnDeploy automation composition migrated.
@@ -400,11 +429,6 @@ UnDeployAutomationCompositionMigrationTo
     ChangeStatusAutomationComposition  ${compositionToId}   ${instanceMigrationId}  ${postjson}
     Wait Until Keyword Succeeds    2 min    5 sec    VerifyDeployStatus  ${compositionToId}  ${instanceMigrationId}  UNDEPLOYED
 
-UnInstantiateAutomationComposition
-    [Documentation]  Delete automation composition instance.
-    DeleteAutomationComposition  ${compositionId}  ${instanceId}
-    Wait Until Keyword Succeeds    1 min    5 sec    VerifyUninstantiated  ${compositionId}
-
 FailUnInstantiateAutomationCompositionMigrationTo
     [Documentation]  Fail Delete automation composition instance migrated.
     SetParticipantSimFail
@@ -476,18 +500,10 @@ FailRollbackAutomationComposition
     Should Be Equal As Strings    ${resp.status_code}     202
     Wait Until Keyword Succeeds    2 min    5 sec    VerifyStateChangeResult  ${compositionFromId}  ${instanceMigrationId}  FAILED
 
-UnDeployAutomationCompositionRollback
-    [Documentation]  UnDeploy automation composition in fail rollback.
-    SetParticipantSimSuccess
-    ${auth}=    ClampAuth
-    ${postjson}=  Get file  ${CURDIR}/data/UndeployAC.json
-    ChangeStatusAutomationComposition  ${compositionFromId}   ${instanceMigrationId}  ${postjson}
-    Wait Until Keyword Succeeds    2 min    5 sec    VerifyDeployStatus  ${compositionFromId}  ${instanceMigrationId}  UNDEPLOYED
-
 UnInstantiateAutomationCompositionRollback
-    [Documentation]  Delete automation composition instance in fail rollback.
-    DeleteAutomationComposition  ${compositionFromId}  ${instanceMigrationId}
-    Wait Until Keyword Succeeds    1 min    5 sec    VerifyUninstantiated  ${compositionFromId}
+    [Documentation]  Undeploy and Delete automation composition instance in fail rollback.
+    SetParticipantSimSuccess
+    UndeployAndDeleteAutomationComposition  ${compositionFromId}  ${instanceMigrationId}
 
 FailDePrimeACDefinitionsFrom
     [Documentation]  Fail DePrime automation composition definition migration From.
@@ -496,36 +512,18 @@ FailDePrimeACDefinitionsFrom
     PrimeACDefinition  ${postjson}  ${compositionFromId}
     Wait Until Keyword Succeeds    2 min    5 sec    VerifyStateChangeResultPriming  ${compositionFromId}   FAILED
 
-DePrimeACDefinitionsFrom
-    [Documentation]  DePrime automation composition definition migration From.
+DeleteACDefinitionFrom
+    [Documentation]  DePrime and Delete automation composition definition migration From.
     SetParticipantSimSuccess
-    ${postjson}=  Get file  ${CURDIR}/data/ACDepriming.json
-    PrimeACDefinition  ${postjson}  ${compositionFromId}
-    Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionFromId}  COMMISSIONED
-
-DePrimeACDefinitions
-    [Documentation]  DePrime automation composition definition
-    ${postjson}=  Get file  ${CURDIR}/data/ACDepriming.json
-    PrimeACDefinition  ${postjson}  ${compositionId}
-    Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionId}  COMMISSIONED
-
-DePrimeACDefinitionsTo
-    [Documentation]  DePrime automation composition definition migration To.
-    ${postjson}=  Get file  ${CURDIR}/data/ACDepriming.json
-    PrimeACDefinition  ${postjson}  ${compositionToId}
-    Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionToId}  COMMISSIONED
+    DePrimeAndDeleteACDefinition  ${compositionFromId}
 
 DeleteACDefinitions
-    [Documentation]  Delete automation composition definition.
-    DeleteACDefinition  ${compositionId}
-
-DeleteACDefinitionFrom
-    [Documentation]  Delete automation composition definition migration From.
-    DeleteACDefinition  ${compositionFromId}
+    [Documentation]  DePrime and Delete automation composition definition.
+    DePrimeAndDeleteACDefinition  ${compositionId}
 
 DeleteACDefinitionTo
-    [Documentation]  Delete automation composition definition migration To.
-    DeleteACDefinition  ${compositionToId}
+    [Documentation]  DePrime and Delete automation composition definition migration To.
+    DePrimeAndDeleteACDefinition  ${compositionToId}
 
 *** Keywords ***
 
@@ -668,6 +666,15 @@ VerifyRollbackElementsSim
     Should Not Match Regexp  ${respstring}  Sim_NewAutomationCompositionElement
     Should Match Regexp  ${respstring}  Sim_SinkAutomationCompositionElement
 
+VerifyCompositionParticipantSim
+    [Arguments]  ${textToFind}
+    [Documentation]  Query composition on Participant Simulator
+    ${auth}=    ParticipantAuth
+    ${resp}=    MakeGetRequest  participant  ${POLICY_PARTICIPANT_SIM_IP}  /onap/policy/simparticipant/v2/compositiondatas  ${auth}
+    Should Be Equal As Strings    ${resp.status_code}     200
+    ${respstring}   Convert To String   ${resp.json()}
+    Should Match Regexp  ${respstring}  ${textToFind}
+
 VerifyParticipantSim
     [Arguments]  ${theInstanceId}  ${textToFind}
     [Documentation]  Query on Participant Simulator
@@ -730,6 +737,13 @@ MakeCommissionAcDefinition
     Should Be Equal As Strings    ${resp.status_code}     201
     RETURN  ${respyaml["compositionId"]}
 
+DePrimeAndDeleteACDefinition
+    [Arguments]   ${compositionId}
+    ${postjson}=  Get file  ${CURDIR}/data/ACDepriming.json
+    PrimeACDefinition  ${postjson}  ${compositionId}
+    Wait Until Keyword Succeeds    2 min    5 sec    VerifyPriming  ${compositionId}  COMMISSIONED
+    DeleteACDefinition  ${compositionId}
+
 PrimeACDefinition
     [Arguments]   ${postjson}  ${compositionId}
     ${auth}=    ClampAuth
@@ -780,6 +794,14 @@ DeleteAutomationComposition
     Log    Received response from runtime acm ${resp.text}
     Should Be Equal As Strings    ${resp.status_code}     202
 
+UndeployAndDeleteAutomationComposition
+    [Arguments]  ${compositionId}  ${instanceId}
+    ${postjson}=  Get file  ${CURDIR}/data/UndeployAC.json
+    ChangeStatusAutomationComposition  ${compositionId}   ${instanceId}  ${postjson}
+    Wait Until Keyword Succeeds    3 min    5 sec    VerifyDeployStatus  ${compositionId}  ${instanceId}  UNDEPLOYED
+    DeleteAutomationComposition  ${compositionId}  ${instanceId}
+    Wait Until Keyword Succeeds    1 min    5 sec    VerifyUninstantiated  ${compositionId}
+
 MakePostRequest
     [Arguments]  ${name}  ${domain}  ${url}  ${auth}
     Log    Creating session http://${domain}