Commit f57409f3 authored by kzangeli's avatar kzangeli
Browse files

fix: D012_01_exc / D015_01_exc — complete the § 9.3.3 exclusive-pinning sweep

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.
parent d9a20233
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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}
+4 −3
Original line number Diff line number Diff line
@@ -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}
+29 −0
Original line number Diff line number Diff line
{
  "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"
 ]
}
+8 −0
Original line number Diff line number Diff line
@@ -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
+37 −0
Original line number Diff line number Diff line
@@ -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.)