Commit b82c709e authored by Giacomo Bernini's avatar Giacomo Bernini Committed by Giacomo Bernini
Browse files

[test-upd][SOL005][NSD-FM][v5.3.1][NFVSOL(26)000019r3][5.3.3.5.x Test-IDs]...

[test-upd][SOL005][NSD-FM][v5.3.1][NFVSOL(26)000019r3][5.3.3.5.x Test-IDs] implemented support for notification validation as per item 17-2
parent 2cb338dd
Loading
Loading
Loading
Loading
+109 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ NS Fault Alarm Notification
    Trigger the fault of a virtualised resource in the NS instance (external action) 
    Check Alarm Notification Http POST Request Body Json Schema Is    alarmNotification
    Check Alarm Notification Http POST Request Body notificationType attribute Is    alarmNotification
    Check Alarm Notification Validation

NS Fault Alarm Cleared Notification
    [Documentation]    Test ID: 5.3.3.5.2
@@ -38,6 +39,7 @@ NS Fault Alarm Cleared Notification
    Trigger the fault cleared of a virtualised resource in the NS instance (external action) 
    Check Alarm cleared Notification Http POST Request Body Json Schema Is    alarmClearedNotification
    Check Alarm cleared Notification Http POST Request Body notificationType attribute Is    alarmClearedNotification
    Check Alarm cleared Notification Validation

NS Fault Alarm List Rebuilt Notification 
    [Documentation]    Test ID: 5.3.3.5.3
@@ -51,6 +53,7 @@ NS Fault Alarm List Rebuilt Notification
    Trigger the NS fault alarm list rebuild in the NFVO (external action) 
    Check Alarm list rebuilt Notification Http POST Request Body Json Schema Is    alarmListRebuiltNotification
    Check Alarm list rebuilt Notification Http POST Request Body notificationType attribute Is    alarmListRebuiltNotification
    Check Alarm list rebuilt Notification Validation

NS Fault Alarm Notification with Instrumental Platform Hook
    [Documentation]    Test ID: 5.3.3.5.4
@@ -64,6 +67,7 @@ NS Fault Alarm Notification with Instrumental Platform Hook
    Trigger the fault of a virtualised resource in the NS instance
    Check Instrumentation Platform Alarm Notification Http POST Request Body Json Schema Is    alarmNotification
    Check Instrumentation Platform Alarm Notification Http POST Request Body notificationType attribute Is    alarmNotification
    Check Alarm Notification Validation

NS Fault Alarm Cleared Notification with Instrumental Platform Hook
    [Documentation]    Test ID: 5.3.3.5.5
@@ -77,6 +81,7 @@ NS Fault Alarm Cleared Notification with Instrumental Platform Hook
    Trigger the fault cleared of a virtualised resource in the NS instance
    Check Instrumentation Platform Alarm Cleared Notification Http POST Request Body Json Schema Is    alarmClearedNotification
    Check Instrumentation Platform Alarm Cleared Notification Http POST Request Body notificationType attribute Is    alarmClearedNotification
    Check Alarm Cleared Notification Validation

NS Fault Alarm List Rebuilt Notification with Instrumental Platform Hook
    [Documentation]    Test ID: 5.3.3.5.6
@@ -90,6 +95,7 @@ NS Fault Alarm List Rebuilt Notification with Instrumental Platform Hook
    Trigger the NS fault alarm list rebuild in the NFVO
    Check Instrumentation Platform Alarm List Rebuilt Notification Http POST Request Body Json Schema Is    alarmListRebuiltNotification
    Check Instrumentation Platform Alarm List Rebuilt Notification Http POST Request Body notificationType attribute Is    alarmListRebuiltNotification
    Check Alarm List Rebuilt Notification Validation

*** Keywords ***
Trigger the fault of a virtualised resource in the NS instance
@@ -249,3 +255,105 @@ Create Alarm Subscription
    Set Global Variable    ${response}    ${output}
    Clear Requests    ${callback_endpoint}

Check Alarm Notification Validation
    [Arguments]    ${expected_notification_type}=AlarmNotification
    ${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}

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

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

    # Validate entity exists
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarm['alarmId']}
    Integer    response status    200

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

Check Alarm Cleared Notification Validation
    [Arguments]    ${expected_notification_type}=AlarmClearedNotification
    ${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}

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

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

    # Validate entity exists
    Get    ${apiRoot}/${apiName}/${apiMajorVersion}/alarms/${alarmId}
    Integer    response status    200

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

Check Alarm List Rebuilt Notification Validation
    [Arguments]    ${expected_notification_type}=AlarmListRebuiltNotification
    ${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}

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

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

    # Validate entity exists
    Get    ${_links['alarms']}
    Integer    response status    200

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