From 397a8b3e4f755639ce467b861cf417d50ee29dcd Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 15 Jan 2026 13:04:50 +0100 Subject: [PATCH 1/5] feat: add new test for inclusive --- .../MergeBatchOfEntities/D016_01_inc.robot | 70 +++++++++++++++++++ ...urce-registration-vehicle-batch-ops.jsonld | 20 ++++++ ...ration-vehicle-speed-with-batch-ops.jsonld | 21 ++++++ .../Provision/D016_01_inc.json | 43 ++++++++++++ .../ContextSourceRegistration.resource | 8 +++ 5 files changed, 162 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot create mode 100644 data/csourceRegistrations/context-source-registration-vehicle-batch-ops.jsonld create mode 100644 data/csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops.jsonld create mode 100644 doc/files/DistributedOperations/Provision/D016_01_inc.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot new file mode 100644 index 00000000..4bbe85f1 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot @@ -0,0 +1,70 @@ +*** Settings *** +Documentation Check that if one requests the Context Broker to merge a batch of entities, they are also merged in the 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 Create Entity And Registration On The Context Broker And Start Context Source Mock Server +Test Teardown Delete Created Entity And Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_payload_filename} vehicle-simple-attributes-second.jsonld +${entity_second_payload_filename} vehicle-simple-attributes-second-different.jsonld +${entity_pattern} urn:ngsi-ld:Vehicle:* +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-batch-ops.jsonld + +*** Test Cases *** +D016_01_inc Merge Batch Entities On Both Context Broker And Context Source + [Documentation] Check that if one requests the Context Broker to merge a batch of entities that match an exclusive registration, they are merged on the Context Source too. + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-inclusive 4_3_6_2 5_6_20 + + ${first_entity}= Load Entity ${entity_second_payload_filename} ${first_entity_id} + ${second_entity}= Load Entity ${entity_second_payload_filename} ${second_entity_id} + @{entities_ids_to_be_merged}= Create List ${first_entity_id} ${second_entity_id} + @{entities_to_be_merged}= Create List ${first_entity} ${second_entity} + + Set Stub Reply POST /ngsi-ld/v1/entityOperations/merge 204 + ${response}= Batch Merge Entities @{entities_to_be_merged} + Check Response Status Code 204 ${response.status_code} + + ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_merged} + ${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 ${entities_to_be_merged} ${response.json()} + +*** Keywords *** +Create Entity And Registration On The Context Broker And Start Context Source Mock Server + ${first_entity_id}= Generate Random Vehicle Entity Id + Set Suite Variable ${first_entity_id} + ${second_entity_id}= Generate Random Vehicle Entity Id + Set Suite Variable ${second_entity_id} + + ${response}= Create Entity ${entity_payload_filename} ${first_entity_id} + Check Response Status Code 201 ${response.status_code} + ${response}= Create Entity ${entity_payload_filename} ${second_entity_id} + 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} + ${response}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response.status_code} + Start Context Source Mock Server + +Delete Created Entity And 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-batch-ops.jsonld b/data/csourceRegistrations/context-source-registration-vehicle-batch-ops.jsonld new file mode 100644 index 00000000..8ddbe4fb --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-vehicle-batch-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", "createBatch", "upsertBatch", "updateBatch", "deleteBatch", "mergeBatch"], + "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/data/csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops.jsonld b/data/csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops.jsonld new file mode 100644 index 00000000..38697527 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-vehicle-speed-with-batch-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", "createBatch", "upsertBatch", "updateBatch", "deleteBatch", "mergeBatch"], + "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/D016_01_inc.json b/doc/files/DistributedOperations/Provision/D016_01_inc.json new file mode 100644 index 00000000..f802cd49 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D016_01_inc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BE/D016_01_inc", + "test_objective": "Check that if one requests the Context Broker to merge a batch of entities, they are also merged in the Context Source", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.2, 5.6.20", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.2", + "5.6.20" + ], + "pics_selection": "", + "keywords": [ + "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", + "Delete Created Entity And 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 an initial Entity ${entity} on the Context Broker\n with an id set to ${entity_id}\n and payload set to ${entity_payload_filename}\n and 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": "D016_01_inc Merge Batch Entities On Both Context Broker And Context Source", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BE/D016_01_inc", + "doc": "Check that if one requests the Context Broker to merge a batch of entities that match an exclusive registration, they are merged on the Context Source too.", + "tags": [ + "4_3_3", + "4_3_6_2", + "5_6_20", + "cf_06", + "dist-ops", + "proxy-inclusive", + "since_v1.6.1" + ], + "setup": "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", + "teardown": "Delete Created Entity And Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities", + "robotfile": "D016_01_inc" +} \ No newline at end of file diff --git a/resources/ApiUtils/ContextSourceRegistration.resource b/resources/ApiUtils/ContextSourceRegistration.resource index 55f1dba2..7a904f8c 100755 --- a/resources/ApiUtils/ContextSourceRegistration.resource +++ b/resources/ApiUtils/ContextSourceRegistration.resource @@ -28,6 +28,7 @@ Prepare Context Source Registration From File ... ${id} ... ${registration_file} ... ${entity_id}=${EMPTY} + ... ${entity_pattern}=${EMPTY} ... ${mode}=${EMPTY} ... ${endpoint}=${EMPTY} ... ${operations}=[] @@ -48,6 +49,13 @@ Prepare Context Source Registration From File ... $..entities[*] ... ${dict} END + IF '${entity_pattern}' != '' + ${dict}= Create Dictionary idPattern=${entity_pattern} + ${registration_payload}= Add Object To JSON + ... ${registration_payload} + ... $..entities[*] + ... ${dict} + END IF '${mode}' != '' ${dict}= Create Dictionary mode=${mode} ${registration_payload}= Add Object To JSON -- GitLab From 6a3084dce06f51ceed9351050f05d07d36aeaaa8 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 15 Jan 2026 16:11:51 +0100 Subject: [PATCH 2/5] fix: minor changes to test --- .../MergeBatchOfEntities/D016_01_inc.robot | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot index 4bbe85f1..d130f8a6 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot @@ -24,22 +24,26 @@ D016_01_inc Merge Batch Entities On Both Context Broker And Context Source [Documentation] Check that if one requests the Context Broker to merge a batch of entities that match an exclusive registration, they are merged on the Context Source too. [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-inclusive 4_3_6_2 5_6_20 - ${first_entity}= Load Entity ${entity_second_payload_filename} ${first_entity_id} - ${second_entity}= Load Entity ${entity_second_payload_filename} ${second_entity_id} + ${new_first_entity}= Load Entity ${entity_second_payload_filename} ${first_entity_id} + ${new_second_entity}= Load Entity ${entity_second_payload_filename} ${second_entity_id} @{entities_ids_to_be_merged}= Create List ${first_entity_id} ${second_entity_id} - @{entities_to_be_merged}= Create List ${first_entity} ${second_entity} + @{entities_to_be_merged}= Create List ${new_first_entity} ${new_second_entity} Set Stub Reply POST /ngsi-ld/v1/entityOperations/merge 204 ${response}= Batch Merge Entities @{entities_to_be_merged} Check Response Status Code 204 ${response.status_code} + ${stub_count}= Get Stub Count POST /ngsi-ld/v1/entityOperations/merge + Should Be Equal ${stub_count} 1 + ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_merged} ${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 ${entities_to_be_merged} ${response.json()} + + Should Contain ${response.json()} speed *** Keywords *** Create Entity And Registration On The Context Broker And Start Context Source Mock Server -- GitLab From a4b61ac933360e6a07718c28e4cc2e7f053c8f56 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 15 Jan 2026 16:46:31 +0100 Subject: [PATCH 3/5] feat: new test for exclusive --- .../MergeBatchOfEntities/D016_01_exc.robot | 77 +++++++++++++++++++ .../MergeBatchOfEntities/D016_01_inc.robot | 4 +- .../Provision/D016_01_exc.json | 43 +++++++++++ .../Provision/D016_01_inc.json | 4 +- 4 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_exc.robot create mode 100644 doc/files/DistributedOperations/Provision/D016_01_exc.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_exc.robot new file mode 100644 index 00000000..d51a7840 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_exc.robot @@ -0,0 +1,77 @@ +*** Settings *** +Documentation Check that if one requests the Context Broker to merge a batch of entities, they are also merged in the 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 Create Entity And Registration On The Context Broker And Start Context Source Mock Server +Test Teardown Delete Created Entity And Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_payload_filename} vehicle-simple-attributes-second.jsonld +${entity_second_payload_filename} vehicle-simple-attributes-second-different.jsonld +${entity_pattern} urn:ngsi-ld:Vehicle:* +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops.jsonld + +*** Test Cases *** +D016_01_exc Merge Batch Entities On Both Context Broker And Context Source + [Documentation] Check that if one requests the Context Broker to merge a batch of entities that match an exclusive registration, they are merged on the Context Source too. + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-exclusive 4_3_6_3 5_6_20 + + ${new_first_entity}= Load Entity ${entity_second_payload_filename} ${first_entity_id} + ${new_second_entity}= Load Entity ${entity_second_payload_filename} ${second_entity_id} + @{entities_ids_to_be_merged}= Create List ${first_entity_id} ${second_entity_id} + @{entities_to_be_merged}= Create List ${new_first_entity} ${new_second_entity} + + Set Stub Reply POST /broker1/ngsi-ld/v1/entityOperations/merge 204 + ${response}= Batch Merge Entities @{entities_to_be_merged} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count POST /broker1/ngsi-ld/v1/entityOperations/merge + Should Be Equal ${stub_count} 1 + + ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_merged} + ${response}= Query Entities + ... entity_ids=${expected_entities_ids} + ... entity_types=Vehicle + ... context=${ngsild_test_suite_context} + ... accept=${CONTENT_TYPE_LD_JSON} + ... local=true + + Should Not Contain ${response.json()} speed + +*** Keywords *** +Create Entity And Registration On The Context Broker And Start Context Source Mock Server + ${first_entity_id}= Generate Random Vehicle Entity Id + Set Suite Variable ${first_entity_id} + ${second_entity_id}= Generate Random Vehicle Entity Id + Set Suite 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=exclusive + ... endpoint=/broker1 + ${response}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response.status_code} + Start Context Source Mock Server + +Delete Created Entity And 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/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot index d130f8a6..b95dd705 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot @@ -21,8 +21,8 @@ ${registration_payload_file_path} csourceRegistrations/context-source-regi *** Test Cases *** D016_01_inc Merge Batch Entities On Both Context Broker And Context Source - [Documentation] Check that if one requests the Context Broker to merge a batch of entities that match an exclusive registration, they are merged on the Context Source too. - [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-inclusive 4_3_6_2 5_6_20 + [Documentation] Check that if one requests the Context Broker to merge a batch of entities that match an inclusive registration, they are merged 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_20 ${new_first_entity}= Load Entity ${entity_second_payload_filename} ${first_entity_id} ${new_second_entity}= Load Entity ${entity_second_payload_filename} ${second_entity_id} diff --git a/doc/files/DistributedOperations/Provision/D016_01_exc.json b/doc/files/DistributedOperations/Provision/D016_01_exc.json new file mode 100644 index 00000000..d3c67054 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D016_01_exc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BE/D016_01_exc", + "test_objective": "Check that if one requests the Context Broker to merge a batch of entities, they are also merged in the Context Source", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.20", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.20" + ], + "pics_selection": "", + "keywords": [ + "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", + "Delete Created Entity And 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 an initial Entity ${entity} on the Context Broker\n with an id set to ${entity_id}\n and payload set to ${entity_payload_filename}\n and 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": "D016_01_exc Merge Batch Entities On Both Context Broker And Context Source", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BE/D016_01_exc", + "doc": "Check that if one requests the Context Broker to merge a batch of entities that match an exclusive registration, they are merged on the Context Source too.", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_20", + "cf_06", + "dist-ops", + "proxy-exclusive", + "since_v1.6.1" + ], + "setup": "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", + "teardown": "Delete Created Entity And Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities", + "robotfile": "D016_01_exc" +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D016_01_inc.json b/doc/files/DistributedOperations/Provision/D016_01_inc.json index f802cd49..f301da23 100644 --- a/doc/files/DistributedOperations/Provision/D016_01_inc.json +++ b/doc/files/DistributedOperations/Provision/D016_01_inc.json @@ -20,14 +20,14 @@ { "name": "D016_01_inc Merge Batch Entities On Both Context Broker And Context Source", "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BE/D016_01_inc", - "doc": "Check that if one requests the Context Broker to merge a batch of entities that match an exclusive registration, they are merged on the Context Source too.", + "doc": "Check that if one requests the Context Broker to merge a batch of entities that match an inclusive registration, they are merged on the Context Source too.", "tags": [ "4_3_3", "4_3_6_2", "5_6_20", + "additive-inclusive", "cf_06", "dist-ops", - "proxy-inclusive", "since_v1.6.1" ], "setup": "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", -- GitLab From cd2715ff1c42cd484b3323ea7915ae4619d793aa Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 15 Jan 2026 17:49:37 +0100 Subject: [PATCH 4/5] feat: new test for redirect --- .../MergeBatchOfEntities/D016_01_red.robot | 91 +++++++++++++++++++ .../Provision/D016_01_red.json | 43 +++++++++ 2 files changed, 134 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_red.robot create mode 100644 doc/files/DistributedOperations/Provision/D016_01_red.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_red.robot new file mode 100644 index 00000000..5ee37172 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_red.robot @@ -0,0 +1,91 @@ +*** Settings *** +Documentation Check that if one requests the Context Broker to merge a batch of entities, they get merged in the Context Source thanks to redirect registration + +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 Create Entity And Registration On The Context Broker And Start Context Source Mock Server +Test Teardown Delete Created Entity And Registration And Stop Context Source Mock Server + +*** Variables *** +${entity_payload_filename} vehicle-simple-attributes-second.jsonld +${entity_second_payload_filename} vehicle-simple-attributes-second-different.jsonld +${entity_pattern} urn:ngsi-ld:Vehicle:* +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-batch-ops.jsonld + +*** Test Cases *** +D016_01_red Merge Batch Entities On The Context Source + [Documentation] Check that if one requests the Context Broker to merge a batch of entities that match an exclusive registration, they are merged on the Context Source too. + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_20 + + ${first_entity}= Load Entity ${entity_payload_filename} ${first_entity_id} + ${second_entity}= Load Entity ${entity_payload_filename} ${second_entity_id} + Set Stub Reply POST /broker1/ngsi-ld/v1/entityOperations/create 204 + Set Stub Reply POST /broker2/ngsi-ld/v1/entityOperations/create 204 + + ${new_first_entity}= Load Entity ${entity_second_payload_filename} ${first_entity_id} + ${new_second_entity}= Load Entity ${entity_second_payload_filename} ${second_entity_id} + @{entities_ids_to_be_merged}= Create List ${first_entity_id} ${second_entity_id} + @{entities_to_be_merged}= Create List ${new_first_entity} ${new_second_entity} + + Set Stub Reply POST /broker1/ngsi-ld/v1/entityOperations/merge 204 + Set Stub Reply POST /broker2/ngsi-ld/v1/entityOperations/merge 204 + ${response}= Batch Merge Entities @{entities_to_be_merged} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count POST /broker1/ngsi-ld/v1/entityOperations/merge + Should Be Equal ${stub_count} 1 + ${stub_count}= Get Stub Count POST /broker2/ngsi-ld/v1/entityOperations/merge + Should Be Equal ${stub_count} 1 + + ${expected_entities_ids}= Catenate SEPARATOR=, @{entities_ids_to_be_merged} + ${response}= Query Entities + ... entity_ids=${expected_entities_ids} + ... entity_types=Vehicle + ... context=${ngsild_test_suite_context} + ... accept=${CONTENT_TYPE_LD_JSON} + + Should Contain ${response.json()} speed + +*** Keywords *** +Create Entity And Registration On The Context Broker And Start Context Source Mock Server + ${first_entity_id}= Generate Random Vehicle Entity Id + Set Suite Variable ${first_entity_id} + ${second_entity_id}= Generate Random Vehicle Entity Id + Set Suite 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 + ${response}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response.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 + ${response}= Create Context Source Registration With Return ${registration_payload} + Check Response Status Code 201 ${response.status_code} + + Start Context Source Mock Server + +Delete Created Entity And 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} + Delete Context Source Registration ${registration_id2} + Stop Context Source Mock Server diff --git a/doc/files/DistributedOperations/Provision/D016_01_red.json b/doc/files/DistributedOperations/Provision/D016_01_red.json new file mode 100644 index 00000000..35b3a480 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D016_01_red.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BE/D016_01_red", + "test_objective": "Check that if one requests the Context Broker to merge a batch of entities, they get merged in the Context Source thanks to redirect registration", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.20", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.20" + ], + "pics_selection": "", + "keywords": [ + "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", + "Delete Created Entity And 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 an initial Entity ${entity} on the Context Broker\n with an id set to ${entity_id}\n and payload set to ${entity_payload_filename}\n and 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": "D016_01_red Merge Batch Entities On The Context Source", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/BE/D016_01_red", + "doc": "Check that if one requests the Context Broker to merge a batch of entities that match an exclusive registration, they are merged on the Context Source too.", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_20", + "cf_06", + "dist-ops", + "proxy-redirect", + "since_v1.6.1" + ], + "setup": "Create Entity And Registration On The Context Broker And Start Context Source Mock Server", + "teardown": "Delete Created Entity And Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "GET", + "endpoint": "entities/" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities", + "robotfile": "D016_01_red" +} \ No newline at end of file -- GitLab From 00ad7f8e220996a32d43bc80cd6938276970e81e Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Mon, 19 Jan 2026 11:05:41 +0100 Subject: [PATCH 5/5] fix: variable names --- .../BatchEntities/MergeBatchOfEntities/D016_01_exc.robot | 2 +- .../BatchEntities/MergeBatchOfEntities/D016_01_inc.robot | 2 +- .../BatchEntities/MergeBatchOfEntities/D016_01_red.robot | 4 ++-- resources/ApiUtils/ContextSourceRegistration.resource | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_exc.robot index d51a7840..905ebd5d 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_exc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_exc.robot @@ -63,7 +63,7 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo ${registration_payload}= Prepare Context Source Registration From File ... ${registration_id} ... ${registration_payload_file_path} - ... entity_pattern=${entity_pattern} + ... entity_id_pattern=${entity_pattern} ... mode=exclusive ... endpoint=/broker1 ${response}= Create Context Source Registration With Return ${registration_payload} diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot index b95dd705..b79768cb 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_inc.robot @@ -62,7 +62,7 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo ${registration_payload}= Prepare Context Source Registration From File ... ${registration_id} ... ${registration_payload_file_path} - ... entity_pattern=${entity_pattern} + ... entity_id_pattern=${entity_pattern} ${response}= Create Context Source Registration With Return ${registration_payload} Check Response Status Code 201 ${response.status_code} Start Context Source Mock Server diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_red.robot index 5ee37172..b99ff629 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_red.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/MergeBatchOfEntities/D016_01_red.robot @@ -65,7 +65,7 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo ${registration_payload}= Prepare Context Source Registration From File ... ${registration_id} ... ${registration_payload_file_path} - ... entity_pattern=${entity_pattern} + ... entity_id_pattern=${entity_pattern} ... mode=redirect ... endpoint=/broker1 ${response}= Create Context Source Registration With Return ${registration_payload} @@ -75,7 +75,7 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo ${registration_payload}= Prepare Context Source Registration From File ... ${registration_id2} ... ${registration_payload_file_path} - ... entity_pattern=${entity_pattern} + ... entity_id_pattern=${entity_pattern} ... mode=redirect ... endpoint=/broker2 ${response}= Create Context Source Registration With Return ${registration_payload} diff --git a/resources/ApiUtils/ContextSourceRegistration.resource b/resources/ApiUtils/ContextSourceRegistration.resource index 7a904f8c..ffdcc108 100755 --- a/resources/ApiUtils/ContextSourceRegistration.resource +++ b/resources/ApiUtils/ContextSourceRegistration.resource @@ -28,7 +28,7 @@ Prepare Context Source Registration From File ... ${id} ... ${registration_file} ... ${entity_id}=${EMPTY} - ... ${entity_pattern}=${EMPTY} + ... ${entity_id_pattern}=${EMPTY} ... ${mode}=${EMPTY} ... ${endpoint}=${EMPTY} ... ${operations}=[] @@ -49,8 +49,8 @@ Prepare Context Source Registration From File ... $..entities[*] ... ${dict} END - IF '${entity_pattern}' != '' - ${dict}= Create Dictionary idPattern=${entity_pattern} + IF '${entity_id_pattern}' != '' + ${dict}= Create Dictionary idPattern=${entity_id_pattern} ${registration_payload}= Add Object To JSON ... ${registration_payload} ... $..entities[*] -- GitLab