Commit 91a47ad8 authored by Eisha Ayaz's avatar Eisha Ayaz
Browse files

[test-upd][SOL002][VNF-LCM][v5.3.1][6.3.5.19.1,2...

[test-upd][SOL002][VNF-LCM][v5.3.1][6.3.5.19.1,2 Test-IDs][NFVSOL(26)000019r3​] Add support of received notification validation
parent 54e84c50
Loading
Loading
Loading
Loading
+130 −17
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ Library MockServerLibrary
Library    Process
Library    OperatingSystem
Library    Collections
Library    REST    http://${VNFM_HOST}:${VNFM_PORT}    ssl_verify=false

*** Test Cases ***
VNF LCM Operation Occurrence Start Notification
@@ -20,7 +21,7 @@ VNF LCM Operation Occurrence Start Notification
    Trigger a VNF LCM operation (external action) 
    Check VNF LCM Operation Occurrence Start Notification Http POST Request Body Json Schema Is    VnfLcmOperationOccurrenceNotification
    Check VNF LCM Operation Occurrence Start Notification Http POST Request Body notificationType attribute Is    VnfLcmOperationOccurrenceNotification
    Check VNF LCM Operation Occurrence Start Notification Http POST Request Body notificationStatus attribute Is    START
    Check VNF LCM Operation Occurrence Start Notification And LCM State    START
    
VNF LCM Operation Occurrence Result Notification
    [Documentation]    Test ID: 6.3.5.19.2
@@ -34,7 +35,7 @@ VNF LCM Operation Occurrence Result Notification
    Trigger the completion of an VNF LCM operation (external action)
    Check VNF LCM Operation Occurrence Result Notification Http POST Request Body Json Schema Is    VnfLcmOperationOccurrenceNotification
    Check VNF LCM Operation Occurrence Result Notification Http POST Request Body notificationType attribute Is    VnfLcmOperationOccurrenceNotification
    Check VNF LCM Operation Occurrence Start Notification Http POST Request Body notificationStatus attribute Is    RESULT
    Check VNF LCM Operation Occurrence Result Notification And LCM State    RESULT
    
VNF Identifier Creation Notification
    [Documentation]    Test ID: 6.3.5.19.3
@@ -87,14 +88,11 @@ Check VNF LCM Operation Occurrence Start Notification Http POST Request Body Jso
Check VNF LCM Operation Occurrence Start Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification VNF LCM Operation Occurrence Start Handler    ${callback_endpoint_fwd}    ${type}    START
    Wait Until Keyword Succeeds     ${total_polling_time}    ${polling_interval}    Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
    
    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}    
Configure Notification VNF LCM Operation Occurrence Start Handler
    [Arguments]    ${endpoint}    ${type}    ${status}
    ${json}=    evaluate    {}
    set to dictionary   ${json}    notificationType    ${type}    changeType    ${status}
    set to dictionary   ${json}    notificationType    ${type}    notificationStatus    ${status}
    ${BODY}=    evaluate    json.dumps(${json})    json
    Log  Creating mock request and response to handle status notification
    &{req}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
@@ -110,14 +108,11 @@ Check VNF LCM Operation Occurrence Result Notification Http POST Request Body Js
Check VNF LCM Operation Occurrence Result Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification VNF LCM Operation Occurrence Result Handler    ${callback_endpoint_fwd}    ${type}    RESULT
    Wait Until Keyword Succeeds     ${total_polling_time}    ${polling_interval}    Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
    
    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}
Configure Notification VNF LCM Operation Occurrence Result Handler
    [Arguments]    ${endpoint}    ${type}    ${status}
    ${json}=    evaluate    {}
    set to dictionary   ${json}    notificationType    ${type}    changeType    ${status}
    set to dictionary   ${json}    notificationType    ${type}    notificationStatus    ${status}
    ${BODY}=    evaluate    json.dumps(${json})    json
    Log  Creating mock request and response to handle status notification
    &{req}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
@@ -133,10 +128,7 @@ Check VNF Identifier Creation Notification Http POST Request Body Json Schema Is
Check VNF Identifier Creation Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification VNF Identifier Creation Handler    ${callback_endpoint_fwd}    ${type}
    Wait Until Keyword Succeeds     ${total_polling_time}    ${polling_interval}    Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}
Configure Notification VNF Identifier Creation Handler
    [Arguments]    ${endpoint}    ${type}
    ${json}=    evaluate    {}
