Commit 1c9ba2ad authored by Elian Kraja's avatar Elian Kraja
Browse files

Fix on asynchronous notifications

parent 5a2af762
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -543,6 +543,36 @@ GET VNF LCM OP occurrences invalid filter
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_lcm_op_occs?fields=wrong_field	
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}	
	
Get VNF LCM Operation occurrences with all_fields attribute selector
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_lcm_op_occs?all_fields
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}

Get VNF LCM Operation occurrences with exclude_default attribute selector
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_lcm_op_occs?exclude_default
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
Get VNF LCM Operation occurrences with fields attribute selector
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_lcm_op_occs?fields=${fields}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output}
    
Get VNF LCM Operation occurrences with exclude_fields attribute selector
    Set Headers    {"Accept": "${ACCEPT_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization": "${AUTHORIZATION}"}
    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_lcm_op_occs?exclude_fields=${fields}
    ${output}=    Output    response
    Set Suite Variable    ${response}    ${output} 	


PUT VNF LCM OP occurrences	
    log    Trying to perform a PUT. This method should not be implemented
    Set Headers  {"Accept":"${ACCEPT}"}  
+568 −0

File changed.

Preview size limit exceeded, changes collapsed.

+10 −2
Original line number Diff line number Diff line
@@ -10,8 +10,9 @@ Library BuiltIn
Library    Collections
Library    JSONLibrary
Library    Process
Library    MockServerLibrary    
Suite Setup    Initialize System
Suite Teardown    Terminate All Processes    kill=true
Suite Teardown    Clean up


*** Test Cases ***
@@ -42,5 +43,12 @@ Check Postcondition VNF Instance Created status is
    Check VNF Status    ${response['body']['instantiationState']}  ${status}

Check Operation Notification For VNF Instance Creation
    Check VNF Instance Operation Notification    VnfIdentifierCreationNotification   ${vnfInstanceId}
    # Check VNF Instance Operation Notification    VnfIdentifierCreationNotification   ${vnfInstanceId}
    Check Operation Notification    VnfIdentifierCreationNotification    204



Clean up
    Terminate All Processes    kill=true
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
 No newline at end of file
+24 −26
Original line number Diff line number Diff line
@@ -28,46 +28,45 @@ Create Sessions

Configure Notification Status Handler
    [Arguments]    ${endpoint}    ${status}=""
    ${opst}=     Create Dictionary
    ${json}=     Create Dictionary  operationState=${opst}
    ${json}=     Create Dictionary
    ${value}=    Run Keyword And Return Status    Should Not Be Equal As Strings    ${status}        ""
    Run Keyword If   ${value} == True      Set to dictionary    ${json["operationState"]}    dp=${status}
    ${BODY}=    evaluate    json.dumps(${json})    json
    Run Keyword If   ${value} == True      Set to dictionary    ${json}    operationState    ${status}
    Log  Creating mock request and response to handle ${element}
    &{notification_request}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    ${headers}=  Create Dictionary  "Content-Type"="application/json"
    &{notification_response}=  Create Mock Response	headers=${headers}  status_code=204
    ${notification_request}=  Create Mock Request Matcher	POST  ${endpoint}  body_type='JSON'    body=${json}
    &{headers}=  Create Dictionary  Content-Type=application/json
    ${notification_response}=  Create Mock Response	    status_code=${status}    headers=${headers}     
    Create Mock Expectation  ${notification_request}  ${notification_response}
    [Return]    ${notification_request}

