Commit 6847146c authored by Benedetta Arena's avatar Benedetta Arena
Browse files

feat: implement new test with five brokers

parent 9d141b42
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ ${b3_url}
${b4_url}

*** Test Cases ***
IOP_CNF_03_01 Create Entity In B1 And Query Entity In All Brokers
IOP_CNF_03_02 Create Entity In B1 And Query Entity In All Brokers
    [Documentation]    Check that entities can be queried from all brokers.
    [Tags]    6_3    I6_3_3_1    inclusive    auxiliary    interoperability
    
+149 −0
Original line number Diff line number Diff line
*** Settings ***
Documentation       Verify that the entities found in b4 and b5 can be queried correctly.
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 ***
${first_parking_location_name_payload_filename}       interoperability/offstreet-parking1-location-and-name.jsonld
${second_parking_location_name_payload_filename}      interoperability/offstreet-parking2-location-and-name.jsonld
${first_full_parking_payload_filename}                interoperability/offstreet-parking1-full.jsonld
${second_full_parking_payload_filename}               interoperability/offstreet-parking2-full.jsonld
${auxiliary_registration_payload_file_path}           csourceRegistrations/interoperability/context-source-registration-auxiliary-2.jsonld
${inclusive_registration_payload_file_path}           csourceRegistrations/interoperability/context-source-registration-inclusive-1.jsonld
${first_exclusive_registration_payload_file_path}     csourceRegistrations/interoperability/context-source-registration-exclusive-2.jsonld
${second_exclusive_registration_payload_file_path}    csourceRegistrations/interoperability/context-source-registration-exclusive-3.jsonld
${first_redirect_registration_payload_file_path}      csourceRegistrations/interoperability/context-source-registration-redirect-1.jsonld
${second_redirect_registration_payload_file_path}     csourceRegistrations/interoperability/context-source-registration-redirect-2.jsonld
${b1_url}                                         
${b2_url}                                         
${b3_url}
${b4_url}
${b5_url}

*** Test Cases ***
IOP_CNF_04_01 Create Entities In Remote Brokers And Query Said Entities
    [Documentation]    Check that entities can be queried from all brokers.
    [Tags]    6_3    I6_3_4_1    inclusive    auxiliary    redirect    exclusive    interoperability
    
    ${response}=    Query Entities    entity_types=OffstreetParking    broker_url=${b1_url}
    Check Response Status Code    200    ${response.status_code}

    &{payload}=    Evaluate    {i['id']: i for i in ${response.json()}}
    ${first_parking_payload}=    Get From Dictionary    ${payload}    OffstreetParking:1
    ${second_parking_payload}=    Get From Dictionary    ${payload}    OffstreetParking:2
    Should Contain    ${first_parking_payload}    location
    Should Contain    ${second_parking_payload}    availableSpotsNumber
    Should Contain    ${second_parking_payload}    totalSpotsNumber
    Should Contain    ${second_parking_payload}    location

    ${response}=    Query Entities    entity_types=OffstreetParking    broker_url=${b4_url}
    ${payload}=    Evaluate    {i['id']: i for i in ${response.json()}}
    ${expected_entity1}=    Get From Dictionary    ${payload}    OffstreetParking:2
    ${response}=    Query Entities    entity_types=OffstreetParking    broker_url=${b5_url}
    ${payload}=    Evaluate    {i['id']: i for i in ${response.json()}}
    ${expected_entity2}=    Get From Dictionary    ${payload}    OffstreetParking:1
    ${expected_entity3}=    Get From Dictionary    ${payload}    OffstreetParking:2

    Should Be Equal    ${first_parking_payload}[location]    ${expected_entity2}[location]
    Should Be Equal    ${second_parking_payload}[availableSpotsNumber]    ${expected_entity1}[availableSpotsNumber]
    Should Be Equal    ${second_parking_payload}[totalSpotsNumber]    ${expected_entity1}[totalSpotsNumber]
    Should Be Equal    ${second_parking_payload}[location]    ${expected_entity3}[location]

*** Keywords ***
Setup Initial Context Source Registrations
    ${entity_id}=    Generate Random Parking Entity Id
    Set Suite Variable    ${entity_id}

    ${response}=    Create Entity    ${first_parking_location_name_payload_filename}    ${entity_id}    broker_url=${b4_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${second_full_parking_payload_filename}    ${entity_id}    broker_url=${b4_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${first_full_parking_payload_filename}    ${entity_id}    broker_url=${b5_url}
    Check Response Status Code    201    ${response.status_code}
    ${response}=    Create Entity    ${second_parking_location_name_payload_filename}    ${entity_id}    broker_url=${b5_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}
    ...    ${auxiliary_registration_payload_file_path}
    ...    entity_id_pattern=
    ...    endpoint=${b2_url}
    ...    mode=auxiliary
    ${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}
    ...    endpoint=${b4_url}
    ...    mode=redirect
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b2_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}
    ...    endpoint=${b5_url}
    ...    mode=redirect
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b2_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id4}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id4}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id4}
    ...    ${inclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    endpoint=${b3_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_id5}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id5}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id5}
    ...    ${first_exclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    endpoint=${b5_url}
    ...    mode=exclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b3_url}
    Check Response Status Code    201    ${response.status_code}

    ${registration_id6}=    Generate Random CSR Id
    Set Suite Variable    ${registration_id6}
    ${registration_payload}=    Prepare Context Source Registration From File
    ...    ${registration_id6}
    ...    ${second_exclusive_registration_payload_file_path}
    ...    entity_id=${entity_id}
    ...    endpoint=${b5_url}
    ...    mode=exclusive
    ${response}=    Create Context Source Registration With Return    ${registration_payload}    broker_url=${b3_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=${b2_url}
    Delete Context Source Registration    ${registration_id3}    broker_url=${b2_url}
    Delete Context Source Registration    ${registration_id4}    broker_url=${b1_url}
    Delete Context Source Registration    ${registration_id5}    broker_url=${b3_url}
    Delete Context Source Registration    ${registration_id6}    broker_url=${b3_url}
    Delete Entity by Id    ${parking_entity_id1}    broker_url=${b4_url}
    Delete Entity By Id    ${parking_entity_id2}    broker_url=${b4_url}
    Delete Entity by Id    ${parking_entity_id1}    broker_url=${b5_url}
    Delete Entity By Id    ${parking_entity_id2}    broker_url=${b5_url}
 No newline at end of file
+22 −0
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:ContextSourceRegistration:Auxiliary:2",
  "type": "ContextSourceRegistration",
  "information": [
    {
      "entities": [
        {
          "type": "OffStreetParking"
        }
      ],
      "propertyNames": [
        "availableSpotsNumber",
        "totalSpotsNumber"			
      ]
    }
  ],
  "mode": "auxiliary",
  "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
+23 −0
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:ContextSourceRegistration:Exclusive:3",
  "type": "ContextSourceRegistration",
  "information": [
    {
      "entities": [
        {
          "id": "urn:ngsi-ld:OffStreetParking:1",
          "type": "OffStreetParking"
        }
      ],
      "propertyNames": [
        "location"		
      ]
    }
  ],
  "mode": "exclusive",
  "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
+19 −0
Original line number Diff line number Diff line
{
  "id": "urn:ngsi-ld:ContextSourceRegistration:Redirect:1",
  "type": "ContextSourceRegistration",
  "information": [
    {
      "entities": [
        {
          "type": "OffStreetParking"
        }
      ]
    }
  ],
  "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