@@ -156,7 +148,7 @@ Check VNF Identifier Deletion Notification Http POST Request Body Json Schema Is
Check VNF Identifier Deletion Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification VNF Identifier Deletion Handler    ${callback_endpoint_fwd}    ${type}
    Wait Until Keyword Succeeds     ${total_polling_time}    ${polling_interval}    Verify Mock Expectation    ${notification_request}
    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

@@ -193,3 +185,124 @@ Create Sessions
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}:${callback_port}

Check VNF LCM Operation Occurrence Start Notification And LCM State
    [Arguments]    ${expected_status}
    ${requests}=    Retrieve Requests    ${callback_endpoint_fwd}
    Should Not Be Empty    ${requests}    msg=No notification received at callback endpoint!

    ${request_type}=    Evaluate    type(${requests})
    ${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
    Should Not Be Empty    ${notification}
    # Validate notification content
    Dictionary Should Contain Key    ${notification}    notificationType
    Dictionary Should Contain Key    ${notification}    notificationStatus
    Dictionary Should Contain Key    ${notification}    vnfInstanceId
    Dictionary Should Contain Key    ${notification}    vnfLcmOpOccId

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

    Should Be Equal As Strings
    ...    ${notification['notificationStatus']}
    ...    ${expected_status}

    ${vnfInstanceId}=    Get From Dictionary    ${notification}    vnfInstanceId
    ${vnfLcmOpOccId}=    Get From Dictionary    ${notification}    vnfLcmOpOccId

    Set Headers    {"Accept": "${ACCEPT_JSON}"}

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

    # Validate VNF Instance
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/vnf_instances/${vnfInstanceId}
    Integer    response status    200

    # Validate LCM operation occurrence
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/vnf_lcm_op_occs/${vnfLcmOpOccId}
    Integer    response status    200

    ${response_body}=    Output    response body

    ${lcm_state}=    Get From Dictionary    ${response_body}    operationState
    ${returned_id}=    Get From Dictionary    ${response_body}    id

    Should Be Equal As Strings    ${returned_id}    ${vnfLcmOpOccId}

    @{allowed_states}=    Create List    STARTING    PROCESSING

    List Should Contain Value
    ...    ${allowed_states}
    ...    ${lcm_state}
Check VNF LCM Operation Occurrence Result Notification And LCM State
    [Arguments]    ${expected_status}
    ${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}
    
    # Handle both single request and list of requests
    ${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

    # 2. Content Validation of Notification
    Dictionary Should Contain Key    ${notification}    notificationType
    Dictionary Should Contain Key    ${notification}    notificationStatus
    Dictionary Should Contain Key    ${notification}    vnfInstanceId
    Dictionary Should Contain Key    ${notification}    vnfLcmOpOccId

    Should Be Equal As Strings    ${notification['notificationType']}      VnfLcmOperationOccurrenceNotification
    Should Be Equal As Strings    ${notification['notificationStatus']}    ${expected_status}
    ...    msg=Expected notificationStatus=RESULT but got ${notification['notificationStatus']}

    ${vnfInstanceId}=    Get From Dictionary    ${notification}    vnfInstanceId
    ${vnfLcmOpOccId}=    Get From Dictionary    ${notification}    vnfLcmOpOccId

    #  Post-condition Verification
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}

    # Validate VNF Instance
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/vnf_instances/${vnfInstanceId}
    Integer    response status    200
    Log    VNF Instance ${vnfInstanceId} validated successfully

    # Validate LCM Operation Occurrence
    GET    ${apiRoot}/${apiName}/${apiMajorVersion}/vnf_lcm_op_occs/${vnfLcmOpOccId}
    Integer    response status    200

    ${outputResponse}=    Output    response
    Set Global Variable    ${response}    ${outputResponse}
    ${lcm_state}=   Get From Dictionary    ${response['body']}    operationState

    # ID Consistency Check
    ${returned_id}=    Get From Dictionary    ${response['body']}    id
    Should Be Equal As Strings    ${returned_id}    ${vnfLcmOpOccId}
    ...    msg=ID mismatch! LCM Op Occ ID in notification (${vnfLcmOpOccId}) does not match resource ID (${returned_id})

    Log    LCM operationState = ${lcm_state}

    # Allowed states for RESULT notification
    @{allowed_states}=    Create List    COMPLETED    FAILED    FAILED_TEMP    ROLLING_BACK    ROLLED_BACK
    List Should Contain Value    ${allowed_states}    ${lcm_state}
    ...    msg=Unexpected operationState '${lcm_state}' after RESULT notification

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