Commit 75ce9ecf authored by Giacomo Bernini's avatar Giacomo Bernini
Browse files

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

[test-upd][SOL005][NS-LCM][v5.3.1][NFVSOL(26)000019r3][5.3.2.17.x Test-IDs] implemented support for notification validation as per item 17-2
parent 5bcc7d79
Loading
Loading
Loading
Loading
+187 −2
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ Library MockServerLibrary
Library    Process
Library    OperatingSystem
Library    Collections
Library    REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}     ssl_verify=false


*** Test Cases ***
NS LCM Operation Occurrence Start Notification
@@ -21,6 +23,8 @@ NS LCM Operation Occurrence Start Notification
    Check NS LCM Operation Occurrence Start Notification Http POST Request Body Json Schema Is    NsLcmOperationOccurrenceNotification
    Check NS LCM Operation Occurrence Start Notification Http POST Request Body notificationType attribute Is    NsLcmOperationOccurrenceNotification
    Check NS LCM Operation Occurrence Start Notification Http POST Request Body notificationStatus attribute Is    START
    Check NS LCM Operation Occurrence Notification Available

    
NS LCM Operation Occurrence Result Notification
    [Documentation]    Test ID: 5.3.2.17.2
@@ -34,7 +38,9 @@ NS LCM Operation Occurrence Result Notification
    Trigger the completion of an NS LCM operation (external action)
    Check NS LCM Operation Occurrence Result Notification Http POST Request Body Json Schema Is    NsLcmOperationOccurrenceNotification
    Check NS LCM Operation Occurrence Result Notification Http POST Request Body notificationType attribute Is    NsLcmOperationOccurrenceNotification
    Check NS LCM Operation Occurrence Start Notification Http POST Request Body notificationStatus attribute Is    RESULT
    Check NS LCM Operation Occurrence Result Notification Http POST Request Body notificationStatus attribute Is    RESULT
    Check NS LCM Operation Occurrence Notification Available

    
NS Identifier Creation Notification
    [Documentation]    Test ID: 5.3.2.17.3
@@ -48,6 +54,8 @@ NS Identifier Creation Notification
    Trigger the creation of a NS instance resource (external action)
    Check NS Identifier Creation Notification Http POST Request Body Json Schema Is    NsIdentifierCreationNotification
    Check NS Identifier Creation Notification Http POST Request Body notificationType attribute Is    NsIdentifierCreationNotification
    Check NS Identifier Creation Notification Available

    
NS Identifier Deletion Notification
    [Documentation]    Test ID: 5.3.2.17.4
@@ -61,6 +69,8 @@ NS Identifier Deletion Notification
    Trigger the deletion of a NS instance resource (external action)
    Check NS Identifier Deletion Notification Http POST Request Body Json Schema Is    NsIdentifierDeletionNotification
    Check NS Identifier Deletion Notification Http POST Request Body notificationType attribute Is    NsIdentifierDeletionNotification
    Check NS Identifier Deletion Notification Available

    
NS Change Notification
    [Documentation]    Test ID: 5.3.2.17.5
@@ -74,6 +84,8 @@ NS Change Notification
    Trigger a NS LCM operation that affects a NS instance component (external action)
    Check NS Change Notification Http POST Request Body Json Schema Is    NsChangeNotification
    Check NS Change Notification Http POST Request Body notificationType attribute Is    NsChangeNotification
    Check NS Change Notification Available


NS LCM Capacity Shortage Notification
    [Documentation]    Test ID: 5.3.2.17.6
@@ -87,6 +99,8 @@ NS LCM Capacity Shortage Notification
    Trigger a resource shortage for a NS LCM operation (external action)
    Check NS LCM Capacity Shortage Notification Http POST Request Body Json Schema Is    NsLcmCapacityShortageNotification
    Check NS LCM Capacity Shortage Notification Http POST Request Body notificationType attribute Is    NsLcmCapacityShortageNotification
    Check NS LCM Capacity Shortage Notification Available


*** Keywords ***
Trigger a NS LCM operation (external action) 
@@ -278,3 +292,174 @@ 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 NS LCM Operation Occurrence 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}

    ${_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['logReports'][0]}
    Integer    response status    200

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


Check NS Identifier Creation Notification Available
    [Arguments]    ${expected_notification_type}=NsIdentifierCreationNotification
    ${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}

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

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

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

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

Check NS Identifier Deletion Notification Available
    [Arguments]    ${expected_notification_type}=NsIdentifierDeletionNotification
    ${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}

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

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

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

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

Check NS Change Notification Available
    [Arguments]    ${expected_notification_type}=NsChangeNotification
    ${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}

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

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

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

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

Check NS LCM Capacity Shortage Notification Available
    [Arguments]    ${expected_notification_type}=NsLcmCapacityShortageNotification
    ${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}

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

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

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

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