Update PRH tests to use file based conifg
[integration/csit.git] / tests / dcaegen2 / prh-testcases / resources / prh_library.robot
index cf3f109..ff02d7f 100644 (file)
@@ -12,15 +12,15 @@ Verify PNF ready sent
     ${expected_pnf_ready_event}=    Get Data From File    ${test_case_directory}/expected-pnf-ready-event.json
     Add PNF entry in AAI    ${pnf_entry}
     Set VES event in DMaaP    ${ves_event}
-    Wait Until Keyword Succeeds    10x    3000ms    Check CBS ready
     Wait Until Keyword Succeeds    10x    3000ms    Check created PNF_READY notification    ${expected_pnf_ready_event}
 
-Verify PNF ready sent and old logical link removed from AAI
+Verify PNF ready sent and old logical link replaced in AAI
     [Arguments]    ${test_case_directory}
     ${logical_link}=   Get Data From File  ${test_case_directory}/logical-link.json
+    ${expected_logical_link}=    Get Data From File  ${test_case_directory}/expected-logical-link.json
     Add logical link entry in AAI  ${logical_link}
     Verify PNF ready sent  ${test_case_directory}
-    Wait Until Keyword Succeeds    10x    3000ms    Check no logical link in AAI    ${test_case_directory}
+    Wait Until Keyword Succeeds    10x    3000ms    Check created Logical Link    ${expected_logical_link}
 
 Verify PNF ready sent and logical link created
     [Arguments]    ${test_case_directory}
@@ -35,32 +35,29 @@ Verify event with missing required field is logged
     Log    Invalid ves event: ${invalid_ves_event}
     ${notification}=    Create invalid notification    ${invalid_ves_event}
     ${error_msg}=    Set Variable    Incorrect json, consumerDmaapModel can not be created:
-    Wait Until Keyword Succeeds    10x    3000ms    Check PRH json log    ${error_msg}    ${notification}
+    Wait for PRH json log entry    20s    ${error_msg}    ${notification}
 
 Verify incorrect JSON event is logged
-    [Timeout]    60s
     [Arguments]    ${test_case_directory}
     ${invalid_ves_event}=    Get Data From File    ${test_case_directory}/invalid-ves-event.json
     Set VES event in DMaaP    ${invalid_ves_event}
-    Check PRH log    |WARN    |Incorrect json, consumerDmaapModel can not be created:
+    Wait for PRH log entry    20s    java.lang.IllegalStateException: Not a JSON Object
 
 Verify missing AAI record is logged
-    [Timeout]    100s
     [Arguments]    ${test_case_directory}
     ${incorrect_aai_entry}=    Get Data From File    ${test_case_directory}/incorrect-aai-entry.json
     ${ves_event}=    Get Data From File    ${test_case_directory}/ves-event.json
     Add PNF entry in AAI    ${incorrect_aai_entry}
     Set VES event in DMaaP    ${ves_event}
-    Check PRH log    Request failed for URL 'https://aai:3334/aai/v12/network/pnfs/pnf/NOK6061ZW8'. Response code: 404 Not Found
+    Wait for PRH log entry    20s    Request failed for URL 'https://aai:3334/aai/v23/network/pnfs/pnf/NOK6061ZW8'. Response code: 404 Not Found
 
 Verify AAI not responding is logged
-    [Timeout]    100s
     [Arguments]    ${test_case_directory}
     ${ves_event}=    Get Data From File    ${test_case_directory}/ves-event.json
     Ensure Container Is Exited    aai_simulator
     Set VES event in DMaaP    ${ves_event}
-    Check PRH log    connection timed out: aai    Host is unreachable: aai
-    Ensure Container Is Running   aai_simulator
+    Wait for one of PRH log entries    90s    connection timed out: aai    Host is unreachable: aai    No route to host: aai    failed to resolve 'aai'
+    [Teardown]    Ensure Container Is Running   aai_simulator
 
 Verify PNF re registration
     [Timeout]    500s
@@ -89,53 +86,47 @@ Verify PNF ready sent when service instance non active
     Add service instance entry in AAI    ${service_instance}
 
     Set VES event in DMaaP    ${ves_event}
-    Wait Until Keyword Succeeds    10x    3000ms    Check CBS ready
     Wait Until Keyword Succeeds    10x    3000ms    Check created PNF_READY notification    ${expected_pnf_ready_event}
 
 Check logical link not modified
     [Arguments]    ${test_case_directory}
     ${expected_logical_link}=    Get Data From File  ${test_case_directory}/logical-link.json