Configure Notification VNF Instance Handler
    [Arguments]    ${endpoint}    ${instanceId}=""
    Run Keyword If   "${instanceId}"!=""  set to dictionary    ${json['vnfInstanceId']}    dp=${instanceId}
    ${BODY}=    evaluate    json.dumps(${json})    json
    ${json}=     Create Dictionary
    ${value}=    Run Keyword And Return Status    Should Not Be Equal As Strings    ${instanceId}        ""
    Run Keyword If   ${value} == True      Set to dictionary    ${json}    vnfInstanceId    ${instanceId}
    Log  Creating mock request and response to handle ${element}
    &{notification_request}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    &{headers}=  Create Dictionary  "Content-Type"="application/json"
    &{notification_response}=  Create Mock Response     headers=${headers}  status_code=204
    ${exp}=  Create Mock Expectation  ${Notification_request}  ${notification_response}
    ${notification_request}=  Create Mock Request Matcher	POST  ${endpoint}    body_type='JSON'  body=${json}
    &{headers}=  Create Dictionary  Content-Type=application/json
    ${notification_response}=  Create Mock Response     204    headers=${headers}    
    Log    ${notification_request}
    Log    ${notification_response}
    Create Mock Expectation  ${notification_request}  ${notification_response}
    [Return]    ${notification_request}

Configure Notification Forward
    [Arguments]    ${element}    ${endpoint}    ${endpoint_fwd}
    ${json}=    Get File    schemas/${element}.schema.json
    ${BODY}=	evaluate	json.loads('''${json}''')	json
    Log  ${BODY}
    Log  Creating mock HTTP forward to handle ${element}
    &{notification_tmp}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON_SCHEMA"    body=${BODY}
    &{notification_fwd}=  Create Mock Http Forward	${endpoint_fwd}
    ${notification_tmp}=  Create Mock Request Matcher	POST  ${endpoint}  body_type='JSON_SCHEMA'    body=${json}
    ${notification_fwd}=  Create Mock Http Forward	${endpoint_fwd}
    Create Mock Expectation With Http Forward  ${notification_tmp}  ${notification_fwd}
    [Return]  notification_tmp
    [Return]  ${notification_tmp}

Check Operation Notification
    [Arguments]    ${element}    ${status}=""
    ${json}=	Get File	schemas/${element}.schema.json
    Configure Notification Forward    ${element}    ${callback_endpoint}    ${callback_endpoint_fwd}
    Configure Notification Status Handler    ${callback_endpoint_fwd}    ${status}
    ${verify}=   Create Dictionary
    Wait Until Keyword Succeeds    10 sec   10 sec   Verify Mock Expectation    ${verify}
    ${req1}=    Configure Notification Forward    ${element}    ${callback_endpoint}    ${callback_endpoint_fwd}
    ${req2}=    Configure Notification Status Handler    ${callback_endpoint_fwd}    ${status}
    Wait Until Keyword Succeeds    12 sec   3 sec   Verify Mock Expectation    ${req2}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

@@ -76,7 +75,6 @@ Check VNF Instance Operation Notification
    ${json}=	Get File	schemas/${element}.schema.json
    ${req1}=  Configure Notification Forward   ${element}    ${callback_endpoint}    ${callback_endpoint_fwd}
    ${req2}=  Configure Notification VNF Instance Handler    ${callback_endpoint_fwd}    ${instance_id}
    Wait Until Keyword Succeeds    12 sec   3 sec   Verify Mock Expectation    ${req1}
    Wait Until Keyword Succeeds    12 sec  3 sec   Verify Mock Expectation    ${req2}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
+5 −5
Original line number Diff line number Diff line
*** Variables ***
${VNFM_HOST}      localhost    # Hostname of the VNFM
${VNFM_PORT}      8080    # Listening port of the VNFM
${VNFM_SCHEMA}    https
${VNFM_PORT}      5000    # Listening port of the VNFM
${VNFM_SCHEMA}    http
${ACCEPT}         application/json
${ACCEPT_JSON}         application/json
${CONTENT_TYPE}    application/json
${AUTHORIZATION}    Bearer    QWxhZGRpbjpvcGVuIHNlc2FtZQ==
${AUTH_USAGE}     1
${AUTH_USAGE}     0
${CONTENT_TYPE_PATCH}    application/merge-patch+json

${apiRoot}        /
${apiRoot}        
${apiName}        vnflcm
${apiVersion}     v1

Loading