From 500b9b8bf20a88d0640eea61014bb569c1c06ea4 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 13 Nov 2025 15:54:50 +0100 Subject: [PATCH 1/5] feat: add new test for inclusive --- .../Entities/MergeEntity/D008_01_inc.robot | 69 +++++++++++++++++++ ...-simple-attributes-second-different.jsonld | 25 +++++++ 2 files changed, 94 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_inc.robot create mode 100644 data/entities/vehicle-simple-attributes-second-different.jsonld diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_inc.robot new file mode 100644 index 00000000..c83394e6 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_inc.robot @@ -0,0 +1,69 @@ +*** Settings *** +Documentation Check that if one requests the Context Broker to merge an entity that matches an inclusive registration, this is merged on the 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 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_new_payload_filename} vehicle-simple-attributes-second-different.jsonld +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D008_01_inc Merge Entity On Both Context Broker And Context Source + [Documentation] Check that if one requests the Context Broker to merge an entity that matches an inclusive registration, this is 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_17 + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} + ${old_isparked}= Get From Dictionary ${response.json()} isParked2 + ${old_brandname}= Get From Dictionary ${response.json()} brandName + + Set Stub Reply PATCH /ngsi-ld/v1/entities/${entity_id} 204 + ${response}= Merge Entity + ... entity_id=${entity_id} + ... entity_filename=${entity_new_payload_filename} + ... content_type=${CONTENT_TYPE_LD_JSON} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count PATCH /ngsi-ld/v1/entities/${entity_id} + Should Be True ${stub_count} > 0 + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} + ${new_brandname}= Get From Dictionary ${response.json()} brandName + ${new_isparked}= Get From Dictionary ${response.json()} isParked2 + Should Be Equal ${old_brandname} ${new_brandname} + Should Not Be Equal ${old_isparked} ${new_isparked} + Dictionary Should Contain Key ${response.json()} speed + +*** Keywords *** +Create Entity And Registration On The Context Broker And Start Context Source Mock Server + ${entity_id}= Generate Random Vehicle Entity Id + Set Suite Variable ${entity_id} + + ${response}= Create Entity ${entity_payload_filename} ${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_id=${entity_id} + ... mode=inclusive + ${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 + Delete Entity by Id ${entity_id} + Delete Context Source Registration ${registration_id} diff --git a/data/entities/vehicle-simple-attributes-second-different.jsonld b/data/entities/vehicle-simple-attributes-second-different.jsonld new file mode 100644 index 00000000..b892e88f --- /dev/null +++ b/data/entities/vehicle-simple-attributes-second-different.jsonld @@ -0,0 +1,25 @@ +{ + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle", + "speed": { + "type": "Property", + "value": 56, + "source": { + "type": "Property", + "value": "Speedometer" + }, + "datasetId": "urn:ngsi-ld:Property:speedometerA4567-speed2" + }, + "isParked2": { + "type": "Relationship", + "object": "urn:ngsi-ld:OffStreetParking:Downtown2", + "observedAt": "2019-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Bob" + } + }, + "@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 6c6ddaa23270009e0c895a16525a0ec7e174c400 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 13 Nov 2025 16:51:43 +0100 Subject: [PATCH 2/5] feat: add new test for redirect --- .../Entities/MergeEntity/D008_01_red.robot | 68 +++++++++++++++++++ .../Provision/D008_01_inc.json | 43 ++++++++++++ .../Provision/D008_01_red.json | 43 ++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot create mode 100644 doc/files/DistributedOperations/Provision/D008_01_inc.json create mode 100644 doc/files/DistributedOperations/Provision/D008_01_red.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot new file mode 100644 index 00000000..b0684de5 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot @@ -0,0 +1,68 @@ +*** Settings *** +Documentation Check that if one requests the Context Broker to merge an entity that matches a redirect registration, this is merged on the Context Sources. + +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 Created Entity And Registration And Stop Context Source Mock Server + + +*** Variables *** +${entity_payload_filename} vehicle-simple-attributes-second.jsonld +${entity_new_payload_filename} vehicle-simple-attributes-second-different.jsonld +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D008_01_red Merge Entity On Both Context Broker And Context Source + [Documentation] Check that if one requests the Context Broker to merge an entity that matches a redirect registration, this is merged on the Context Source. + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_17 + + Set Stub Reply PATCH /broker1/ngsi-ld/v1/entities/${entity_id} 204 + Set Stub Reply PATCH /broker2/ngsi-ld/v1/entities/${entity_id} 204 + ${response}= Merge Entity + ... entity_id=${entity_id} + ... entity_filename=${entity_new_payload_filename} + ... content_type=${CONTENT_TYPE_LD_JSON} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count PATCH /broker1/ngsi-ld/v1/entities/${entity_id} + Should Be True ${stub_count} > 0 + ${stub_count}= Get Stub Count PATCH /broker2/ngsi-ld/v1/entities/${entity_id} + Should Be True ${stub_count} > 0 + +*** Keywords *** +Setup Registration And Start Context Source Mock Server + ${entity_id}= Generate Random Vehicle Entity Id + Set Suite Variable ${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_id=${entity_id} + ... mode=redirect + ${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_id=${entity_id} + ... mode=redirect + ${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 + Delete Context Source Registration ${registration_id} + Delete Context Source Registration ${registration_id2} diff --git a/doc/files/DistributedOperations/Provision/D008_01_inc.json b/doc/files/DistributedOperations/Provision/D008_01_inc.json new file mode 100644 index 00000000..a896005a --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D008_01_inc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_inc", + "test_objective": "Check that if one requests the Context Broker to merge an entity that matches an inclusive registration, this is merged on the Context Source too", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.2, 5.6.17", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.2", + "5.6.17" + ], + "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": "D008_01_inc Merge Entity On Both Context Broker And Context Source", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_inc", + "doc": "Check that if one requests the Context Broker to merge an entity that matches an inclusive registration, this is merged on the Context Source too", + "tags": [ + "4_3_3", + "4_3_6_2", + "5_6_17", + "additive-inclusive", + "cf_06", + "dist-ops", + "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/{id}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/Entities/MergeEntity", + "robotfile": "D008_01_inc" +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D008_01_red.json b/doc/files/DistributedOperations/Provision/D008_01_red.json new file mode 100644 index 00000000..181943ed --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D008_01_red.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_red", + "test_objective": "Check that if one requests the Context Broker to merge an entity that matches a redirect registration, this is merged on the Context Sources.", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.17", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.17" + ], + "pics_selection": "", + "keywords": [ + "Setup Registration 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 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": "D008_01_red Merge Entity On Both Context Broker And Context Source", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_red", + "doc": "Check that if one requests the Context Broker to merge an entity that matches a redirect registration, this is merged on the Context Source.", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_17", + "cf_06", + "dist-ops", + "proxy-redirect", + "since_v1.6.1" + ], + "setup": "Setup Registration And Start Context Source Mock Server", + "teardown": "Delete Created Entity And Registration And Stop Context Source Mock Server", + "template": null, + "http_verb": "PATCH", + "endpoint": "entities/{entity_id}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/Entities/MergeEntity", + "robotfile": "D008_01_red" +} \ No newline at end of file -- GitLab From 9239d2c562b791403ea6f0008f6983c7d10af455 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 13 Nov 2025 16:56:07 +0100 Subject: [PATCH 3/5] fix: correct test registration --- .../Provision/Entities/MergeEntity/D008_01_red.robot | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot index b0684de5..17ed909d 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_red.robot @@ -49,6 +49,7 @@ Setup Registration And Start Context Source Mock Server ... ${registration_payload_file_path} ... entity_id=${entity_id} ... mode=redirect + ... endpoint=/broker1 ${response}= Create Context Source Registration With Return ${registration_payload} Check Response Status Code 201 ${response.status_code} @@ -59,6 +60,7 @@ Setup Registration And Start Context Source Mock Server ... ${registration_payload_file_path} ... entity_id=${entity_id} ... 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 -- GitLab From 68dfcb837d82d80806ff399a2472d9fade872f85 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 13 Nov 2025 17:04:54 +0100 Subject: [PATCH 4/5] feat: add new test for exclusive --- .../Entities/MergeEntity/D008_01_exc.robot | 63 +++++++++++++++++++ .../Provision/D008_01_exc.json | 43 +++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot create mode 100644 doc/files/DistributedOperations/Provision/D008_01_exc.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot new file mode 100644 index 00000000..a404203c --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot @@ -0,0 +1,63 @@ +*** Settings *** +Documentation Check that if one requests the Context Broker to merge an entity that matches an exclusive registration, this is merged on the Context Sources. + +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_new_payload_filename} vehicle-simple-attributes-second-different.jsonld +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld + +*** Test Cases *** +D008_01_exc Merge Entity On Both Context Broker And Context Source + [Documentation] Check that if one requests the Context Broker to merge an entity that matches an exclusive registration, this is merged on the Context Source. + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-exclusive 4_3_6_3 5_6_17 + + Set Stub Reply PATCH /broker1/ngsi-ld/v1/entities/${entity_id} 204 + ${response}= Merge Entity + ... entity_id=${entity_id} + ... entity_filename=${entity_new_payload_filename} + ... content_type=${CONTENT_TYPE_LD_JSON} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count PATCH /broker1/ngsi-ld/v1/entities/${entity_id} + Should Be True ${stub_count} > 0 + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} local=true + ${body}= Get From Dictionary ${response.json()} speed + Should Not Contain ${body} speed + +*** Keywords *** +Create Entity And Registration On The Context Broker And Start Context Source Mock Server + ${entity_id}= Generate Random Vehicle Entity Id + Set Suite Variable ${entity_id} + + ${response}= Create Entity ${entity_payload_filename} ${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_id=${entity_id} + ... 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 + Delete Entity by Id ${entity_id} + Delete Context Source Registration ${registration_id} diff --git a/doc/files/DistributedOperations/Provision/D008_01_exc.json b/doc/files/DistributedOperations/Provision/D008_01_exc.json new file mode 100644 index 00000000..51ef44ad --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D008_01_exc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_exc", + "test_objective": "Check that if one requests the Context Broker to merge an entity that matches an exclusive registration, this is merged on the Context Sources.", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.17", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.17" + ], + "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": "D008_01_exc Merge Entity On Both Context Broker And Context Source", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D008_01_exc", + "doc": "Check that if one requests the Context Broker to merge an entity that matches an exclusive registration, this is merged on the Context Source.", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_17", + "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/{id}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/Entities/MergeEntity", + "robotfile": "D008_01_exc" +} \ No newline at end of file -- GitLab From bfa9193d4a1ac127acba6d8c90f5e404af911e86 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Thu, 27 Nov 2025 15:25:21 +0100 Subject: [PATCH 5/5] fix: change tests based on review --- .../Provision/Entities/MergeEntity/D008_01_exc.robot | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot index a404203c..3fa52b4e 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/MergeEntity/D008_01_exc.robot @@ -29,14 +29,13 @@ D008_01_exc Merge Entity On Both Context Broker And Context Source ... entity_id=${entity_id} ... entity_filename=${entity_new_payload_filename} ... content_type=${CONTENT_TYPE_LD_JSON} - Check Response Status Code 204 ${response.status_code} + Check Response Status Code 204 ${response.status_code} ${stub_count}= Get Stub Count PATCH /broker1/ngsi-ld/v1/entities/${entity_id} Should Be True ${stub_count} > 0 ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} local=true - ${body}= Get From Dictionary ${response.json()} speed - Should Not Contain ${body} speed + Should Not Contain ${response} speed *** Keywords *** Create Entity And Registration On The Context Broker And Start Context Source Mock Server -- GitLab