Skip to content
NSLCMOperationKeywords.robot 64.9 KiB
Newer Older
aureliano sinatra's avatar
aureliano sinatra committed
*** Settings ***
Giacomo Bernini's avatar
Giacomo Bernini committed
Resource   environment/variables.txt
Library    REST     ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}    ssl_verify=false
aureliano sinatra's avatar
aureliano sinatra committed
Library    JSONLibrary
Library    Process
Library    JSONSchemaLibrary    schemas/
Library    OperatingSystem
Library    MockServerLibrary
root's avatar
root committed
Library    Collections
Giacomo Bernini's avatar
Giacomo Bernini committed
Library    String
aureliano sinatra's avatar
aureliano sinatra committed

*** Keywords ***
Initialize System
    Start Process  java  -jar  ../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar  -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}:${callback_port} 
    
Check Operation Occurrence Id
Elian Kraja's avatar
Elian Kraja committed
    ${occid}=    Get Value From Json    ${response['headers']['Location']}  ${response}
aureliano sinatra's avatar
aureliano sinatra committed
    Set Global Variable    @{nsLcmOpOccId}    ${occid}
    Should Not Be Empty    ${nsLcmOpOccId}
    
Create Sessions
    Start Process  java  -jar  ../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar  -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}:${callback_port}   
    
Check subscription existence
aureliano sinatra's avatar
aureliano sinatra committed
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId} 
    Integer    response status    200
    
root's avatar
root committed
Check Instance Deleted
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
root's avatar
root committed
    Delete    ${apiRoot}/${apiName}/${apiVersion}/ns_instances/${nsInstanceId}
root's avatar
root committed
    Integer    response status    404
root's avatar
root committed
    
aureliano sinatra's avatar
aureliano sinatra committed
Check Fail not supported
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_lcm_op_occs/${nsLcmOpOccId}
    # how to check if Fail is not supported? Also In Sol002
    
Check Cancel not supported
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_lcm_op_occs/${nsLcmOpOccId}
    # how to check if Cancel is not supported? Also In Sol002
    
Check Continue not supported
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_lcm_op_occs/${nsLcmOpOccId}
    # how to check if Continue is not supported? Also In Sol002
    
Check retry not supported
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_lcm_op_occs/${nsLcmOpOccId}
    # how to check if retry is not supported? Also In Sol002
    
Check Rollback not supported
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_lcm_op_occs/${nsLcmOpOccId}
    # how to check if rollback is not supported? Also In Sol002
    
Check resource FAILED_TEMP
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_lcm_op_occs/${nsLcmOpOccId} 
    String    response body operationState    FAILED_TEMP

Check resource not 
    [Arguments]   ${status}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_lcm_op_occs/${nsLcmOpOccId} 
    Should Not Be Equal As Strings  response body operationState    ${status}

aureliano sinatra's avatar
aureliano sinatra committed
Check Operation Notification Status is
    [Arguments]    ${status}
    Check Operation Notification    NsLcmOperationOccurrenceNotification   ${status}

Check Operation Notification
    [Arguments]    ${element}    ${status}
aureliano sinatra's avatar
aureliano sinatra committed
    ${json}=	Get File	schemas/${element}.schema.json
    Configure Notification Forward    ${element}    ${callback_endpoint}    ${callback_endpoint_fwd}
    Configure Notification Status Handler    ${callback_endpoint_fwd}    ${status}
    Wait Until Keyword Succeeds    ${notification_timeout}   ${poll_interval}   Verify Mock Expectation    ${notification_request}
aureliano sinatra's avatar
aureliano sinatra committed
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
    
Configure Notification Forward
    [Arguments]    ${element}    ${endpoint}    ${endpoint_fwd}    
   # ${BODY}=	evaluate	json.loads('''${json}''')	json
aureliano sinatra's avatar
aureliano sinatra committed
    Log  Creating mock HTTP forward to handle ${element}
    &{notification_tmp}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON_SCHEMA"    body=${element}
aureliano sinatra's avatar
aureliano sinatra committed
    &{notification_fwd}=  Create Mock Http Forward	${endpoint_fwd}
    Create Mock Expectation With Http Forward  ${notification_tmp}  ${notification_fwd}
    
Configure Notification Status Handler
    [Arguments]    ${endpoint}    ${status}
    set to dictionary   ${json}    notificationStatus    ${status}   
