Commit c4ad0fea authored by Benedetta Arena's avatar Benedetta Arena
Browse files

feat: add second test with four brokers

parent 0bedbf0b
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ Test Teardown Delete Entities and Delete Registrations
${entity_payload_filename}                        interoperability/offstreet-parking1-full.jsonld
${inclusive_registration_payload_file_path}       csourceRegistrations/interoperability/context-source-registration-inclusive-2.jsonld
${exclusive_registration_payload_file_path}       csourceRegistrations/interoperability/context-source-registration-exclusive-2.jsonld
${entity_id}                                      urn:ngsi-ld:OffStreetParking:1
${b1_url}                                         
${b2_url}                                         
${b3_url}                                         
@@ -26,8 +25,6 @@ IOP_CNF_01_01 Create Entity In B1 And Retrieve Entity In All Brokers
    [Tags]    6_1    I6_1_1_1    Inclusive    Exclusive    Interoperability
    
    ${expected_payload}=    Load Entity    ${entity_payload_filename}    ${entity_id}
    ${response}=    Create Entity From File    ${entity_payload_filename}    broker_url=${b1_url}    
    Check Response Status Code    201    ${response.status_code}

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b1_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}
@@ -45,6 +42,11 @@ IOP_CNF_01_01 Create Entity In B1 And Retrieve Entity In All Brokers
*** Keywords ***
Setup Initial Context Source Registrations

    ${entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id1}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id1}
    ${registration_payload}=    Prepare Context Source Registration From File
+5 −4
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ Test Teardown Delete Entities and Delete Registrations
${entity_payload_filename}                        interoperability/offstreet-parking2-full.jsonld
${inclusive_registration_payload_file_path}       csourceRegistrations/interoperability/context-source-registration-inclusive-2.jsonld
${exclusive_registration_payload_file_path}       csourceRegistrations/interoperability/context-source-registration-exclusive-2.jsonld
${entity_id}                                      urn:ngsi-ld:OffStreetParking:2
${b1_url}                                         
${b2_url}                                         
${b3_url}                                         
@@ -27,9 +26,6 @@ IOP_CNF_01_02 Create Entity In B1 And Retrieve Entity In All Brokers
    [Documentation]    Check that, in b1 and b2, the entity does not contain the attribute location, said attribute will be contained in b3 thanks to an exclusive registration.
    [Tags]    6_1    I6_1_1_2    Inclusive    Exclusive    Interoperability

    ${response}=    Create Entity From File    ${entity_payload_filename}    ${b1_url}
    Check Response Status Code    201    ${response.status_code}

    ${response}=    Retrieve Entity by Id    ${entity_id}    context=${ngsild_test_suite_context}    broker_url=${b1_url}    local=true
    Check Response Status Code    200    ${response.status_code}
    Should Not Contain    ${response.json()}    location
@@ -45,6 +41,11 @@ IOP_CNF_01_02 Create Entity In B1 And Retrieve Entity In All Brokers
*** Keywords ***
Setup Initial Context Source Registrations

    ${entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id1}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id1}
    ${registration_payload}=    Prepare Context Source Registration From File
+6 −4
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ Test Teardown Delete Entities and Delete Registrations
${entity_payload_filename}                        interoperability/offstreet-parking1-full.jsonld
${inclusive_registration_payload_file_path}       csourceRegistrations/interoperability/context-source-registration-inclusive-2.jsonld
${redirect_registration_payload_file_path}        csourceRegistrations/interoperability/context-source-registration-redirect-2.jsonld
${entity_id}                                      urn:ngsi-ld:OffStreetParking:1
${b1_url}                                         
${b2_url}                                         
${b3_url}
@@ -23,12 +22,10 @@ ${b4_url}

