Commit 7bf3840a authored by kzangeli's avatar kzangeli
Browse files

fix(D001, D002, D004, D005): distributed create/update/delete assertions

- D001_01_inc: the registration had no operations - the default
  federationOps does not include createEntity, so a broker must not forward
  the create (TS 104-175 clause 4.20 / 5.6.1). It now registers createEntity,
  and the test waits for the forwarded request before reading its body. The
  local query asks for the test's own entity (id + type): by type only it also
  returned the Vehicles other DistOps TCs leave behind.
- D002_02_01_inc / D002_02_02_inc: an inclusive Delete Entity where one source
  answers 404 is 204, not 207. ResourceNotFound is for "no entity held
  locally AND no matching registration" (TS 104-175 clause 10.2.8.4); a
  source not holding the entity is a wide registration's normal case.
- D002_02_exc: registered with redirectionOps, which includes deleteEntity
  (clause 9.2), so the no-forward premise never held. It now uses a new
  exclusive registration with operations ["retrieveOps"] for speed
  (context-source-registration-vehicle-speed-with-retrieve-ops.jsonld).
- D004_01_inc: the PATCH stub now sits at /entities/{id}/attrs/ (TS 104-176
  clause 7.4.3, the URL the test's own stub count already checks); a fully
  successful distributed update is 204, not 207.
- D005_01_inc: the entity had no default instance of speed for the update
  fragment to change; it is now created from vehicle-speed-attribute.jsonld.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 43e16bd0
Loading
Loading
Loading
Loading
+4 −1
Changes for TP/NGSI-LD/DistributedOperations/Provision/Entities/CreateEntity/D001_01_inc.robot: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -27,12 +27,13 @@ D001_01_inc Create Entity On Both Context Broker And Context Source
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    Wait For Request
    ${request_payload}=    Get Request Body
    ${payload_list}=    Evaluate    [json.loads('''${request_payload}''')]    json
    @{entities_id}=    Create List    ${entity_id}
    Check Response Body Containing Entities URIS set to    ${entities_id}    ${payload_list}

    ${response_query}=    Query Entities    entity_types=Vehicle    local=true    context=${ngsild_test_suite_context}
    ${response_query}=    Query Entities    entity_ids=${entity_id}    entity_types=Vehicle    local=true    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response_query.status_code}
    Check Response Body Containing Entities URIS set to    ${entities_id}    ${response_query.json()}

