From f57409f34b0c84324deb6845266288e659653139 Mon Sep 17 00:00:00 2001 From: kzangeli Date: Fri, 5 Jun 2026 14:38:38 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20D012=5F01=5Fexc=20/=20D015=5F01=5Fexc=20?= =?UTF-8?q?=E2=80=94=20complete=20the=20=C2=A7=209.3.3=20exclusive-pinning?= =?UTF-8?q?=20sweep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The exclusive-mode batch tests were restructured to satisfy TS 104-175 § 9.3.3 (exclusive registrations pin specific entity ids; an exclusive claim must not overlap an Attribute the broker stores locally): D013/D014/D016 use entity_id= + entity_id2= with the two-group fixture context-source-registration-vehicle-speed-with-batch-ops-exclusive. D012_01_exc and D015_01_exc were missed — their registrations still used entity_id_pattern=urn:ngsi-ld:Vehicle:* and got 400, and D015's local twins carried the claimed 'speed' attribute, earning a 409. With setup failing, teardown crashed on unset suite variables and the two local=true setup entities leaked into every later unpinned type=Vehicle query: D001_01_inc / D001_02_inc / D001_03_03_inc fail with 'Lengths are different: 1 != 5' in full-suite runs. Same recipe as the sweep: pinned ids + the exclusive fixture, and D015's local twins move to vehicle-simple-attributes-second.jsonld (no 'speed'). The entity_id2= keyword support and the exclusive fixture are re-declared identically to their origin branch (unmerged MR) — git deduplicates on merge. Analysis recorded as testsuite-doubts.md #95. --- .../CreateBatchOfEntities/D012_01_exc.robot | 5 ++- .../DeleteBatchOfEntities/D015_01_exc.robot | 7 ++-- ...icle-speed-with-batch-ops-exclusive.jsonld | 29 +++++++++++++++ .../ContextSourceRegistration.resource | 8 ++++ testsuite-doubts.md | 37 +++++++++++++++++++ 5 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 data/csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops-exclusive.jsonld diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/CreateBatchOfEntities/D012_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/CreateBatchOfEntities/D012_01_exc.robot index 443e6865..d6c14efe 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/CreateBatchOfEntities/D012_01_exc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/CreateBatchOfEntities/D012_01_exc.robot @@ -18,7 +18,7 @@ Test Teardown Delete Created Entity And Registration And Stop Context Sour ${entity_payload_filename} vehicle-simple-attributes.jsonld ${entity_speed_payload_filename} vehicle-speed-attribute.jsonld ${entity_pattern} urn:ngsi-ld:Vehicle:* -${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops.jsonld +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops-exclusive.jsonld *** Test Cases *** @@ -59,7 +59,8 @@ 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_id_pattern=${entity_pattern} + ... entity_id=${first_entity_id} + ... entity_id2=${second_entity_id} ... mode=exclusive ... endpoint=/broker1 ${response}= Create Context Source Registration With Return ${registration_payload} diff --git a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/DeleteBatchOfEntities/D015_01_exc.robot b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/DeleteBatchOfEntities/D015_01_exc.robot index b00be3e8..53af542f 100644 --- a/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/DeleteBatchOfEntities/D015_01_exc.robot +++ b/TP/NGSI-LD/DistributedOperations/Provision/BatchEntities/DeleteBatchOfEntities/D015_01_exc.robot @@ -11,9 +11,9 @@ Resource ${EXECDIR}/resources/MockServerUtils.resource Test Setup Create Entities And Registration And Start Context Source Mock Server Test Teardown Delete Registration And Stop Context Source Mock Server *** Variables *** -${entity_payload_filename} vehicle-simple-different-attributes.jsonld +${entity_payload_filename} vehicle-simple-attributes-second.jsonld ${entity_pattern} urn:ngsi-ld:Vehicle:* -${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops.jsonld +${registration_payload_file_path} csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops-exclusive.jsonld *** Test Cases *** D015_01_exc Delete Batch Of Entities On Both Context Broker And Context Source @@ -54,7 +54,8 @@ Create Entities And Registration And Start Context Source Mock Server ${registration_payload}= Prepare Context Source Registration From File ... ${registration_id} ... ${registration_payload_file_path} - ... entity_id_pattern=${entity_pattern} + ... entity_id=${first_entity_id} + ... entity_id2=${second_entity_id} ... mode=exclusive ... endpoint=/broker1 ${response}= Create Context Source Registration With Return ${registration_payload} diff --git a/data/csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops-exclusive.jsonld b/data/csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops-exclusive.jsonld new file mode 100644 index 00000000..5961a605 --- /dev/null +++ b/data/csourceRegistrations/context-source-registration-vehicle-speed-with-batch-ops-exclusive.jsonld @@ -0,0 +1,29 @@ +{ + "id": "urn:ngsi-ld:ContextSourceRegistration:randomUUID", + "type": "ContextSourceRegistration", + "information": [ + { + "entities": [ + { + "id": "urn:ngsi-ld:Vehicle:randomUUID", + "type": "Vehicle" + } + ], + "propertyNames":["speed"] + }, + { + "entities": [ + { + "id": "urn:ngsi-ld:Vehicle:randomUUID2", + "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" + ] +} diff --git a/resources/ApiUtils/ContextSourceRegistration.resource b/resources/ApiUtils/ContextSourceRegistration.resource index 5263add9..6c334031 100755 --- a/resources/ApiUtils/ContextSourceRegistration.resource +++ b/resources/ApiUtils/ContextSourceRegistration.resource @@ -33,6 +33,7 @@ Prepare Context Source Registration From File ... ${endpoint}=${EMPTY} ... ${broker_url}=${EMPTY} ... ${operations}=[] + ... ${entity_id2}=${EMPTY} ${payload}= Load JSON From File ${EXECDIR}/data/${registration_file} ${final_context_source_url}= Set Variable If '${broker_url}' != '' ${broker_url} ${context_source_url} @@ -51,6 +52,13 @@ Prepare Context Source Registration From File ... $..entities[*] ... ${dict} END + IF '${entity_id2}' != '' + ${dict}= Create Dictionary id=${entity_id2} + ${registration_payload}= Add Object To JSON + ... ${registration_payload} + ... $.information[1].entities[*] + ... ${dict} + END IF '${entity_id_pattern}' != '' ${dict}= Create Dictionary idPattern=${entity_id_pattern} ${registration_payload}= Add Object To JSON diff --git a/testsuite-doubts.md b/testsuite-doubts.md index 50417d0d..7d43af9b 100644 --- a/testsuite-doubts.md +++ b/testsuite-doubts.md @@ -2667,3 +2667,40 @@ doesn't match the URL id. `$.id` with the actual `${entity_id}` before PATCHing. Or omit the `id` from the fragment entirely (PATCH attrs doesn't need it). + + +## 95. `D012_01_exc` / `D015_01_exc` — missed by the § 9.3.3 exclusive-pinning sweep; their setup failures leak entities into D001/D011 + +**Hit (full-suite runs):** both tests fail in setup — the CSR create returns +400 (`exclusive Registration 'entities[]' entry must specify a specific +'id'`), and for D015 (after pinning) 409 (`registration overlaps with +locally-stored entity`). Because setup aborts before the test body sets its +suite variables, the teardown crashes (`Variable '@{expected_entities_ids}' +not found` / 404 on the registration delete) and the two `local=true` +entities created in setup are never removed. Those leaked Vehicles then +surface in every later unpinned `type=Vehicle` query — +`D001_01_inc` / `D001_02_inc` / `D001_03_03_inc` fail with +`Lengths are different: 1 != 5`. + +**Analysis:** the exclusive-mode batch tests were restructured to satisfy +TS 104-175 § 9.3.3 (an exclusive registration shall pin specific entity ids; +the broker also rejects an exclusive claim over an entity it stores locally +with the claimed Attribute): `D013_*_exc` / `D014_*_exc` / `D016_01_exc` use +`entity_id=` + `entity_id2=` and the two-information-group fixture +`context-source-registration-vehicle-speed-with-batch-ops-exclusive.jsonld`, +and seed their local twins without the exclusively-claimed `speed`. +`D012_01_exc` and `D015_01_exc` were missed by that sweep and still used +`entity_id_pattern=urn:ngsi-ld:Vehicle:*` (D015 additionally seeding local +twins WITH `speed` — `vehicle-simple-different-attributes.jsonld`). + +**Fix:** same recipe as the sweep — + +- both tests register with `entity_id=` + `entity_id2=` and the + `…-with-batch-ops-exclusive.jsonld` fixture; +- D015's local twins switch to `vehicle-simple-attributes-second.jsonld` + (no `speed`), so the exclusive claim doesn't overlap locally-stored + Attributes. + +(The `entity_id2=` keyword support and the exclusive fixture are +re-declared identically to their origin branch since that MR is unmerged — +git deduplicates on merge.) -- GitLab