aureliano sinatra's avatar
aureliano sinatra committed
    ${BODY}=    evaluate    json.dumps(${json})    json
    Log  Creating mock request and response to handle ${endpoint}
    &{req}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    Set Global Variable    ${req}    ${notification_request}
    &{headers} =    Create Dictionary    Content-Type=application/json
    &{notification_response}=  Create Mock Response    headers=${headers}    status_code=204
aureliano sinatra's avatar
aureliano sinatra committed
    Create Mock Expectation  ${notification_request}  ${notification_response}    
        
Check resource operationState is
    [Arguments]    ${state} 
Elian Kraja's avatar
Elian Kraja committed
    String    ${response['body']['operationState']}   ${state}
Check resource INSTANTIATED
aureliano sinatra's avatar
aureliano sinatra committed
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    GET    ${response['headers']['Location']}  
    ${opocc}=    Output    response
    Should Be Equal as Strings  ${opocc['status']}    200
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_instances/${opocc['body']['nsInstanceId']} 
Elian Kraja's avatar
Elian Kraja committed
    String    response body nsState    INSTANTIATED
aureliano sinatra's avatar
aureliano sinatra committed
    
Check resource not_instantiated
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_instances/${response['body']['id']}
    String    response body nsState     NOT_INSTANTIATED

Check NS resource not_instantiated
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    GET    ${response['headers']['Location']}  
    ${opocc}=    Output    response
    Should Be Equal as Strings  ${opocc['status']}    200
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_instances/${opocc['body']['nsInstanceId']} 
Elian Kraja's avatar
Elian Kraja committed
    String    response body nsState     NOT_INSTANTIATED
Check operation resource state is FAILED_TEMP    
aureliano sinatra's avatar
aureliano sinatra committed
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    GET    ${response['headers']['Location']}
    ${opocc}=    Output    response
    Should Be Equal as Strings  ${opocc['status']}    200
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_instances/${opocc['body']['nsInstanceId']}
aureliano sinatra's avatar
aureliano sinatra committed
    String    response body instantiationState    FAILED_TEMP 
Elian Kraja's avatar
Elian Kraja committed
    
Check operation resource state is not FAILED_TEMP
    Check operation resource state is FAILED_TEMP    
aureliano sinatra's avatar
aureliano sinatra committed
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    GET    ${response['headers']['Location']}  
    ${opocc}=    Output    response
    Should Be Equal as Strings  ${opocc['status']}    200
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_instances/${opocc['body']['nsInstanceId']}
Giacomo Bernini's avatar
Giacomo Bernini committed
    String  response body instantiationState  not  FAILED_TEMP
aureliano sinatra's avatar
aureliano sinatra committed

Check resource is finally failed
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    GET    ${response['headers']['Location']}  
    ${opocc}=    Output    response
    Should Be Equal as Strings  ${opocc['status']}    200
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_instances/${opocc['body']['nsInstanceId']}
aureliano sinatra's avatar
aureliano sinatra committed
    String    response body instantiationState    FINALLY_FAILED 

aureliano sinatra's avatar
aureliano sinatra committed
Launch another LCM operation
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
    ${body}=    Get File    jsons/scaleNsToLevelRequest.json
    Post    ${apiRoot}/${apiName}/${apiVersion}/ns_instances/${nsInstanceId}/scale_to_level    ${body}
    Integer    response status    202

aureliano sinatra's avatar
aureliano sinatra committed
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
aureliano sinatra's avatar
aureliano sinatra committed
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_instances/${nsInstanceId} 
    Integer    response status    200
    
root's avatar
root committed
Check Postcondition NS Instance is not created
root's avatar
root committed
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
root's avatar
root committed
    Get    ${apiRoot}/${apiName}/${apiVersion}/ns_instances/${nsInstanceId} 
    Integer    response status    404
    
aureliano sinatra's avatar
aureliano sinatra committed
Check HTTP Response Status Code Is
    [Arguments]    ${expected_status}
    Log    Validate Status code    
Elian Kraja's avatar
Elian Kraja committed
    Should Be Equal as Strings  ${response['status']}    ${expected_status}
aureliano sinatra's avatar
aureliano sinatra committed
    Log    Status code validated 
    
root's avatar
root committed
Check Postcondition NS Instance is deleted
Loading full blame...