From 768401e8ad74eee861a7df64494e97e9e07fc9f4 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Tue, 25 Nov 2025 11:35:58 +0100 Subject: [PATCH 1/3] feat: implement new test for inclusive --- .../ReplaceEntityAttribute/D009_01_inc.robot | 67 +++++++++++++++++++ ...hicle-speed-two-datasetid-01-fragment.json | 10 +++ .../Provision/D009_01_inc.json | 45 +++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_inc.robot create mode 100644 data/entities/fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json create mode 100644 doc/files/DistributedOperations/Provision/D009_01_inc.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_inc.robot new file mode 100644 index 00000000..8ea2f326 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_inc.robot @@ -0,0 +1,67 @@ +*** Settings *** +Documentation Verify that, when one has an inclusive registration on a Context Broker, one is able to replace a target entity and the change is forwarded to 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_id_prefix} urn:ngsi-ld:Vehicle: +${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${entity_attribute_filename} fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json +${registration_id_prefix} urn:ngsi-ld:Registration: +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D009_01_inc Replace Entity Attribute + [Documentation] Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Source thanks to an inclusive registration + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 additive-inclusive 4_3_6_2 5_6_19 6_3_18 + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} + ${old_attribute}= Get From Dictionary ${response.json()} speed + + ${attribute_payload}= Load Entity ${entity_attribute_filename} ${entity_id} + Set Stub Reply PUT /ngsi-ld/v1/entities/${entity_id}/attrs/speed 204 + + ${response}= Replace Attribute Selecting Content Type + ... entity_id=${entity_id} + ... attr_id=speed + ... attribute_fragment=${attribute_payload} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 204 ${response.status_code} + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} + ${new_attribute}= Get From Dictionary ${response.json()} speed + Should Not Be Equal ${old_attribute} ${new_attribute} + +*** 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} + ${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 Entity by Id ${entity_id} \ No newline at end of file diff --git a/data/entities/fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json b/data/entities/fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json new file mode 100644 index 00000000..fc7e3200 --- /dev/null +++ b/data/entities/fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json @@ -0,0 +1,10 @@ +{ + "speed": { + "type": "Property", + "value": 99, + "source": { + "type": "Property", + "value": "Speedometer" + } + } +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D009_01_inc.json b/doc/files/DistributedOperations/Provision/D009_01_inc.json new file mode 100644 index 00000000..5b23a698 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D009_01_inc.json @@ -0,0 +1,45 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_inc", + "test_objective": "Verify that, when one has an inclusive registration on a Context Broker, one is able to replace a target entity and the change is forwarded to the Context Source", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.2, 5.6.19, 6.3.18", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.2", + "5.6.19", + "6.3.18" + ], + "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": "D009_01_inc Replace Entity Attribute", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_inc", + "doc": "Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Source thanks to an inclusive registration", + "tags": [ + "4_3_3", + "4_3_6_2", + "5_6_19", + "6_3_18", + "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/EntityAttributes/ReplaceEntityAttribute", + "robotfile": "D009_01_inc" +} \ No newline at end of file -- GitLab From a0af7266a648b7355877f9abcfee28f3c8c845d4 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Tue, 25 Nov 2025 12:15:55 +0100 Subject: [PATCH 2/3] feat: implement new test for redirect --- .../ReplaceEntityAttribute/D009_01_red.robot | 79 +++++++++++++++++++ .../Provision/D009_01_red.json | 45 +++++++++++ 2 files changed, 124 insertions(+) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot create mode 100644 doc/files/DistributedOperations/Provision/D009_01_red.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot new file mode 100644 index 00000000..78d8eade --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot @@ -0,0 +1,79 @@ +*** Settings *** +Documentation Verify that, when one has two redirect registrations on a Context Broker, one is able to replace a target entity on both 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_id_prefix} urn:ngsi-ld:Vehicle: +${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${entity_attribute_filename} fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json +${registration_id_prefix} urn:ngsi-ld:Registration: +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D009_01_red Replace Entity Attribute + [Documentation] Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Sources thanks to the redirect registrations + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_19 6_3_18 + + Set Stub Reply POST /broker1/ngsi-ld/v1/entities 201 ${entity_id} + Set Stub Reply POST /broker2/ngsi-ld/v1/entities 201 ${entity_id} + + ${attribute_payload}= Load Entity ${entity_attribute_filename} ${entity_id} + Set Stub Reply PUT /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/speed 204 + Set Stub Reply PUT /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/speed 204 + + ${response}= Replace Attribute Selecting Content Type + ... entity_id=${entity_id} + ... attr_id=speed + ... attribute_fragment=${attribute_payload} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Request Count PUT /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/speed + Should Be Equal 1 ${stub_count} + ${stub_count}= Get Stub Request Count PUT /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/speed + Should Be Equal 1 ${stub_count} + +*** 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 + ... 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_payload2}= Prepare Context Source Registration From File + ... ${registration_id} + ... ${registration_payload_file_path} + ... entity_id=${entity_id} + ... mode=redirect + ... endpoint=/broker2 + ${response}= Create Context Source Registration With Return ${registration_payload2} + 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} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D009_01_red.json b/doc/files/DistributedOperations/Provision/D009_01_red.json new file mode 100644 index 00000000..5fcfe1ad --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D009_01_red.json @@ -0,0 +1,45 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_red", + "test_objective": "Verify that, when one has two redirect registrations on a Context Broker, one is able to replace a target entity on both the Context Sources", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.19, 6.3.18", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.19", + "6.3.18" + ], + "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": "D009_01_red Replace Entity Attribute", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_red", + "doc": "Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Sources thanks to the redirect registrations", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_19", + "6_3_18", + "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": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute", + "robotfile": "D009_01_red" +} \ No newline at end of file -- GitLab From da8899d945ff354c12832491ce4b9edc4e033f89 Mon Sep 17 00:00:00 2001 From: Benedetta Arena Date: Tue, 25 Nov 2025 15:24:31 +0100 Subject: [PATCH 3/3] feat: implement new test for exclusive --- .../ReplaceEntityAttribute/D009_01_exc.robot | 65 +++++++++++++++++++ .../ReplaceEntityAttribute/D009_01_red.robot | 4 +- .../Provision/D009_01_exc.json | 45 +++++++++++++ 3 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_exc.robot create mode 100644 doc/files/DistributedOperations/Provision/D009_01_exc.json diff --git a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_exc.robot new file mode 100644 index 00000000..07c5f142 --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_exc.robot @@ -0,0 +1,65 @@ +*** Settings *** +Documentation Verify that, when one has an exclusive registration on a Context Broker, one is able to replace a target entity attribute and the change is forwarded to 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_id_prefix} urn:ngsi-ld:Vehicle: +${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${entity_attribute_filename} fragmentEntities/vehicle-speed-two-datasetid-01-fragment.json +${registration_id_prefix} urn:ngsi-ld:Registration: +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld + +*** Test Cases *** +D009_01_exc Replace Entity Attribute + [Documentation] Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Source thanks to an exclusive registration + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-exclusive 4_3_6_3 5_6_19 6_3_18 + + ${attribute_payload}= Load Entity ${entity_attribute_filename} ${entity_id} + Set Stub Reply PUT /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/speed 204 + + ${response}= Replace Attribute Selecting Content Type + ... entity_id=${entity_id} + ... attr_id=speed + ... attribute_fragment=${attribute_payload} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Request Count PUT /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/speed + Should Be Equal ${stub_count} 1 + +*** 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 Context Source Registration ${registration_id} + Delete Entity by Id ${entity_id} \ No newline at end of file diff --git a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot index 78d8eade..a85571a3 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute/D009_01_red.robot @@ -41,9 +41,9 @@ D009_01_red Replace Entity Attribute Check Response Status Code 204 ${response.status_code} ${stub_count}= Get Stub Request Count PUT /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/speed - Should Be Equal 1 ${stub_count} + Should Be Equal ${stub_count} 1 ${stub_count}= Get Stub Request Count PUT /broker2/ngsi-ld/v1/entities/${entity_id}/attrs/speed - Should Be Equal 1 ${stub_count} + Should Be Equal ${stub_count} 1 *** Keywords *** Setup Registration And Start Context Source Mock Server diff --git a/doc/files/DistributedOperations/Provision/D009_01_exc.json b/doc/files/DistributedOperations/Provision/D009_01_exc.json new file mode 100644 index 00000000..47882986 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D009_01_exc.json @@ -0,0 +1,45 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_exc", + "test_objective": "Verify that, when one has an exclusive registration on a Context Broker, one is able to replace a target entity attribute and the change is forwarded to the Context Source", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.19, 6.3.18", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.19", + "6.3.18" + ], + "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": "D009_01_exc Replace Entity Attribute", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/EA/D009_01_exc", + "doc": "Check that one can replace an existing entity attribute, the changes will be forwarded to the Context Source thanks to an exclusive registration", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_19", + "6_3_18", + "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": "PUT", + "endpoint": "entities/{entity_id}/attrs/{attr_id}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/EntityAttributes/ReplaceEntityAttribute", + "robotfile": "D009_01_exc" +} \ No newline at end of file -- GitLab