-    ${actual_logical_link}=    Get Request   ${aai_session}    /verify/logical-link/bbs-link    headers=${suite_headers}
-    Should Be Equal As JSON  ${expected_logical_link}    ${actual_logical_link.content}
-
-Check no logical link in AAI
-    [Arguments]    ${test_case_directory}
-    ${logical_links}=    Get Request    ${aai_session}    /verify/logical-links    headers=${suite_headers}
-    Should Be Equal As JSON    {}    ${logical_links.content}
-
-Check CBS ready
-    ${resp}=    Get Request    ${consul_session}    /v1/catalog/services
-    Should Be Equal As Strings    ${resp.status_code}    200
-    Log    Service Catalog response: ${resp.content}
-    Dictionary Should Contain Key    ${resp.json()}    cbs    |Consul service catalog should contain CBS entry
+    ${existing_logical_link}=    Get Request    ${aai_session}    /verify/logical-link    headers=${suite_headers}
+    Should Be Equal As JSON  ${expected_logical_link}    ${existing_logical_link.content}
 
 Check created PNF_READY notification
-    [Arguments]    ${expected_event_pnf_ready_in_dpaap}
+    [Arguments]    ${expected_event_pnf_ready_in_dmaap}
     ${resp}=    Get Request    ${dmaap_session}    /verify/pnf_ready    headers=${suite_headers}
     Should Be Equal As Strings    ${resp.status_code}    200
-    Should Be Equal As JSON    ${resp.content}    ${expected_event_pnf_ready_in_dpaap}
+    Should Be Equal As JSON    ${resp.content}    ${expected_event_pnf_ready_in_dmaap}
 
 Check created PNF_UPDATE notification
-    [Arguments]    ${expected_event_pnf_update_in_dpaap}
+    [Arguments]    ${expected_event_pnf_update_in_dmaap}
     ${resp}=    Get Request    ${dmaap_session}    /verify/pnf_update    headers=${suite_headers}
     Log    Response from DMaaP: ${resp.content}
     Should Be Equal As Strings    ${resp.status_code}    200
-    Should Be Equal As JSON    ${resp.content}    ${expected_event_pnf_update_in_dpaap}
+    Should Be Equal As JSON    ${resp.content}    ${expected_event_pnf_update_in_dmaap}
 
 Check created Logical Link
     [Arguments]    ${expected_logical_link_in_aai}
-    ${resp}=    Get Request    ${aai_session}    /verify/created_logical_link    headers=${suite_headers}
+    ${resp}=    Get Request    ${aai_session}    /verify/logical-link    headers=${suite_headers}
     Should Be Equal As Strings    ${resp.status_code}    200
     Should Be Equal As JSON    ${resp.content}    ${expected_logical_link_in_aai}
 
-Check PRH log
-    [Arguments]    @{log_entries}
-    ${found}=    Find one of log entryies    ${log_entries}
+Wait for PRH log entry
+    [Arguments]    ${timeout}    ${log_entry}
+    Wait for one of PRH log entries    ${timeout}    ${log_entry}
+
+Wait for one of PRH log entries
+    [Arguments]    ${timeout}    @{log_entries}
+    [Timeout]     ${timeout}
+    ${found}=    Wait for one of docker log entries   prh   ${log_entries}
     Should Be True    ${found}
 
-Check PRH json log
-    [Arguments]    ${prefix}    ${json}
-    ${found}=    Find log json    ${prefix}    ${json}
+Wait for PRH json log entry
+    [Arguments]    ${timeout}    ${prefix}    ${json}
+    [Timeout]     ${timeout}
+    ${found}=    Wait for log entry with json message    ${prefix}    ${json}
     Should Be True    ${found}
 
 Create event parsing error
@@ -155,7 +146,7 @@ Add service instance entry in AAI
     [Arguments]    ${aai_service_instance}
     ${headers}=    Create Dictionary    Accept=application/json    Content-Type=application/json
     Log    AAI url ${AAI_SIMULATOR_SETUP_URL}
-    ${resp}=    Put Request    ${aai_session}    /setup/add_service_instace    headers=${suite_headers}    data=${aai_service_instance}
+    ${resp}=    Put Request    ${aai_session}    /setup/add_service_instance    headers=${suite_headers}    data=${aai_service_instance}
     Should Be Equal As Strings    ${resp.status_code}    200
 
 Add logical link entry in AAI
@@ -213,4 +204,9 @@ Verify logging level
 
 Verify logs with heartbeat
     Get Request    prh_session    /heartbeat
-    Check PRH log   Heartbeat request received
\ No newline at end of file
+    Verify PRH logs contains    Heartbeat request received
+
+Verify PRH logs contains
+   [Arguments]    ${expected_entry}
+   ${log}=    Get docker logs since test start    prh
+   Should Contain    ${log}    ${expected_entry}