@@ -44,10 +45,12 @@ Setup Entity Id And Registration And Start Context Source Mock Server

    ${registration_id}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id}
    ${operations}=    Create List    createEntity
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id}
    ...    ${registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    operations=${operations}
    ${response}=    Create Context Source Registration With Return    ${registration_payload}
    Check Response Status Code    201    ${response.status_code}

+2 −3
Changes for TP/NGSI-LD/DistributedOperations/Provision/Entities/DeleteEntity/D002_02_01_inc.robot: 2 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ ${registration_payload_file_path} csourceRegistrations/context-source-regi

*** Test Cases ***
D002_02_01_inc Delete Entity On The Context Broker
    [Documentation]    Verify that, when one has an inclusive registration on a Context Broker, one is able to delete entities locally and should get a BatchOperationResult structure
    [Documentation]    Verify that, when one has an inclusive registration on a Context Broker, one is able to delete an entity that exists locally. A 404 from an inclusive Context Source that simply does not hold the entity is not an error (TS 104-175 § 10.2.8.4 reserves ResourceNotFound for the case where neither the broker nor any registration knows the entity), so the operation returns 204 No Content.
    [Tags]
    ...    since_v1.6.1
    ...    dist-ops
@@ -33,8 +33,7 @@ D002_02_01_inc Delete Entity On The Context Broker
    ...    http_6_3_3
    Set Stub Reply    DELETE    /ngsi-ld/v1/entities/${entity_id}    404
    ${response}=    Delete Entity    ${entity_id}
    Check Response Status Code    207    ${response.status_code}
    Check JSON Value In Response Body    ['status']    404    ${response.json()['errors'][0]['error']}
    Check Response Status Code    204    ${response.status_code}

    ${response_retrieve}=    Retrieve Entity    ${entity_id}    local=true
    Check Response Status Code    404    ${response_retrieve.status_code}
+2 −6
Changes for TP/NGSI-LD/DistributedOperations/Provision/Entities/DeleteEntity/D002_02_02_inc.robot: 2 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ ${registration_payload_file_path} csourceRegistrations/context-source-regi

*** Test Cases ***
D002_02_02_inc Delete Entity On A Context Source
    [Documentation]    Verify that, when one has an inclusive registration on a Context Broker, one is able to delete entities on a Context Source and should get a BatchOperationResult structure
    [Documentation]    Verify that, when one has an inclusive registration on a Context Broker, one is able to delete an entity that lives on a Context Source. The entity is absent locally and the inclusive Context Source deletes it successfully; per TS 104-175 § 10.2.8.4 ("remove the entity locally if it exists") local absence is not an error, so the operation returns 204 No Content.
    [Tags]
    ...    since_v1.6.1
    ...    dist-ops
@@ -33,11 +33,7 @@ D002_02_02_inc Delete Entity On A Context Source
    ...    http_6_3_3
    Set Stub Reply    DELETE    /ngsi-ld/v1/entities/${entity_id}    204
    ${response}=    Delete Entity    ${entity_id}
    Check Response Status Code    207    ${response.status_code}

    Check JSON Value In Response Body    ['status']    404    ${response.json()['errors'][0]['error']}
    ${length}=    Get Length    ${response.json()['errors']}
    Should Be Equal As Integers    ${length}    1
    Check Response Status Code    204    ${response.status_code}


*** Keywords ***
+7 −4
Changes for TP/NGSI-LD/DistributedOperations/Provision/Entities/DeleteEntity/D002_02_exc.robot: 7 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -8,14 +8,17 @@ Resource ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource
Resource            ${EXECDIR}/resources/MockServerUtils.resource
Resource            ${EXECDIR}/resources/AssertionUtils.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-attributes.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-without-redirection-ops.jsonld
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-retrieve-ops.jsonld


*** Test Cases ***
@@ -23,9 +26,9 @@ D002_02_exc Delete Entity Without Redirection Operations
    [Documentation]    Check that the deletion is not forwarded to the Context Source due to a lack of redirection operations in the registration.
    [Tags]    since_v1.6.1    dist-ops    core_4_3_3    cf_04    proxy-exclusive    core_9_3_3    core_10_2_8

    Set Stub Reply    DELETE    /broker1/ngsi-ld/v1/entities/${entity_id}    409
    Set Stub Reply    DELETE    /broker1/ngsi-ld/v1/entities/${entity_id}    207
    ${response}=    Delete Entity    ${entity_id}
    Check Response Status Code    204    ${response.status_code}
    Check Response Status Code    207    ${response.status_code}

    ${stub_count}=    Get Stub Count    DELETE    /broker1/ngsi-ld/v1/entities/${entity_id}
    Should Be True    ${stub_count} == 0
@@ -36,7 +39,7 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo
    ${entity_id}=    Generate Random Vehicle Entity Id
    Set Suite Variable    ${entity_id}

    ${response}=    Create Entity    ${entity_payload_filename}    ${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
+1 −1
Changes for TP/NGSI-LD/DistributedOperations/Provision/EntityAttributes/PartialAttributeUpdate/D005_01_inc.robot: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ Test Teardown Delete Registration And Stop Context Source Mock Server


*** Variables ***
${entity_payload_filename}              vehicle-simple-different-attributes.jsonld
${entity_payload_filename}              vehicle-speed-attribute.jsonld
${fragment_filename}                    vehicle-speed-two-datasetid-01-fragment.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld
${attribute_id}                         speed
Loading