*** Test Cases ***
IOP_CNF_02_01 Create Entity In B1 And Retrieve Entity In All Brokers
    [Documentation]    Check that entities are created in b1 and b2 but not in b3.
    [Documentation]    Check that entities are created in the brokers, b1 and b2 should contain most entity attributes, 3b and b4 should only contain the location attribute.
    [Tags]    6_1    I6_1_2_1    Inclusive    Redirect    Interoperability
    
    ${expected_payload}=    Load Entity    ${entity_payload_filename}    ${entity_id}
    ${response}=    Create Entity From File    ${entity_payload_filename}    broker_url=${b1_url}    
    Check Response Status Code    201    ${response.status_code}

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b1_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}
@@ -50,6 +47,11 @@ IOP_CNF_02_01 Create Entity In B1 And Retrieve Entity In All Brokers
*** Keywords ***
Setup Initial Context Source Registrations

    ${entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}
    
    ${registration_id1}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id1}
    ${registration_payload}=    Prepare Context Source Registration From File
+94 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that broker b2 mirrors the information in b1 and the b3 and b4 brokers contain only the location property.

Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationConsumption.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceDiscovery.resource
Resource            ${EXECDIR}/resources/ApiUtils/ContextSourceRegistration.resource
Resource            ${EXECDIR}/resources/AssertionUtils.resource
Resource            ${EXECDIR}/resources/JsonUtils.resource

Test Setup          Setup Initial Context Source Registrations
Test Teardown       Delete Entities and Delete Registrations

*** Variables ***
${entity_payload_filename}                              interoperability/offstreet-parking2-full.jsonld
${inclusive_registration_payload_file_path}             csourceRegistrations/interoperability/context-source-registration-inclusive-2.jsonld
${first_redirect_registration_payload_file_path}        csourceRegistrations/interoperability/context-source-registration-redirect-2.jsonld
${second_redirect_registration_payload_file_path}       csourceRegistrations/interoperability/context-source-registration-redirect-3.jsonld
${b1_url}                                         
${b2_url}                                         
${b3_url}
${b4_url}                                         

*** Test Cases ***
IOP_CNF_02_02 Create Entity In B1 And Retrieve Entity In All Brokers
    [Documentation]    Check that entities are created in the brokers, b1 and b2 should contain most entity attributes, 3b and b4 should only contain the location attribute.
    [Tags]    6_1    I6_1_2_2    Inclusive    Redirect    Interoperability

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

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b2_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}
    Should Not Contain    ${response.json()}    location
    Should Not Contain    ${response.json()}    name

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b3_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}
    Should Contain    ${response.json()}    location

    ${response}=    Retrieve Entity by Id    ${entity_id}    local=true    broker_url=${b4_url}    context=${ngsild_test_suite_context}
    Check Response Status Code    200    ${response.status_code}
    Should Contain    ${response.json()}    location

*** Keywords ***
Setup Initial Context Source Registrations
    
    ${entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${entity_id}
    ${response}=    Create Entity    ${entity_payload_filename}    ${entity_id}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id1}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id1}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id1}
    ...    ${inclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    broker_url=${b2_url}
    ...    mode=inclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id2}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id2}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id2}
    ...    ${first_redirect_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    broker_url=${b3_url}
    ...    mode=redirect
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id3}=     Generate Random CSR Id
    Set Suite Variable    ${registration_id3}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id3}
    ...    ${second_redirect_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    broker_url=${b4_url}
    ...    mode=redirect
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b1_url}
    Check Response Status Code    201    ${response.status_code}

Delete Entities And Delete Registrations
    Delete Context Source Registration    ${registration_id1}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id2}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id3}    broker_url=${b1_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b1_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b2_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b3_url}
    Delete Entity By Id    ${entity_id}    broker_url=${b4_url}
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:ContextSourceRegistration:Redirect:3",
  "type": "ContextSourceRegistration",
  "information": [
    {
      "entities": [
        {
          "type": "OffStreetParking",
          "id": "urn:ngsi-ld:OffStreetParking:2"
        }
      ],
      "propertyNames": [
        "location"		
      ]
    }
  ],
  "mode": "redirect",
  "operations": ["redirectionOps"],
  "endpoint": "xxx",
  "@context":[
    "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite-compound.jsonld"
  ]
}
 No newline at end of file
Loading