Fix relative path in context and endpoint being overwritten with a partial path

  1. @context relative reference → absolute URL resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld declared one of its @context entries as a bare relative filename ("ngsi-ld-test-suite.jsonld") instead of a fully-qualified URL. Brokers that don't perform relative-IRI resolution on nested/imported JSON-LD contexts (confirmed with Scorpio) fail to resolve it and reject any request carrying this context with LdContextNotAvailable (503). Fixed by making the entry an absolute URL.

  2. context_source_url vs endpoint when creating CSourceRegistrations Distributed-operations tests previously built the registration endpoint inline at each call site (endpoint=${context_source_url}/broker1), duplicated across every test file. Centralized this so tests pass only the relative suffix (endpoint=/broker1) and the base URL is resolved in one place. Prevents drift between tests and makes it possible to point the whole suite at a different reachable host (e.g. host.docker.internal when the broker under test runs in Docker and needs to reach the stub server on the host) via a single variable instead of editing every test.

  3. Mock stub-matching fixes (HttpCtrl/http_stub.py) The vendored mock library's stub matcher had a loose fallback for GET requests whose query string doesn't exactly match a registered stub (needed because brokers forward distributed retrieveEntity/query operations with extra query parameters, e.g. ?sysAttrs=true or ?id=...&type=...). The fallback only checked that entity-id fragments appeared somewhere in the request URL — it never checked the request's base path/prefix. As a result, a stub registered for one Context Source (/broker1/...) could silently satisfy a request actually sent to a different Context Source (/broker2/...), since both reference the same entity id. This made multi-source redirect tests (two overlapping mode: redirect registrations for the same entity) pass through only one of the two registered stubs and never exercise the second, hiding real distributed-operations behavior — including cases where the entity broker actually does correctly query both sources.

Fixed the matcher to require the request's base path to match the stub's own path, handling both URL shapes seen across broker implementations:

id kept in the path, extra query params appended (e.g. .../entities/{id}?sysAttrs=true) id moved out of the path into a query parameter (e.g. .../entities?id=...&type=...) Verified against two broker implementations with different redirect URL shapes (Scorpio and Coraine/Seamware with --distributed) — both now correctly attribute each forwarded request to the Context Source that actually made it, and multi-source responses merge as expected.

Merge request reports

Loading
+2 −10
Changes for TP/NGSI-LD/DistributedOperations/Provision/Entities/CreateEntity/D001_01_exc.robot: 2 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -8,17 +8,13 @@ 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
${entity_speed_filename}                vehicle-speed-attribute.jsonld
${registration_id_prefix}               urn:ngsi-ld:Registration:
${entity_payload_filename}              vehicle-simple-different-attributes.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld


@@ -27,7 +23,7 @@ D001_01_exc Create Entity With Exclusive Registration
    [Documentation]    Check that the entity is created correctly on both the Context Broker and the Context Source. The entity shall be retrieved correctly.
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_04    proxy-exclusive    4_3_6_3    5_6_1
    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entities    201
    ${speed_entity}=    Create Entity    ${entity_speed_filename}    ${entity_id}
    ${speed_entity}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${speed_entity.status_code}

    ${stub_count}=    Get Stub Count    POST    /broker1/ngsi-ld/v1/entities
@@ -37,15 +33,11 @@ D001_01_exc Create Entity With Exclusive Registration
    ${body}=    Set To Dictionary    ${response.json()}
    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
+1 −2
Changes for TP/NGSI-LD/DistributedOperations/Provision/Entities/CreateEntity/D001_01_red.robot: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -14,9 +14,7 @@ Test Teardown Delete Registrations And Stop Context Source Mock Server


*** Variables ***
${entity_id_prefix}                     urn:ngsi-ld:Vehicle:
${entity_payload_filename}              vehicle-simple-attributes.jsonld
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld


@@ -67,6 +65,7 @@ Setup Entity Id And Registration And Start Context Source Mock Server
    Check Response Status Code    201    ${response2.status_code}
    
    Start Context Source Mock Server

Delete Registrations And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Context Source Registration    ${registration_id2}
+3 −12
Changes for TP/NGSI-LD/DistributedOperations/Provision/Entities/CreateEntity/D001_02_exc.robot: 3 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -8,19 +8,14 @@ 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
${entity_speed_filename}                vehicle-speed-attribute.jsonld
${registration_id_prefix}               urn:ngsi-ld:Registration:
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-redirection-ops.jsonld

${entity_payload_filename}              vehicle-speed-attribute.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-without-redirection-ops.jsonld

*** Test Cases ***
D001_02_exc Create Entity Without Redirection Operations
@@ -28,21 +23,17 @@ D001_02_exc Create Entity Without Redirection Operations
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_04    proxy-exclusive    4_3_6_3    5_6_1

    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entities    409
    ${response}=    Create Entity    ${entity_speed_filename}    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    409    ${response.status_code}

    ${stub_count}=    Get Stub Count    POST    /broker1/ngsi-ld/v1/entities
    Should Be True    ${stub_count} == 0


*** 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
+9 −11
Changes for TP/NGSI-LD/DistributedOperations/Provision/Entities/DeleteEntity/D002_01_exc.robot: 9 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -8,17 +8,13 @@ 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
${entity_speed_filename}                vehicle-speed-attribute.json
${registration_id_prefix}               urn:ngsi-ld:Registration:
${entity_payload_filename}              vehicle-simple-different-attributes.jsonld
${registration_payload_file_path}       csourceRegistrations/context-source-registration-vehicle-speed-with-redirection-ops.jsonld


@@ -26,7 +22,14 @@ ${registration_payload_file_path} csourceRegistrations/context-source-regi
D002_01_exc Delete Entity With Exclusive Registration
    [Documentation]    Check that the entity is deleted correctly in the Context Broker and in the Context Source.
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_04    proxy-exclusive    4_3_6_3    5_6_6
    ${speed_entity}=    Load Entity    ${entity_speed_filename}    ${entity_id}

    Set Stub Reply    POST    /broker1/ngsi-ld/v1/entities/    201
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}
    Check Response Status Code    201    ${response.status_code}

    ${response}=    Retrieve Entity    ${entity_id}    context=${ngsild_test_suite_context}    local=true
    Check Response Status Code    200    ${response.status_code}
    Should Not Contain    ${response.json()}    speed

    Set Stub Reply    DELETE    /broker1/ngsi-ld/v1/entities/${entity_id}    204
    ${response}=    Delete Entity    ${entity_id}
@@ -34,15 +37,11 @@ D002_01_exc Delete Entity With Exclusive Registration
    ${stub_count}=    Get Stub Count    DELETE    /broker1/ngsi-ld/v1/entities/${entity_id}
    Should Be True    ${stub_count} > 0


*** 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
@@ -58,5 +57,4 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo

Delete Created Entity And Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Entity    ${entity_id}
    Stop Context Source Mock Server
+0 −1
Changes for TP/NGSI-LD/DistributedOperations/Provision/Entities/DeleteEntity/D002_01_inc.robot: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -52,5 +52,4 @@ Create Entity And Registration On The Context Broker And Start Context Source Mo

Delete Created Entity And Registration And Stop Context Source Mock Server
    Delete Context Source Registration    ${registration_id}
    Delete Entity    ${entity_id}
    Stop Context Source Mock Server
Loading
Loading