From da68bbb77800f20e283e6fe0c8898a44e479027a Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Tue, 9 Dec 2025 17:39:12 +0100 Subject: [PATCH 1/8] feat: new test for inclusive --- .../UpdateBatchEntities/D014_01_inc.robot | 70 +++++++++++++++++++ .../Provision/D014_01_inc.json | 43 ++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot create mode 100644 doc/files/DistributedOperations/Provision/D014_01_inc.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot new file mode 100644 index 00000000..9844b8b7 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot @@ -0,0 +1,70 @@ +*** Settings *** +Documentation Verify that, when one has an inclusive registration on a Context Broker with redirectionOps, one is able to update a batch of entities on a Context Source too + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Test Setup Setup Registration And Start Context Source Mock Server +Test Teardown Delete Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_payload_filename} vehicle-simple-attributes.jsonld +${update_fragment_filename} fragmentEntities/vehicle-brandname-complete-fragment.jsonld +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D014_01_inc Update Batch Entities without noOverwrite Option + [Documentation] Check that if one request the Context Broker to update a batch of entities that match an inclusive registration, they are updated on the Context Source too + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 additive-inclusive 4_3_6_2 5_6_9 + + ${fragment_entity1}= Load Entity ${update_fragment_filename} ${entity_id1} + ${fragment_entity2}= Load Entity ${update_fragment_filename} ${entity_id2} + @{entities_to_be_updated}= Create List ${fragment_entity1} ${fragment_entity2} + @{entities_ids_to_be_updated}= Create List ${entity_id1} ${entity_id2} + + Set Stub Reply POST /ngsi-ld/v1/entityOperations/update 204 + ${response}= Batch Update Entities @{entities_to_be_updated} + + @{outdated_entities}= Create List ${fragment_entity1} ${fragment_entity2} + ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_updated} + ${response}= Query Entities + ... entity_ids=${expected_entities_ids} + ... entity_types=Vehicle + ... context=${ngsild_test_suite_context} + ... accept=${CONTENT_TYPE_LD_JSON} + + Should Not Be Equal ${outdated_entities} ${response.json()} + +*** Keywords *** +Setup Registration And Start Context Source Mock Server + ${entity_id1}= Generate Random Vehicle Entity Id + Set Test Variable ${entity_id1} + ${entity_id2}= Generate Random Vehicle Entity Id + Set Test Variable ${entity_id2} + + ${response}= Create Entity ${entity_payload_filename} ${entity_id1} + Check Response Status Code 201 ${response.status_code} + ${response}= Create Entity ${entity_payload_filename} ${entity_id2} + Check Response Status Code 201 ${response.status_code} + + ${registration_id}= Generate Random CSR Id + Set Suite Variable ${registration_id} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_id=${EMPTY} + ${response1}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response1.status_code} + Start Context Source Mock Server + +Delete Registration And Stop Context Source Mock Server + @{entities_ids_to_be_deleted}= Create List ${entity_id1} ${entity_id2} + Batch Delete Entities entities_ids_to_be_deleted=@{entities_ids_to_be_deleted} + Delete Context Source Registration ${registration_id} + Stop Context Source Mock Server diff --git a/doc/files/DistributedOperations/Provision/D014_01_inc.json b/doc/files/DistributedOperations/Provision/D014_01_inc.json new file mode 100644 index 00000000..b75055f5 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D014_01_inc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_01_inc", + "test_objective": "Verify that, when one has an inclusive registration on a Context Broker with redirectionOps, one is able to update a batch of entities on a Context Source too", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.2, 5.6.9", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.2", + "5.6.9" + ], + "pics_selection": "", + "keywords": [ + "Setup Registration And Start Context Source Mock Server", + "Delete Registration And Stop Context Source Mock Server" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing a Context Source Registration \n with id equal to ${registration_id}\n and payload set to ${registration_payload_file_path}\n and the SUT containing a Context Source Mock Server\n}", + "test_cases": [ + { + "name": "D014_01_inc Update Batch Entities without noOverwrite Option", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_01_inc", + "doc": "Check that if one request the Context Broker to update a batch of entities that match an inclusive registration, they are updated on the Context Source too", + "tags": [ + "4_3_3", + "4_3_6_2", + "5_6_9", + "additive-inclusive", + "cf_06", + "dist-ops", + "since_v1.6.1" + ], + "setup": "Setup Registration And Start Context Source Mock Server", + "teardown": "Delete Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/BatchEntities/UpdateBatchEntities", + "robotfile": "D014_01_inc" +} \ No newline at end of file -- GitLab From 942cd26c9cd0aa027a9b92db8b0b6e2c6f9347ae Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Fri, 12 Dec 2025 09:57:28 +0100 Subject: [PATCH 2/8] feat: add new test for inclusive --- .../UpdateBatchEntities/D014_02_inc.robot | 74 +++++++++++++++++++ .../Provision/D014_02_inc.json | 43 +++++++++++ 2 files changed, 117 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot create mode 100644 doc/files/DistributedOperations/Provision/D014_02_inc.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot new file mode 100644 index 00000000..a7c32d1a --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot @@ -0,0 +1,74 @@ +*** Settings *** +Documentation Check that, given an inclusive registration with the noOverwrite flag, updating a batch entities creates the new attributes in the Context Source accordingly but does not modify existing ones. + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Test Setup Setup Registration And Start Context Source Mock Server +Test Teardown Delete Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_payload_filename} vehicle-simple-attributes.jsonld +${update_fragment_filename} fragmentEntities/vehicle-speed-isParked-fragment.json +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D014_02_inc Update Batch Entities With The noOverwrite Option + [Documentation] Check that if one request the Context Broker to update a batch of entities that match an inclusive registration, they are updated on the Context Source too + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 additive-inclusive 4_3_6_2 5_6_9 + + ${fragment_entity1}= Load Entity ${update_fragment_filename} ${entity_id1} + ${fragment_entity2}= Load Entity ${update_fragment_filename} ${entity_id2} + @{entities_to_be_updated}= Create List ${fragment_entity1} ${fragment_entity2} + @{entities_ids_to_be_updated}= Create List ${entity_id1} ${entity_id2} + + Set Stub Reply POST /ngsi-ld/v1/entityOperations/update 204 + ${response}= Batch Update Entities @{entities_to_be_updated} overwrite_option=noOverwrite + + @{outdated_entities}= Create List ${fragment_entity1} ${fragment_entity2} + ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_updated} + ${response}= Query Entities + ... entity_ids=${expected_entities_ids} + ... entity_types=Vehicle + ... context=${ngsild_test_suite_context} + ... accept=${CONTENT_TYPE_LD_JSON} + + ${stub}= Get Request Url Params options + Should Contain ${stub} noOverwrite + + Should Not Be Equal ${outdated_entities} ${response.json()} + Should Not Contain ${response.json()} speed + +*** Keywords *** +Setup Registration And Start Context Source Mock Server + ${entity_id1}= Generate Random Vehicle Entity Id + Set Test Variable ${entity_id1} + ${entity_id2}= Generate Random Vehicle Entity Id + Set Test Variable ${entity_id2} + + ${response}= Create Entity ${entity_payload_filename} ${entity_id1} + Check Response Status Code 201 ${response.status_code} + ${response}= Create Entity ${entity_payload_filename} ${entity_id2} + Check Response Status Code 201 ${response.status_code} + + ${registration_id}= Generate Random CSR Id + Set Suite Variable ${registration_id} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_id=${EMPTY} + ${response1}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response1.status_code} + Start Context Source Mock Server + +Delete Registration And Stop Context Source Mock Server + @{entities_ids_to_be_deleted}= Create List ${entity_id1} ${entity_id2} + Batch Delete Entities entities_ids_to_be_deleted=@{entities_ids_to_be_deleted} + Delete Context Source Registration ${registration_id} + Stop Context Source Mock Server diff --git a/doc/files/DistributedOperations/Provision/D014_02_inc.json b/doc/files/DistributedOperations/Provision/D014_02_inc.json new file mode 100644 index 00000000..dc23f6d3 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D014_02_inc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_02_inc", + "test_objective": "Check that, given an inclusive registration with the noOverwrite flag, updating a batch entities creates the new attributes in the Context Source accordingly but does not modify existing ones.", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.2, 5.6.9", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.2", + "5.6.9" + ], + "pics_selection": "", + "keywords": [ + "Setup Registration And Start Context Source Mock Server", + "Delete Registration And Stop Context Source Mock Server" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing a Context Source Registration \n with id equal to ${registration_id}\n and payload set to ${registration_payload_file_path}\n and the SUT containing a Context Source Mock Server\n}", + "test_cases": [ + { + "name": "D014_02_inc Update Batch Entities With The noOverwrite Option", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_02_inc", + "doc": "Check that if one request the Context Broker to update a batch of entities that match an inclusive registration, they are updated on the Context Source too", + "tags": [ + "4_3_3", + "4_3_6_2", + "5_6_9", + "additive-inclusive", + "cf_06", + "dist-ops", + "since_v1.6.1" + ], + "setup": "Setup Registration And Start Context Source Mock Server", + "teardown": "Delete Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/BatchEntities/UpdateBatchEntities", + "robotfile": "D014_02_inc" +} \ No newline at end of file -- GitLab From b585ded9a0f042a1af9fceabe2dffc368bd5de2a Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Tue, 16 Dec 2025 17:51:24 +0100 Subject: [PATCH 3/8] fix: improve test logic --- .../UpdateBatchEntities/D014_01_inc.robot | 30 ++++++++-------- .../UpdateBatchEntities/D014_02_inc.robot | 36 ++++++++++--------- ...icle-idpattern-with-redirection-ops.jsonld | 20 +++++++++++ 3 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 data/csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot index 9844b8b7..aa6974bb 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot @@ -16,22 +16,24 @@ Test Teardown Delete Registration And Stop Context Source Mock Server *** Variables *** ${entity_payload_filename} vehicle-simple-attributes.jsonld ${update_fragment_filename} fragmentEntities/vehicle-brandname-complete-fragment.jsonld -${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld +${entity_pattern} urn:ngsi-ld:Vehicle:* +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld *** Test Cases *** D014_01_inc Update Batch Entities without noOverwrite Option [Documentation] Check that if one request the Context Broker to update a batch of entities that match an inclusive registration, they are updated on the Context Source too [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 additive-inclusive 4_3_6_2 5_6_9 - ${fragment_entity1}= Load Entity ${update_fragment_filename} ${entity_id1} - ${fragment_entity2}= Load Entity ${update_fragment_filename} ${entity_id2} - @{entities_to_be_updated}= Create List ${fragment_entity1} ${fragment_entity2} - @{entities_ids_to_be_updated}= Create List ${entity_id1} ${entity_id2} + ${first_fragment_entity}= Load Entity ${update_fragment_filename} ${first_entity_id} + ${second_fragment_entity}= Load Entity ${update_fragment_filename} ${second_entity_id} + @{entities_to_be_updated}= Create List ${first_fragment_entity} ${second_fragment_entity} + @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} Set Stub Reply POST /ngsi-ld/v1/entityOperations/update 204 ${response}= Batch Update Entities @{entities_to_be_updated} + Check Response Status Code 204 ${response.status_code} - @{outdated_entities}= Create List ${fragment_entity1} ${fragment_entity2} + @{outdated_entities}= Create List ${first_fragment_entity} ${second_fragment_entity} ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_updated} ${response}= Query Entities ... entity_ids=${expected_entities_ids} @@ -43,14 +45,14 @@ D014_01_inc Update Batch Entities without noOverwrite Option *** Keywords *** Setup Registration And Start Context Source Mock Server - ${entity_id1}= Generate Random Vehicle Entity Id - Set Test Variable ${entity_id1} - ${entity_id2}= Generate Random Vehicle Entity Id - Set Test Variable ${entity_id2} + ${first_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${first_entity_id} + ${second_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${second_entity_id} - ${response}= Create Entity ${entity_payload_filename} ${entity_id1} + ${response}= Create Entity ${entity_payload_filename} ${first_entity_id} Check Response Status Code 201 ${response.status_code} - ${response}= Create Entity ${entity_payload_filename} ${entity_id2} + ${response}= Create Entity ${entity_payload_filename} ${second_entity_id} Check Response Status Code 201 ${response.status_code} ${registration_id}= Generate Random CSR Id @@ -58,13 +60,13 @@ Setup Registration And Start Context Source Mock Server ${registration_payload}= Prepare Context Source Registration From File ... ${registration_id} ... ${registration_payload_file_path} - ... entity_id=${EMPTY} + ... entity_pattern=${entity_pattern} ${response1}= Create Context Source Registration With Return ${registration_payload} Check Response Status Code 201 ${response1.status_code} Start Context Source Mock Server Delete Registration And Stop Context Source Mock Server - @{entities_ids_to_be_deleted}= Create List ${entity_id1} ${entity_id2} + @{entities_ids_to_be_deleted}= Create List ${first_entity_id} ${second_entity_id} Batch Delete Entities entities_ids_to_be_deleted=@{entities_ids_to_be_deleted} Delete Context Source Registration ${registration_id} Stop Context Source Mock Server diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot index a7c32d1a..15cd594b 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot @@ -16,22 +16,27 @@ Test Teardown Delete Registration And Stop Context Source Mock Server *** Variables *** ${entity_payload_filename} vehicle-simple-attributes.jsonld ${update_fragment_filename} fragmentEntities/vehicle-speed-isParked-fragment.json -${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld +${entity_pattern} urn:ngsi-ld:Vehicle:* +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld *** Test Cases *** D014_02_inc Update Batch Entities With The noOverwrite Option [Documentation] Check that if one request the Context Broker to update a batch of entities that match an inclusive registration, they are updated on the Context Source too [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 additive-inclusive 4_3_6_2 5_6_9 - ${fragment_entity1}= Load Entity ${update_fragment_filename} ${entity_id1} - ${fragment_entity2}= Load Entity ${update_fragment_filename} ${entity_id2} - @{entities_to_be_updated}= Create List ${fragment_entity1} ${fragment_entity2} - @{entities_ids_to_be_updated}= Create List ${entity_id1} ${entity_id2} + ${first_fragment_entity}= Load Entity ${update_fragment_filename} ${first_entity_id} + ${second_fragment_entity}= Load Entity ${update_fragment_filename} ${second_entity_id} + @{entities_to_be_updated}= Create List ${first_fragment_entity} ${second_fragment_entity} + @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} Set Stub Reply POST /ngsi-ld/v1/entityOperations/update 204 ${response}= Batch Update Entities @{entities_to_be_updated} overwrite_option=noOverwrite + Check Response Status Code 204 ${response.status_code} - @{outdated_entities}= Create List ${fragment_entity1} ${fragment_entity2} + ${stub}= Get Request Url Params options + Should Contain ${stub} noOverwrite + + @{outdated_entities}= Create List ${first_fragment_entity} ${second_fragment_entity} ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_updated} ${response}= Query Entities ... entity_ids=${expected_entities_ids} @@ -39,22 +44,19 @@ D014_02_inc Update Batch Entities With The noOverwrite Option ... context=${ngsild_test_suite_context} ... accept=${CONTENT_TYPE_LD_JSON} - ${stub}= Get Request Url Params options - Should Contain ${stub} noOverwrite - Should Not Be Equal ${outdated_entities} ${response.json()} Should Not Contain ${response.json()} speed *** Keywords *** Setup Registration And Start Context Source Mock Server - ${entity_id1}= Generate Random Vehicle Entity Id - Set Test Variable ${entity_id1} - ${entity_id2}= Generate Random Vehicle Entity Id - Set Test Variable ${entity_id2} + ${first_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${first_entity_id} + ${second_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${second_entity_id} - ${response}= Create Entity ${entity_payload_filename} ${entity_id1} + ${response}= Create Entity ${entity_payload_filename} ${first_entity_id} Check Response Status Code 201 ${response.status_code} - ${response}= Create Entity ${entity_payload_filename} ${entity_id2} + ${response}= Create Entity ${entity_payload_filename} ${second_entity_id} Check Response Status Code 201 ${response.status_code} ${registration_id}= Generate Random CSR Id @@ -62,13 +64,13 @@ Setup Registration And Start Context Source Mock Server ${registration_payload}= Prepare Context Source Registration From File ... ${registration_id} ... ${registration_payload_file_path} - ... entity_id=${EMPTY} + ... entity_pattern=${entity_pattern} ${response1}= Create Context Source Registration With Return ${registration_payload} Check Response Status Code 201 ${response1.status_code} Start Context Source Mock Server Delete Registration And Stop Context Source Mock Server - @{entities_ids_to_be_deleted}= Create List ${entity_id1} ${entity_id2} + @{entities_ids_to_be_deleted}= Create List ${first_entity_id} ${second_entity_id} Batch Delete Entities entities_ids_to_be_deleted=@{entities_ids_to_be_deleted} Delete Context Source Registration ${registration_id} Stop Context Source Mock Server diff --git a/data/csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld b/data/csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld new file mode 100644 index 00000000..d4e0422c --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld @@ -0,0 +1,20 @@ + +{ + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "idPattern": "urn:ngsi-ld:Vehicle:*", + "type": "Vehicle" + } + ] + } + ], + "operations": ["redirectionOps"], + "endpoint": "http://my.csource.org:1026/", + "@context":[ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] +} \ No newline at end of file -- GitLab From 168634c408cb3ce3168e31cb23f0335ca46ed892 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 18 Dec 2025 11:44:12 +0100 Subject: [PATCH 4/8] feat: add test for redirect --- .../UpdateBatchEntities/D014_01_red.robot | 74 +++++++++++++++++++ .../Provision/D014_01_red.json | 43 +++++++++++ 2 files changed, 117 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot create mode 100644 doc/files/DistributedOperations/Provision/D014_01_red.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot new file mode 100644 index 00000000..97f7245d --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot @@ -0,0 +1,74 @@ +*** Settings *** +Documentation Verify that, when one has a redirect registration on a Context Broker with redirectionOps, one is able to update a batch of entities on a Context Source + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Test Setup Setup Registration And Start Context Source Mock Server +Test Teardown Delete Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_payload_filename} vehicle-simple-attributes.jsonld +${update_fragment_filename} fragmentEntities/vehicle-brandname-complete-fragment.jsonld +${entity_pattern} urn:ngsi-ld:Vehicle:* +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld + +*** Test Cases *** +D014_01_red Update Batch Entities without noOverwrite Option + [Documentation] Check that if one request the Context Broker to update a batch of entities that match a redirect registration, they are updated on the Context Source + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_9 + + ${first_fragment_entity}= Load Entity ${update_fragment_filename} ${first_entity_id} + ${second_fragment_entity}= Load Entity ${update_fragment_filename} ${second_entity_id} + @{update_fragements}= Create List ${first_fragment_entity} ${second_fragment_entity} + @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} + + Set Stub Reply POST /broker1/ngsi-ld/v1/entityOperations/update 204 + Set Stub Reply POST /broker2/ngsi-ld/v1/entityOperations/update 204 + ${response}= Batch Update Entities @{entities_to_be_updated} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count POST /broker1/ngsi-ld/v1/entityOperations/update + Should Be Equal ${stub_count} 1 + ${stub_count}= Get Stub Count POST /broker2/ngsi-ld/v1/entityOperations/update + Should Be Equal ${stub_count} 1 + +*** Keywords *** +Setup Registration And Start Context Source Mock Server + ${first_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${first_entity_id} + ${second_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${second_entity_id} + + ${registration_id}= Generate Random CSR Id + Set Suite Variable ${registration_id} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_pattern=${entity_pattern} + ... mode=redirect + ... endpoint=/broker1 + ${response1}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response1.status_code} + ${registration_id2}= Generate Random CSR Id + Set Suite Variable ${registration_id2} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id2} + ... ${registration_payload_file_path} + ... entity_pattern=${entity_pattern} + ... mode=redirect + ... endpoint=/broker2 + ${response1}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response1.status_code} + Start Context Source Mock Server + +Delete Registration And Stop Context Source Mock Server + Delete Context Source Registration ${registration_id} + Delete Context Source Registration ${registration_id2} + Stop Context Source Mock Server diff --git a/doc/files/DistributedOperations/Provision/D014_01_red.json b/doc/files/DistributedOperations/Provision/D014_01_red.json new file mode 100644 index 00000000..65b8e453 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D014_01_red.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_01_red", + "test_objective": "Verify that, when one has a redirect registration on a Context Broker with redirectionOps, one is able to update a batch of entities on a Context Source", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.9", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.9" + ], + "pics_selection": "", + "keywords": [ + "Setup Registration And Start Context Source Mock Server", + "Delete Registration And Stop Context Source Mock Server" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing a Context Source Registration \n with id equal to ${registration_id}\n and payload set to ${registration_payload_file_path}\n and the SUT containing a Context Source Mock Server\n}", + "test_cases": [ + { + "name": "D014_01_red Update Batch Entities without noOverwrite Option", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_01_red", + "doc": "Check that if one request the Context Broker to update a batch of entities that match a redirect registration, they are updated on the Context Source", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_9", + "cf_06", + "dist-ops", + "proxy-redirect", + "since_v1.6.1" + ], + "setup": "Setup Registration And Start Context Source Mock Server", + "teardown": "Delete Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "POST", + "endpoint": "entityOperations/update?${params_as_string}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/BatchEntities/UpdateBatchEntities", + "robotfile": "D014_01_red" +} \ No newline at end of file -- GitLab From c271c44bd6b3445d2c45dc1212adaed1d5ebb224 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 18 Dec 2025 11:55:05 +0100 Subject: [PATCH 5/8] feat: new test for redirect with noOverwrite flag --- .../UpdateBatchEntities/D014_01_red.robot | 2 +- .../UpdateBatchEntities/D014_02_red.robot | 77 +++++++++++++++++++ .../Provision/D014_02_red.json | 43 +++++++++++ 3 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_red.robot create mode 100644 doc/files/DistributedOperations/Provision/D014_02_red.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot index 97f7245d..da37cb10 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot @@ -26,7 +26,7 @@ D014_01_red Update Batch Entities without noOverwrite Option ${first_fragment_entity}= Load Entity ${update_fragment_filename} ${first_entity_id} ${second_fragment_entity}= Load Entity ${update_fragment_filename} ${second_entity_id} - @{update_fragements}= Create List ${first_fragment_entity} ${second_fragment_entity} + @{entities_to_be_updated}= Create List ${first_fragment_entity} ${second_fragment_entity} @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} Set Stub Reply POST /broker1/ngsi-ld/v1/entityOperations/update 204 diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_red.robot new file mode 100644 index 00000000..0e0f1016 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_red.robot @@ -0,0 +1,77 @@ +*** Settings *** +Documentation Check that, given a redirect registration with the noOverwrite flag, updating a batch entities creates the new attributes in the Context Source accordingly but does not modify existing ones. + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Test Setup Setup Registration And Start Context Source Mock Server +Test Teardown Delete Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_payload_filename} vehicle-simple-attributes.jsonld +${update_fragment_filename} fragmentEntities/vehicle-brandname-complete-fragment.jsonld +${entity_pattern} urn:ngsi-ld:Vehicle:* +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld + +*** Test Cases *** +D014_02_red Update Batch Entities With noOverwrite Option + [Documentation] Check that if one request the Context Broker to update a batch of entities that match a redirect registration, they are updated on the Context Source + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_9 + + ${first_fragment_entity}= Load Entity ${update_fragment_filename} ${first_entity_id} + ${second_fragment_entity}= Load Entity ${update_fragment_filename} ${second_entity_id} + @{entities_to_be_updated}= Create List ${first_fragment_entity} ${second_fragment_entity} + @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} + + Set Stub Reply POST /broker1/ngsi-ld/v1/entityOperations/update 204 + Set Stub Reply POST /broker2/ngsi-ld/v1/entityOperations/update 204 + ${response}= Batch Update Entities @{entities_to_be_updated} overwrite_option=noOverwrite + Check Response Status Code 204 ${response.status_code} + + ${stub}= Get Request Url Params options + Should Contain ${stub} noOverwrite + + ${stub_count}= Get Stub Count POST /broker1/ngsi-ld/v1/entityOperations/update + Should Be Equal ${stub_count} 1 + ${stub_count}= Get Stub Count POST /broker2/ngsi-ld/v1/entityOperations/update + Should Be Equal ${stub_count} 1 + +*** Keywords *** +Setup Registration And Start Context Source Mock Server + ${first_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${first_entity_id} + ${second_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${second_entity_id} + + ${registration_id}= Generate Random CSR Id + Set Suite Variable ${registration_id} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_pattern=${entity_pattern} + ... mode=redirect + ... endpoint=/broker1 + ${response1}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response1.status_code} + ${registration_id2}= Generate Random CSR Id + Set Suite Variable ${registration_id2} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id2} + ... ${registration_payload_file_path} + ... entity_pattern=${entity_pattern} + ... mode=redirect + ... endpoint=/broker2 + ${response1}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response1.status_code} + Start Context Source Mock Server + +Delete Registration And Stop Context Source Mock Server + Delete Context Source Registration ${registration_id} + Delete Context Source Registration ${registration_id2} + Stop Context Source Mock Server diff --git a/doc/files/DistributedOperations/Provision/D014_02_red.json b/doc/files/DistributedOperations/Provision/D014_02_red.json new file mode 100644 index 00000000..4b8674b6 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D014_02_red.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_02_red", + "test_objective": "Check that, given a redirect registration with the noOverwrite flag, updating a batch entities creates the new attributes in the Context Source accordingly but does not modify existing ones.", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.9", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.9" + ], + "pics_selection": "", + "keywords": [ + "Setup Registration And Start Context Source Mock Server", + "Delete Registration And Stop Context Source Mock Server" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing a Context Source Registration \n with id equal to ${registration_id}\n and payload set to ${registration_payload_file_path}\n and the SUT containing a Context Source Mock Server\n}", + "test_cases": [ + { + "name": "D014_02_red Update Batch Entities With noOverwrite Option", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_02_red", + "doc": "Check that if one request the Context Broker to update a batch of entities that match a redirect registration, they are updated on the Context Source", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_9", + "cf_06", + "dist-ops", + "proxy-redirect", + "since_v1.6.1" + ], + "setup": "Setup Registration And Start Context Source Mock Server", + "teardown": "Delete Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "POST", + "endpoint": "entityOperations/update?${params_as_string}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/BatchEntities/UpdateBatchEntities", + "robotfile": "D014_02_red" +} \ No newline at end of file -- GitLab From 1de2ba15098c376a2cdd81c899a668d15d29dc33 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 18 Dec 2025 15:01:13 +0100 Subject: [PATCH 6/8] fix: improve tests logic --- .../UpdateBatchEntities/D014_01_inc.robot | 13 ++++++------- .../UpdateBatchEntities/D014_01_red.robot | 9 ++++----- .../UpdateBatchEntities/D014_02_inc.robot | 16 +++++++--------- .../UpdateBatchEntities/D014_02_red.robot | 9 ++++----- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot index aa6974bb..3a06ac42 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_inc.robot @@ -14,8 +14,8 @@ Test Setup Setup Registration And Start Context Source Mock Server Test Teardown Delete Registration And Stop Context Source Mock Server *** Variables *** -${entity_payload_filename} vehicle-simple-attributes.jsonld -${update_fragment_filename} fragmentEntities/vehicle-brandname-complete-fragment.jsonld +${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${update_payload_filename} expectations/vehicle-replace-isParked-attribute.jsonld ${entity_pattern} urn:ngsi-ld:Vehicle:* ${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld @@ -24,16 +24,15 @@ D014_01_inc Update Batch Entities without noOverwrite Option [Documentation] Check that if one request the Context Broker to update a batch of entities that match an inclusive registration, they are updated on the Context Source too [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 additive-inclusive 4_3_6_2 5_6_9 - ${first_fragment_entity}= Load Entity ${update_fragment_filename} ${first_entity_id} - ${second_fragment_entity}= Load Entity ${update_fragment_filename} ${second_entity_id} - @{entities_to_be_updated}= Create List ${first_fragment_entity} ${second_fragment_entity} + ${first_update_entity}= Load Entity ${update_payload_filename} ${first_entity_id} + ${second_update_entity}= Load Entity ${update_payload_filename} ${second_entity_id} + @{entities_to_be_updated}= Create List ${first_update_entity} ${second_update_entity} @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} Set Stub Reply POST /ngsi-ld/v1/entityOperations/update 204 ${response}= Batch Update Entities @{entities_to_be_updated} Check Response Status Code 204 ${response.status_code} - @{outdated_entities}= Create List ${first_fragment_entity} ${second_fragment_entity} ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_updated} ${response}= Query Entities ... entity_ids=${expected_entities_ids} @@ -41,7 +40,7 @@ D014_01_inc Update Batch Entities without noOverwrite Option ... context=${ngsild_test_suite_context} ... accept=${CONTENT_TYPE_LD_JSON} - Should Not Be Equal ${outdated_entities} ${response.json()} + Should Not Be Equal ${entities_to_be_updated} ${response.json()} *** Keywords *** Setup Registration And Start Context Source Mock Server diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot index da37cb10..aebdbcbe 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_red.robot @@ -14,8 +14,7 @@ Test Setup Setup Registration And Start Context Source Mock Server Test Teardown Delete Registration And Stop Context Source Mock Server *** Variables *** -${entity_payload_filename} vehicle-simple-attributes.jsonld -${update_fragment_filename} fragmentEntities/vehicle-brandname-complete-fragment.jsonld +${update_payload_filename} expectations/vehicle-replace-isParked-attribute.jsonld ${entity_pattern} urn:ngsi-ld:Vehicle:* ${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld @@ -24,9 +23,9 @@ D014_01_red Update Batch Entities without noOverwrite Option [Documentation] Check that if one request the Context Broker to update a batch of entities that match a redirect registration, they are updated on the Context Source [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_9 - ${first_fragment_entity}= Load Entity ${update_fragment_filename} ${first_entity_id} - ${second_fragment_entity}= Load Entity ${update_fragment_filename} ${second_entity_id} - @{entities_to_be_updated}= Create List ${first_fragment_entity} ${second_fragment_entity} + ${first_update_entity}= Load Entity ${update_payload_filename} ${first_entity_id} + ${second_update_entity}= Load Entity ${update_payload_filename} ${second_entity_id} + @{entities_to_be_updated}= Create List ${first_update_entity} ${second_update_entity} @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} Set Stub Reply POST /broker1/ngsi-ld/v1/entityOperations/update 204 diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot index 15cd594b..fcf18d25 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_inc.robot @@ -14,8 +14,8 @@ Test Setup Setup Registration And Start Context Source Mock Server Test Teardown Delete Registration And Stop Context Source Mock Server *** Variables *** -${entity_payload_filename} vehicle-simple-attributes.jsonld -${update_fragment_filename} fragmentEntities/vehicle-speed-isParked-fragment.json +${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${update_payload_filename} expectations/vehicle-replace-isParked-attribute.jsonld ${entity_pattern} urn:ngsi-ld:Vehicle:* ${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld @@ -24,9 +24,9 @@ D014_02_inc Update Batch Entities With The noOverwrite Option [Documentation] Check that if one request the Context Broker to update a batch of entities that match an inclusive registration, they are updated on the Context Source too [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 additive-inclusive 4_3_6_2 5_6_9 - ${first_fragment_entity}= Load Entity ${update_fragment_filename} ${first_entity_id} - ${second_fragment_entity}= Load Entity ${update_fragment_filename} ${second_entity_id} - @{entities_to_be_updated}= Create List ${first_fragment_entity} ${second_fragment_entity} + ${first_updated_entity}= Load Entity ${update_payload_filename} ${first_entity_id} + ${second_updated_entity}= Load Entity ${update_payload_filename} ${second_entity_id} + @{entities_to_be_updated}= Create List ${first_updated_entity} ${second_updated_entity} @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} Set Stub Reply POST /ngsi-ld/v1/entityOperations/update 204 @@ -36,16 +36,14 @@ D014_02_inc Update Batch Entities With The noOverwrite Option ${stub}= Get Request Url Params options Should Contain ${stub} noOverwrite - @{outdated_entities}= Create List ${first_fragment_entity} ${second_fragment_entity} ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_updated} ${response}= Query Entities ... entity_ids=${expected_entities_ids} ... entity_types=Vehicle ... context=${ngsild_test_suite_context} ... accept=${CONTENT_TYPE_LD_JSON} - - Should Not Be Equal ${outdated_entities} ${response.json()} - Should Not Contain ${response.json()} speed + + Should Not Be Equal ${entities_to_be_updated} ${response.json()} *** Keywords *** Setup Registration And Start Context Source Mock Server diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_red.robot index 0e0f1016..679611cb 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_red.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_red.robot @@ -14,8 +14,7 @@ Test Setup Setup Registration And Start Context Source Mock Server Test Teardown Delete Registration And Stop Context Source Mock Server *** Variables *** -${entity_payload_filename} vehicle-simple-attributes.jsonld -${update_fragment_filename} fragmentEntities/vehicle-brandname-complete-fragment.jsonld +${update_payload_filename} expectations/vehicle-replace-isParked-attribute.jsonld ${entity_pattern} urn:ngsi-ld:Vehicle:* ${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-idpattern-with-redirection-ops.jsonld @@ -24,9 +23,9 @@ D014_02_red Update Batch Entities With noOverwrite Option [Documentation] Check that if one request the Context Broker to update a batch of entities that match a redirect registration, they are updated on the Context Source [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_9 - ${first_fragment_entity}= Load Entity ${update_fragment_filename} ${first_entity_id} - ${second_fragment_entity}= Load Entity ${update_fragment_filename} ${second_entity_id} - @{entities_to_be_updated}= Create List ${first_fragment_entity} ${second_fragment_entity} + ${first_update_entity}= Load Entity ${update_payload_filename} ${first_entity_id} + ${second_update_entity}= Load Entity ${update_payload_filename} ${second_entity_id} + @{entities_to_be_updated}= Create List ${first_update_entity} ${second_update_entity} @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} Set Stub Reply POST /broker1/ngsi-ld/v1/entityOperations/update 204 -- GitLab From 0c68395a428bf147f52c1ef2749c90d4858c36cf Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 18 Dec 2025 15:22:15 +0100 Subject: [PATCH 7/8] feat: implement new test for exclusive --- .../UpdateBatchEntities/D014_01_exc.robot | 67 +++++++++++++++++++ ...-and-idpattern-with-redirection-ops.jsonld | 21 ++++++ .../Provision/D014_01_exc.json | 43 ++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_exc.robot create mode 100644 data/csourceRegistrations/context-source-registration-vehicle-speed-and-idpattern-with-redirection-ops.jsonld create mode 100644 doc/files/DistributedOperations/Provision/D014_01_exc.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_exc.robot new file mode 100644 index 00000000..82c07184 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_01_exc.robot @@ -0,0 +1,67 @@ +*** Settings *** +Documentation Verify that, when one has an exclusive registration on a Context Broker with redirectionOps, one is able to update a batch of entities on both Context Broker and Context Source + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Test Setup Setup Registration And Start Context Source Mock Server +Test Teardown Delete Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${update_payload_filename} expectations/vehicle-replace-isParked-attribute.jsonld +${entity_pattern} urn:ngsi-ld:Vehicle:* +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-and-idpattern-with-redirection-ops.jsonld + +*** Test Cases *** +D014_01_exc Update Batch Entities without noOverwrite Option + [Documentation] Check that if one request the Context Broker to update a batch of entities that match a redirect registration, they are updated on the Context Source + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-exclusive 4_3_6_3 5_6_9 + + ${first_update_entity}= Load Entity ${update_payload_filename} ${first_entity_id} + ${second_update_entity}= Load Entity ${update_payload_filename} ${second_entity_id} + @{entities_to_be_updated}= Create List ${first_update_entity} ${second_update_entity} + @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} + + Set Stub Reply POST /broker1/ngsi-ld/v1/entityOperations/update 204 + ${response}= Batch Update Entities @{entities_to_be_updated} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count POST /broker1/ngsi-ld/v1/entityOperations/update + Should Be Equal ${stub_count} 1 + +*** Keywords *** +Setup Registration And Start Context Source Mock Server + ${first_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${first_entity_id} + ${second_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${second_entity_id} + + ${response}= Create Entity ${entity_payload_filename} ${first_entity_id} local=true + Check Response Status Code 201 ${response.status_code} + ${response}= Create Entity ${entity_payload_filename} ${second_entity_id} local=true + Check Response Status Code 201 ${response.status_code} + + ${registration_id}= Generate Random CSR Id + Set Suite Variable ${registration_id} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_pattern=${entity_pattern} + ... mode=redirect + ... endpoint=/broker1 + ${response1}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response1.status_code} + Start Context Source Mock Server + +Delete Registration And Stop Context Source Mock Server + @{entities_ids_to_be_deleted}= Create List ${first_entity_id} ${second_entity_id} + Batch Delete Entities entities_ids_to_be_deleted=@{entities_ids_to_be_deleted} + Delete Context Source Registration ${registration_id} + Stop Context Source Mock Server diff --git a/data/csourceRegistrations/context-source-registration-vehicle-speed-and-idpattern-with-redirection-ops.jsonld b/data/csourceRegistrations/context-source-registration-vehicle-speed-and-idpattern-with-redirection-ops.jsonld new file mode 100644 index 00000000..024d83e8 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-vehicle-speed-and-idpattern-with-redirection-ops.jsonld @@ -0,0 +1,21 @@ + +{ + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "idPattern": "urn:ngsi-ld:Vehicle:*", + "type": "Vehicle" + } + ], + "propertyNames":["speed"] + } + ], + "operations": ["redirectionOps"], + "endpoint": "http://my.csource.org:1026/", + "@context":[ + "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld" + ] +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D014_01_exc.json b/doc/files/DistributedOperations/Provision/D014_01_exc.json new file mode 100644 index 00000000..5a54950d --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D014_01_exc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_01_exc", + "test_objective": "Verify that, when one has an exclusive registration on a Context Broker with redirectionOps, one is able to update a batch of entities on both Context Broker and Context Source", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.9", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.9" + ], + "pics_selection": "", + "keywords": [ + "Setup Registration And Start Context Source Mock Server", + "Delete Registration And Stop Context Source Mock Server" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing a Context Source Registration \n with id equal to ${registration_id}\n and payload set to ${registration_payload_file_path}\n and the SUT containing a Context Source Mock Server\n}", + "test_cases": [ + { + "name": "D014_01_exc Update Batch Entities without noOverwrite Option", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_01_exc", + "doc": "Check that if one request the Context Broker to update a batch of entities that match a redirect registration, they are updated on the Context Source", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_9", + "cf_06", + "dist-ops", + "proxy-exclusive", + "since_v1.6.1" + ], + "setup": "Setup Registration And Start Context Source Mock Server", + "teardown": "Delete Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "POST", + "endpoint": "entityOperations/update?${params_as_string}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/BatchEntities/UpdateBatchEntities", + "robotfile": "D014_01_exc" +} \ No newline at end of file -- GitLab From a336bd280851d9f8f9099a4eaad00cfda36ce817 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 18 Dec 2025 15:36:01 +0100 Subject: [PATCH 8/8] feat: new test for exclusive with noOverwrite flag --- .../UpdateBatchEntities/D014_02_exc.robot | 68 +++++++++++++++++++ .../Provision/D014_02_exc.json | 43 ++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_exc.robot create mode 100644 doc/files/DistributedOperations/Provision/D014_02_exc.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_exc.robot new file mode 100644 index 00000000..07f5c7d3 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/UpdateBatchEntities/D014_02_exc.robot @@ -0,0 +1,68 @@ +*** Settings *** +Documentation Check that, given an exclusive registration with the noOverwrite flag, updating a batch entities creates the new attributes in the Context Source accordingly but does not modify existing ones. +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/MockServerUtils.resource + +Test Setup Setup Registration And Start Context Source Mock Server +Test Teardown Delete Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${update_payload_filename} expectations/vehicle-replace-isParked-attribute.jsonld +${entity_pattern} urn:ngsi-ld:Vehicle:* +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-and-idpattern-with-redirection-ops.jsonld + +*** Test Cases *** +D014_02_exc Update Batch Entities with noOverwrite Option + [Documentation] Check that if one request the Context Broker to update a batch of entities that match a redirect registration, they are updated on the Context Source + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-exclusive 4_3_6_3 5_6_9 + + ${first_update_entity}= Load Entity ${update_payload_filename} ${first_entity_id} + ${second_update_entity}= Load Entity ${update_payload_filename} ${second_entity_id} + @{entities_to_be_updated}= Create List ${first_update_entity} ${second_update_entity} + @{entities_ids_to_be_updated}= Create List ${first_entity_id} ${second_entity_id} + + Set Stub Reply POST /broker1/ngsi-ld/v1/entityOperations/update 204 + ${response}= Batch Update Entities @{entities_to_be_updated} overwrite_option=noOverwrite + Check Response Status Code 204 ${response.status_code} + + ${stub}= Get Request Url Params options + Should Contain ${stub} noOverwrite + + ${stub_count}= Get Stub Count POST /broker1/ngsi-ld/v1/entityOperations/update + Should Be Equal ${stub_count} 1 + +*** Keywords *** +Setup Registration And Start Context Source Mock Server + ${first_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${first_entity_id} + ${second_entity_id}= Generate Random Vehicle Entity Id + Set Test Variable ${second_entity_id} + + ${response}= Create Entity ${entity_payload_filename} ${first_entity_id} local=true + Check Response Status Code 201 ${response.status_code} + ${response}= Create Entity ${entity_payload_filename} ${second_entity_id} local=true + Check Response Status Code 201 ${response.status_code} + + ${registration_id}= Generate Random CSR Id + Set Suite Variable ${registration_id} + ${registration_payload}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_pattern=${entity_pattern} + ... mode=redirect + ... endpoint=/broker1 + ${response1}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response1.status_code} + Start Context Source Mock Server + +Delete Registration And Stop Context Source Mock Server + @{entities_ids_to_be_deleted}= Create List ${first_entity_id} ${second_entity_id} + Batch Delete Entities entities_ids_to_be_deleted=@{entities_ids_to_be_deleted} + Delete Context Source Registration ${registration_id} + Stop Context Source Mock Server diff --git a/doc/files/DistributedOperations/Provision/D014_02_exc.json b/doc/files/DistributedOperations/Provision/D014_02_exc.json new file mode 100644 index 00000000..ff56dc4a --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D014_02_exc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_02_exc", + "test_objective": "Check that, given an exclusive registration with the noOverwrite flag, updating a batch entities creates the new attributes in the Context Source accordingly but does not modify existing ones.", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.9", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.9" + ], + "pics_selection": "", + "keywords": [ + "Setup Registration And Start Context Source Mock Server", + "Delete Registration And Stop Context Source Mock Server" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT being in the \"initial state\" and\n the SUT containing a Context Source Registration \n with id equal to ${registration_id}\n and payload set to ${registration_payload_file_path}\n and the SUT containing a Context Source Mock Server\n}", + "test_cases": [ + { + "name": "D014_02_exc Update Batch Entities with noOverwrite Option", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BatchEntities/UpdateBatchEntities/D014_02_exc", + "doc": "Check that if one request the Context Broker to update a batch of entities that match a redirect registration, they are updated on the Context Source", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_9", + "cf_06", + "dist-ops", + "proxy-exclusive", + "since_v1.6.1" + ], + "setup": "Setup Registration And Start Context Source Mock Server", + "teardown": "Delete Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "POST", + "endpoint": "entityOperations/update?${params_as_string}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/BatchEntities/UpdateBatchEntities", + "robotfile": "D014_02_exc" +} \ No newline at end of file -- GitLab