Commit 9448bb8d authored by Giacomo Bernini's avatar Giacomo Bernini
Browse files

[test-upd][SOL005][NS-PM][v5.3.1][NFVSOL(26)000019r3][5.3.4.8.x Test-IDs]...

[test-upd][SOL005][NS-PM][v5.3.1][NFVSOL(26)000019r3][5.3.4.8.x Test-IDs] implemented support for notification validation as per item 17-2
parent 960783ac
Loading
Loading
Loading
Loading
+73 −1
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ Library OperatingSystem
Library    BuiltIn
Library    Collections
Library    String
Library    REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}     ssl_verify=false



*** Test Cases ***
@@ -23,6 +25,7 @@ NS Performance Information Availability Notification
    Trigger the availability of NS Performance Information (external action) 
    Check Performance Information Available Notification Http POST Request Body Json Schema Is    PerformanceInformationAvailableNotification
    Check Performance Information Available Notification Http POST Request Body notificationType attribute Is    PerformanceInformationAvailableNotification
    Check Performance Information Available Notification Available

NS Threshold Crossed Notification
    [Documentation]    Test ID: 5.3.4.8.2
@@ -36,6 +39,7 @@ NS Threshold Crossed Notification
    Trigger the cross of NS Performance Threshold (external action) 
    Check Threshold Crossed Notification Http POST Request Body Json Schema Is    ThresholdCrossedNotification
    Check Threshold Crossed Notification Http POST Request Body notificationType attribute Is    ThresholdCrossedNotification
    Check Threshold Crossed Notification Available


*** Keywords ***
@@ -114,3 +118,71 @@ Create Sessions
    Start Process  java  -jar  ${MOCK_SERVER_JAR}  -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}:${callback_port}

Check Performance Information Available Notification Available
    [Arguments]    ${expected_notification_type}=LogReportAvailableNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${pmJobId}=    Get From Dictionary    ${notification}    pmJobId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${pmJobId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Check Threshold Crossed Notification Available
    [Arguments]    ${expected_notification_type}=LogReportAvailableNotification
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    Log    Request type: ${request_type}

    ${last_request}=    Run Keyword If    "${request_type}" == "<class 'list'>"
    ...    Get From List    ${requests}    -1
    ...    ELSE
    ...    Set Variable    ${requests}

    ${body}=    Get From Dictionary    ${last_request}    body
    ${body_text}=    Get From Dictionary    ${body}    string

    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    Log    Parsed notification: ${notification}

    Should Be Equal As Strings    ${notification['notificationType']}    ${expected_notification_type}

    ${thresholdId}=    Get From Dictionary    ${notification}    thresholdId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate entity exists
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    Integer    response status    200

    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
 No newline at end of file