Commit ec7a64c6 authored by Eisha Ayaz's avatar Eisha Ayaz
Browse files

[test-upd][SOL003][VNF-PM][v5.3.1][7.3.4.8.1,2 Test-IDs][NFVSOL(26)000019r3​]...

[test-upd][SOL003][VNF-PM][v5.3.1][7.3.4.8.1,2 Test-IDs][NFVSOL(26)000019r3​] Add support of received notification validation
parent 74d1f952
Loading
Loading
Loading
Loading
+48 −1
Original line number Diff line number Diff line
*** Setting ***
*** Settings ***
Resource	environment/variables.txt
Suite Setup    Create Sessions
Suite Teardown    Terminate All Processes    kill=true
@@ -8,6 +8,7 @@ Library OperatingSystem
Library    BuiltIn
Library    Collections
Library    String
Library    REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}    ssl_verify=false


*** Test Cases ***
@@ -23,6 +24,7 @@ VNF Performance Information Availability Notification
    Trigger the availability of VNF 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

VNF Threshold Crossed Notification
    [Documentation]    Test ID: 7.3.4.8.2
@@ -36,6 +38,7 @@ VNF Threshold Crossed Notification
    Trigger the cross of VNF 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


*** Keywords ***
@@ -106,6 +109,50 @@ Configure Notification Forward
    &{notification_fwd}=  Create Mock Http Forward	${endpoint_fwd}
    Create Mock Expectation With Http Forward  ${notification_tmp}  ${notification_fwd}

Check Performance Information Available Notification
    ${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
    Log    Raw body: ${body_text}
    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    ${pmJobId}=    Get From Dictionary    ${notification}    pmJobId
    ${pmJobUrl}=    Set Variable    ${apiRoot}/${apiName}/${apiMajorVersion}/pm_jobs/${pmJobId}
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    GET    ${pmJobUrl}
    Integer    response status    200
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Check Threshold Crossed Notification
    ${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
    Log    Raw body: ${body_text}
    ${notification}=    Evaluate    json.loads(r'''${body_text}''')    json
    ${thresholdId}=    Get From Dictionary    ${notification}    thresholdId
    ${thresholdUrl}=    Set Variable    ${apiRoot}/${apiName}/${apiMajorVersion}/thresholds/${thresholdId}
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1
    ...    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    GET    ${thresholdUrl}
    Integer    response status    200
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Create Sessions
    Start Process  java  -jar  ${MOCK_SERVER_JAR}  -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue