diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/ReplaceEntity/D007_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/ReplaceEntity/D007_01_exc.robot new file mode 100644 index 0000000000000000000000000000000000000000..b3bc342d36244ecf38f75a0ed2e813d7694c910f --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/ReplaceEntity/D007_01_exc.robot @@ -0,0 +1,66 @@ +*** Settings *** +Documentation Verify that, when one has an exclusive registration on a Context Broker, one is able to replace the entity on 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.jsonld +${entity_replacement} vehicle-simple-different-attributes.json +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld + +*** Test Cases *** +D007_01_exc Replace Entity + [Documentation] Check that if one requests the Context Broker to replace an entity that matches an exclusive registration, the entity is replaced 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_18 + + Set Stub Reply PUT /broker1/ngsi-ld/v1/entities/${entity_id} 204 + ${response}= Replace Entity + ... entity_id=${entity_id} + ... filename=${entity_replacement} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count PUT /broker1/ngsi-ld/v1/entities/${entity_id} + Should Be Equal ${stub_count} 1 + + ${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 Context Source Registration ${registration_id} + Delete Entity By Id ${entity_id} + Stop Context Source Mock Server diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/ReplaceEntity/D007_01_inc.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/ReplaceEntity/D007_01_inc.robot new file mode 100644 index 0000000000000000000000000000000000000000..5f12ef1f3964b3738588059b77123fc18604191b --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/ReplaceEntity/D007_01_inc.robot @@ -0,0 +1,70 @@ +*** Settings *** +Documentation Verify that, when one has an inclusive registration on a Context Broker, one is able to replace an entity 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 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.json +${entity_replacement} vehicle-simple-attributes-second.json +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + + +*** Test Cases *** +D007_01_inc Replace Entity + [Documentation] Check that if one requests the Context Broker to replace an entity that matches an inclusive registration, this is replaced 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_18 + + ${response}= Retrieve Entity by Id ${entity_id} context=${ngsild_test_suite_context} + ${old_body}= Set To Dictionary ${response.json()} + + Set Stub Reply PUT /ngsi-ld/v1/entities/${entity_id} 204 + ${response}= Replace Entity + ... entity_id=${entity_id} + ... filename=${entity_replacement} + ... 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_body}= Set To Dictionary ${response.json()} + Should Not Be Equal ${old_body} ${new_body} + +*** 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 Selecting Content Type + ... ${entity_payload_filename} + ... ${entity_id} + ... ${CONTENT_TYPE_JSON} + ... ${ngsild_test_suite_context} + 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 Context Source Registration ${registration_id} + Delete Entity By Id ${entity_id} + Stop Context Source Mock Server diff --git a/TP/NGSI-LD/DistributedOperations/Provision/Entities/ReplaceEntity/D007_01_red.robot b/TP/NGSI-LD/DistributedOperations/Provision/Entities/ReplaceEntity/D007_01_red.robot new file mode 100644 index 0000000000000000000000000000000000000000..2dbf53dedc6e94a13ea84aff6c2d445bd07490cc --- /dev/null +++ b/TP/NGSI-LD/DistributedOperations/Provision/Entities/ReplaceEntity/D007_01_red.robot @@ -0,0 +1,74 @@ +*** Settings *** +Documentation Verify that, when one has a redirect registration on a Context Broker, one is able to replace the entities 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 Entity Id And 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.jsonld +${entity_replacement} vehicle-simple-attributes-second.json +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld + +*** Test Cases *** +D007_01_red Replace Entity + [Documentation] Check that if one requests the Context Broker to replace an entity that matches redirect registrations, the entity is replaced on the Context Sources + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-redirect 4_3_6_3 5_6_18 + + Set Stub Reply PUT /broker1/ngsi-ld/v1/entities/${entity_id} 204 + Set Stub Reply PUT /broker2/ngsi-ld/v1/entities/${entity_id} 204 + + ${response}= Replace Entity + ... entity_id=${entity_id} + ... filename=${entity_replacement} + ... content_type=${CONTENT_TYPE_JSON} + ... context=${ngsild_test_suite_context} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count PUT /broker1/ngsi-ld/v1/entities/${entity_id} + Should Be Equal ${stub_count} 1 + ${stub_count}= Get Stub Count PUT /broker2/ngsi-ld/v1/entities/${entity_id} + Should Be Equal ${stub_count} 1 + +*** Keywords *** +Setup Entity Id And 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_payload}= Prepare Context Source Registration From File + ... ${registration_id2} + ... ${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 + +Delete Created Entity And 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/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/AppendEntityAttributes/D003_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/AppendEntityAttributes/D003_01_exc.robot index c6ece0bea2ecfc9ab6a094ffe3f42175e493d658..6967513ba120e9a7a5298a48a12e243ef94542ec 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/AppendEntityAttributes/D003_01_exc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/AppendEntityAttributes/D003_01_exc.robot @@ -12,6 +12,68 @@ Test Setup Create Entity And Registration On The Context Broker And Sta Test Teardown Delete Registration And Stop Context Source Mock Server +*** Variables *** +${entity_payload_filename} vehicle-simple-attributes.jsonld +${fragment_filename} vehicle-speed-isParked-fragment.json +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld + +*** Test Cases *** +D003_01_exc Append Entity Attribute + [Documentation] Check that an entity attribute is appended and the exclusive registration forwards the request to the Context Source + [Tags] since_v1.6.1 dist-ops 4_3_3 cf_06 proxy-exclusive 4_3_6_3 5_6_3 + + Set Stub Reply POST /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/ 204 + ${response}= Append Entity Attributes + ... ${entity_id} + ... ${fragment_filename} + ... ${CONTENT_TYPE_JSON} + Check Response Status Code 204 ${response.status_code} + + ${stub_count}= Get Stub Count POST /broker1/ngsi-ld/v1/entities/${entity_id}/attrs/ + Should Be Equal ${stub_count} 1 + + ${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 Registration And Stop Context Source Mock Server + Delete Context Source Registration ${registration_id} + Delete Entity by Id ${entity_id} + Stop Context Source Mock Server +*** Settings *** +Documentation Check that when appending entity attributes to an entity with an exclusive registration, the attributes managed locally are updated on the Context Broker, while attributes managed with the exclusive registration are updated in the Context Source. + +Resource ${EXECDIR}/resources/ApiUtils/Common.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.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 Registration And Stop Context Source Mock Server + + *** Variables *** ${entity_payload_filename} vehicle-simple-attributes.jsonld ${fragment_filename} vehicle-speed-isParked-fragment.json diff --git a/data/csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld b/data/csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld index b1798060b56ef16a88b88829b549d2cad3f63e69..643ffd4ccaa806df3626516f2c8810946933b8c0 100644 --- a/data/csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld +++ b/data/csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld @@ -1,3 +1,4 @@ + { "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", "type": "ContextSourceRegistration", @@ -8,7 +9,6 @@ "id": "urn:ngsi-ld:Vehicle:randomUUID", "type": "Vehicle" } - ], "propertyNames":["speed"] } diff --git a/data/entities/vehicle-simple-different-attributes.json b/data/entities/vehicle-simple-different-attributes.json new file mode 100644 index 0000000000000000000000000000000000000000..63005769af3a2ad1ea80d91836e18c522ab2741e --- /dev/null +++ b/data/entities/vehicle-simple-different-attributes.json @@ -0,0 +1,22 @@ +{ + "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": "2017-07-29T12:00:04Z", + "providedBy": { + "type": "Relationship", + "object": "urn:ngsi-ld:Person:Alice" + } + } +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D007_01_exc.json b/doc/files/DistributedOperations/Provision/D007_01_exc.json new file mode 100644 index 0000000000000000000000000000000000000000..862fc36c16e17eb5739b9234a0ecc8743c270bd9 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D007_01_exc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D007_01_exc", + "test_objective": "Verify that, when one has an exclusive registration on a Context Broker, one is able to replace the entity on the Context Source", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.18", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.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": "D007_01_exc Replace Entity", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D007_01_exc", + "doc": "Check that if one requests the Context Broker to replace an entity that matches an exclusive registration, the entity is replaced on the Context Source too", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_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": "", + "endpoint": "" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/Entities/ReplaceEntity", + "robotfile": "D007_01_exc" +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D007_01_inc.json b/doc/files/DistributedOperations/Provision/D007_01_inc.json new file mode 100644 index 0000000000000000000000000000000000000000..a9163dc7621b75c7264f262a0a42b28d1660dcce --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D007_01_inc.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D007_01_inc", + "test_objective": "Verify that, when one has an inclusive registration on a Context Broker, one is able to replace an entity on both Context Broker and Context Source", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.2, 5.6.18", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.2", + "5.6.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": "D007_01_inc Replace Entity", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D007_01_inc", + "doc": "Check that if one requests the Context Broker to replace an entity that matches an inclusive registration, this is replaced on the Context Source too", + "tags": [ + "4_3_3", + "4_3_6_2", + "5_6_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": "", + "endpoint": "" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/Entities/ReplaceEntity", + "robotfile": "D007_01_inc" +} \ No newline at end of file diff --git a/doc/files/DistributedOperations/Provision/D007_01_red.json b/doc/files/DistributedOperations/Provision/D007_01_red.json new file mode 100644 index 0000000000000000000000000000000000000000..96494ba082d4d5f764cc762841fc2240dd36baf8 --- /dev/null +++ b/doc/files/DistributedOperations/Provision/D007_01_red.json @@ -0,0 +1,43 @@ +{ + "tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D007_01_red", + "test_objective": "Verify that, when one has a redirect registration on a Context Broker, one is able to replace the entities on the Context Sources", + "reference": "ETSI GS CIM 009 V1.6.1 [], clauses 4.3.3, 4.3.6.3, 5.6.18", + "config_id": "", + "parent_release": "v1.6.1", + "clauses": [ + "4.3.3", + "4.3.6.3", + "5.6.18" + ], + "pics_selection": "", + "keywords": [ + "Setup Entity Id And 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 an initial Entity id set to ${entity_id}\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": "D007_01_red Replace Entity", + "permutation_tp_id": "TP/NGSI-LD/DistributedOperations/Prov/E/D007_01_red", + "doc": "Check that if one requests the Context Broker to replace an entity that matches redirect registrations, the entity is replaced on the Context Sources", + "tags": [ + "4_3_3", + "4_3_6_3", + "5_6_18", + "cf_06", + "dist-ops", + "proxy-redirect", + "since_v1.6.1" + ], + "setup": "Setup Entity Id And 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}" + } + ], + "permutations": [], + "robotpath": "DistributedOperations/Provision/Entities/ReplaceEntity", + "robotfile": "D007_01_red" +} \ No newline at end of file