Commit 1b94f585 authored by kzangeli's avatar kzangeli
Browse files

fix(distops): exclusive-CSR setups must be id-specific and not overlap local data

Nine DistOps tests failed at suite setup against a broker that enforces
TS 104-175 § 9.3.3 on registration creation:

1. idPattern exclusives (400) — D013_01_exc, D013_02_exc, D014_01_exc,
   D014_02_exc, D016_01_exc registered ONE exclusive CSR with
   entity_id_pattern=urn:ngsi-ld:Vehicle:*. § 9.3.3: "an id pattern or
   Entity type defining a group of entities is not supported for
   exclusive registrations". New fixture
   context-source-registration-vehicle-speed-with-batch-ops-exclusive.jsonld
   carries two id-specific information[] elements (one per batch entity,
   each with propertyNames:["speed"]) — still one registration, one
   endpoint, one stub, so the stub_count=1 assertions hold. The Prepare
   keyword gains an optional entity_id2= (appended last, callers by name)
   that injects the second id into $.information[1].entities[*].

2. local-overlap (409) — D005_01_exc, D009_01_exc (and D014_01/02_exc)
   created the entities from vehicle-simple-different-attributes
   (speed, isParked2) BEFORE registering an exclusive CSR on speed. The
   broker shall hold no local data for exclusively-registered attributes,
   so creation-time conflict checking answers 409. Create from
   vehicle-simple-attributes-second (brandName, isParked2) instead —
   keeps the isParked2 the D005 assertions track, drops the local speed.
   § 9.3.3 explicitly permits unregistered attributes locally.

3. redirect + local entity (409) — D006_01_red, D006_02_red created the
   entity locally and then registered two redirect CSRs over it. For
   redirect, "the Context Broker itself holds no data locally in conflict
   to the registration". The bodies never touch the local entity (pure
   forward assertions), so simply drop the local create.

Also: D013_01/02_exc asserted the forwarded batch body contains the FULL
entities; an exclusive forward carries only the registered slice
(chop-and-forward), so assert containment of the entity ids and the
registered attribute instead.

Verified against swBroker: D013_01_exc, D014_01_exc, D016_01_exc,
D006_01_red, D006_02_red now PASS end-to-end; D013_02_exc/D014_02_exc
proceed to the known Get-Request-Url-Params stub-mode crash,
D005_01_exc to the name-wrapped-fragment issue, D009_01_exc to the
GET-stub body/query-match issues — all separately documented.
parent bdc618f6
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ Test Teardown Delete Created Entity And Registration And Stop Context Sour
${entity_payload_filename}              vehicle-simple-attributes-second.jsonld
${entity_second_payload_filename}       vehicle-simple-attributes-second-different.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 ***
D016_01_exc Merge Batch Entities On Both Context Broker And Context Source
@@ -63,7 +63,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
@@ -14,10 +14,10 @@ Test Setup Setup 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
${update_payload_filename}              expectations/vehicle-replace-isParked-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 *** 
D014_01_exc Update Batch Entities without noOverwrite Option
@@ -53,7 +53,8 @@ Setup 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
    ${response1}=    Create Context Source Registration With Return    ${registration_payload}
+4 −3
Original line number Diff line number Diff line
@@ -12,10 +12,10 @@ Test Setup Setup 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
${update_payload_filename}              expectations/vehicle-replace-isParked-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 *** 
D014_02_exc Update Batch Entities with noOverwrite Option
@@ -54,7 +54,8 @@ Setup 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
    ${response1}=    Create Context Source Registration With Return    ${registration_payload}
+6 −5
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ Test Teardown Delete Created Entity And Registration And Stop Context Sour
${old_entity_payload_filename}              vehicle-simple-attributes-second.jsonld
${new_entity_payload_filename}              vehicle-simple-different-attributes.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 ***
D013_01_exc Batch Upsert Entities With Exclusive Registration Without Update Flag
@@ -35,9 +35,9 @@ D013_01_exc Batch Upsert Entities With Exclusive Registration Without Update Fla
    
    Wait for redirected request
    ${request_payload}=    Get Request Body
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Should Contain    ${payload}    ${new_first_entity}
    Should Contain    ${payload}    ${new_second_entity}
    Should Contain    ${request_payload}    ${first_entity_id}
    Should Contain    ${request_payload}    ${second_entity_id}
    Should Contain    ${request_payload}    speed
    
    ${stub_count}=    Get Stub Count    POST    /broker1/ngsi-ld/v1/entityOperations/upsert
    Should Be Equal    ${stub_count}    1
@@ -57,7 +57,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}
+6 −5
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ Test Teardown Delete Created Entity And Registration And Stop Context Sour
${old_entity_payload_filename}              vehicle-simple-attributes-second.jsonld
${new_entity_payload_filename}              vehicle-simple-different-attributes.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 ***
D013_02_exc Batch Upsert Entities With Exclusive Registration With Update Flag
@@ -39,9 +39,9 @@ D013_02_exc Batch Upsert Entities With Exclusive Registration With Update Flag

    Wait for redirected request
    ${request_payload}=    Get Request Body
    ${payload}=    Evaluate    json.loads('''${request_payload}''')    json
    Should Contain    ${payload}    ${new_first_entity}
    Should Contain    ${payload}    ${new_second_entity}
    Should Contain    ${request_payload}    ${first_entity_id}
    Should Contain    ${request_payload}    ${second_entity_id}
    Should Contain    ${request_payload}    speed
    
    ${stub_count}=    Get Stub Count    POST    /broker1/ngsi-ld/v1/entityOperations/upsert
    Should Be Equal    ${stub_count}    1
@@ -61,7 +61,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}
Loading