Commit 4990bc95 authored by mengxuan.zhao's avatar mengxuan.zhao
Browse files

Update high level workflow SOL003 LCM

parent 6025c07f
Loading
Loading
Loading
Loading
+37 −29
Original line number Original line Diff line number Diff line
@@ -7,16 +7,16 @@ Library OperatingSystem
Library    BuiltIn
Library    BuiltIn
Library    Collections
Library    Collections
Library    JSONLibrary
Library    JSONLibrary
Suite Teardown    Terminate All Processes    kill=true


*** variables ***
${LccnSubscriptions}
${scaleInfo}
${element}
${aspectId}


*** Test Cases ***
*** Test Cases ***
Precondition Checks
Scale out a VnFInstance
    Check resource instantiated
    ${LccnSubscriptions}=    Check subscriptions about one VNFInstance and operation type    ${vnfInstanceId}    VnfLcmOperationOccurrenceNotification    operationType=SCALE
    Set Suite Variable    ${LccnSubscriptions}
    ${scaleInfo}=    Get Vnf Scale Info        ${vnfInstanceId}

POST Scale Out a vnfInstance
    [Documentation]    Test ID: 5.x.y.x
    [Documentation]    Test ID: 5.x.y.x
    ...    Test title: Scale out VNF operation
    ...    Test title: Scale out VNF operation
    ...    Test objective: The objective is to test a scale out of an existing VNF instance
    ...    Test objective: The objective is to test a scale out of an existing VNF instance
@@ -26,33 +26,41 @@ POST Scale Out a vnfInstance
    ...    Applicability: Scale operation is supported for the VNF (as capability in the VNFD)
    ...    Applicability: Scale operation is supported for the VNF (as capability in the VNFD)
    ...    NFVO is not subscribed for
    ...    NFVO is not subscribed for
    ...    Post-Conditions: VNF instance still in INSTANTIATED state and VNF was scaled
    ...    Post-Conditions: VNF instance still in INSTANTIATED state and VNF was scaled
    
    Precondition Checks
    ${headers}    ${status}=    Send VNFScaleOut request
    ${response}    ${aspectId}=    Send VNFScaleOut request    ${vnfInstanceId}
    Check Response Status    202    ${status}
    Check Response Status    202    ${response.status}
    ${vnfLcmOpOccId}=    Get VnfLcmOpOccId   ${headers}
    Check HTTP Response Header Contains    Location    ${response.headers}
    
    ${vnfLcmOpOccId}=    Get VnfLcmOpOccId   ${response.headers}
Wait for Notification - STARTING
    Check Operation Notification    STARTING    ${notification_ep}
    Deliver a notification - Operation Occurence
    ${VnfLcmOccInstance}=    Get VnfLcmOccInstance    ${vnfLcmOpOccId}
    Check operationState    STARTING    ${VnfLcmOccInstance}

Granting exchange
    Create a new Grant - Synchronous mode
    Create a new Grant - Synchronous mode
    Check Operation Notification    PROCESSING    ${notification_ep}
    Check Operation Notification    COMPLETED    ${notification_ep}
    Postcondition Checks


Wait for Notification - PROCESSING
*** Keywords ***
    Deliver a notification - Operation Occurence
    ${VnfLcmOccInstance}=    Get VnfLcmOccInstance    ${vnfLcmOpOccId}
    Check operationState    PROCESSING    ${VnfLcmOccInstance}


Wait for Notification - COMPLETED
Precondition Checks
    Deliver a notification - Operation Occurence
    Check resource instantiated
    ${VnfLcmOccInstance}=    Get VnfLcmOccInstance    ${vnfLcmOpOccId}
    ${LccnSubscriptions}=    Check subscriptions about one VNFInstance and operation type    ${vnfInstanceId}    VnfLcmOperationOccurrenceNotification    operationType=SCALE
    Check operationState    COMPLETED    ${VnfLcmOccInstance}
    ${scaleInfo}=    Get Vnf Scale Info        ${vnfInstanceId}


Postcondition Checks
Postcondition Checks
    Check resource instantiated
    Check resource instantiated
    ${newScaleInfo}=    Get Vnf Scale Info    ${vnfInstanceId}
    ${newScaleInfo}=    Get Vnf Scale Info    ${vnfInstanceId}
    #TODO: How to check if VNF is scaled?
    Compare ScaleInfos    SCALE_OUT    ${scaleInfo}    ${newScaleInfo}  
    
Compare ScaleInfos
    [Arguments]    ${type}    ${old_scaleinfo}    ${new_scaleinfo}
    FOR    ${element}    IN    ${old_scaleinfo}
        ${old_level}=    Set Variable If    ${element.aspectId}==${aspectId}   ${element.scaleLevel}
        ${old_level_value}=    Convert To Integer    ${old_level}
    END
    FOR    ${element}    IN    ${new_scaleinfo}
        ${new_level}=    Set Variable If    ${element.aspectId}==${aspectId}   ${element.scaleLevel}
        ${new_level_value}=    Convert To Integer    ${new_level}
    END
    Run Keyword If    ${type}==SCALE_OUT    Should Be True    ${old_level_value}<${new_level_value}
    ...    ELSE    Should Be True    ${old_level_value}<${new_level_value}
   
   
    
    
    
    
 No newline at end of file
+25 −15
Original line number Original line Diff line number Diff line
*** Settings ***
*** Settings ***
Resource          environment/variables.txt
Resource          environment/variables.txt
Library           REST    http://${VNFM_HOST}:${VNFM_PORT}    spec=SOL003-VNFLifecycleManagement-API.yaml
Resource          VnfLcmMntOperationKeywords.robot
Library           REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}    spec=SOL003-VNFLifecycleManagement-API.yaml
Library           OperatingSystem
Library           OperatingSystem
Library           BuiltIn
Library           BuiltIn
Library    Process
Library           JSONLibrary
Library           JSONLibrary
Library    MockServerLibrary
Library    MockServerLibrary


@@ -19,20 +21,28 @@ Check subscriptions about one VNFInstance and operation type
    ${body}    Output    response body
    ${body}    Output    response body
    [Return]    ${body}
    [Return]    ${body}


   
Configure Notification Handler
Deliver a notification - Operation Occurence
    [Arguments]    ${element}    ${endpoint}
    log    The POST method delivers a notification from the server to the client.
    ${json}=	Get File	schemas/${element}.schema.json
    ${json}=	Get File	schemas/vnfLcmOperationOccurrenceNotification.schema.json
    ${BODY}=	evaluate	json.loads('''${json}''')	json
    ${BODY}=	evaluate	json.loads('''${json}''')	json
    Log  Creating mock request and response to handle vnfLcmOperationOccurrenceNotification
    Log  Creating mock request and response to handle ${element}
    &{req}=  Create Mock Request Matcher    POST  ${notification_ep} body_type='JSON_SCHEMA' body=${BODY}
    &{notification_request}=  Create Mock Request Matcher Schema	POST  ${endpoint}  body=${BODY}
    &{rsp}=  Create Mock Response	204 headers="Content-Type: application/json"  body_type='JSON_SCHEMA'
    &{notification_response}=  Create Mock Response Schema	headers="Content-Type: application/json"  status_code=204
    Create Mock Expectation  ${req}  ${rsp}
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Sleep  ${sleep_interval}
    [Return]        &{notification_request}
    Log  Verifying results
    
    Verify Mock Expectation  ${req}
Check Operation Notification
    Log  Cleaning the endpoint
    [Arguments]    ${status}    ${endpoint}
    Clear Requests  ${notification_ep}
    ${req}=    Configure Notification Handler     VnfLcmOperationOccurrenceNotification    ${endpoint}
    Wait Until Keyword Succeeds    2 min   10 sec    Verify Mock Expectation     ${req}    
    ${VnfLcmOccInstance}=    Get VnfLcmOccInstance    ${vnfLcmOpOccId}
    Check operationState    ${status}    ${VnfLcmOccInstance}
    Clear Requests  ${endpoint}
    
Create Sessions
    Start Process  java  -jar  ${MOCK_SERVER_JAR}  -serverPort  ${notification_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${NFVO_SCHEMA}://${NFVO_HOST}:${notification_port}     #The API producer is set to NFVO according to SOL003-5.3.9


    
    


+18 −27
Original line number Original line Diff line number Diff line
@@ -17,7 +17,7 @@ Get Vnf Instance
    Get    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}
    Get    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}
    ${body}=    Output    response body
    ${body}=    Output    response body
    ${json}=    evaluate    json.loads('''${body}''')    json
    ${json}=    evaluate    json.loads('''${body}''')    json
    [Return]    ${json}
    [Return]    ${json}    ${body.aspectId}


Check resource Instantiated
Check resource Instantiated
    Set Headers    {"Accept":"${ACCEPT}"}  
    Set Headers    {"Accept":"${ACCEPT}"}  
@@ -36,22 +36,27 @@ Get Vnf Scale Info
Check Response Status
Check Response Status
    [Arguments]    ${expected_status}    ${status}
    [Arguments]    ${expected_status}    ${status}
    Should Be Equal    ${expected_status}    ${status}
    Should Be Equal    ${expected_status}    ${status}
    Log    Status code validated 
    
Check HTTP Response Header Contains
    [Arguments]    ${CONTENT_TYPE}    ${headers}
    Should Contain    ${headers}    ${CONTENT_TYPE}
    Log    Header is present 


Send VNFscaleOut Request
Send VNFscaleOut Request
    [Arguments]    ${vnfInstanceId}
    Log    Trying to scale a vnf Instance
    Log    Trying to scale a vnf Instance
    Set Headers    {"Accept":"${ACCEPT}"}
    Set Headers    {"Accept":"${ACCEPT}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Set Headers    {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    ${body}=    Get File    json/scaleVnfOutRequest.json  
    ${body}=    Get File    json/scaleVnfOutRequest.json  
    Post    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale    ${body}
    ${response}=    Post    ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale    ${body}
    ${headers}=    Output    response headers
    [Return]    ${response}
    ${json}=    evaluate    json.loads('''${headers}''')    json
    ${status}=    Output    response status
    [Return]    ${json}    ${status}


Get VnfLcmOpOccId
Get VnfLcmOpOccId
    [Arguments]    ${headers}
    [Arguments]    ${headers}
    ${vnfLcmOpOccId}=    Get Value From Json    ${headers}    $..Location
    ${json}=    evaluate    json.loads('''${headers}''')    json
    ${vnfLcmOpOccId}=    Get Value From Json    ${json}    $..Location
    Should Not Be Empty    ${vnfLcmOpOccId}
    Should Not Be Empty    ${vnfLcmOpOccId}
    [Return]    ${vnfLcmOpOccId}
    [Return]    ${vnfLcmOpOccId}


@@ -67,20 +72,6 @@ Check operationState
    ${currentState}=    Get Value From Json    ${VnfLcmOccInstance}    $..operationState
    ${currentState}=    Get Value From Json    ${VnfLcmOccInstance}    $..operationState
    Should Be Equal    ${currentState}    ${operationState}
    Should Be Equal    ${currentState}    ${operationState}
    
    
    
Check Operation Status Transition
    [Arguments]    ${vnfLcmOpOccId}    ${initial_status}    ${final_status}    ${POLLING_TOT}    ${POLLING_INTERVAL}
    :FOR    ${INDEX}    IN RANGE    1    ${POLLING_TOT}
    \    GET    ${apiRoot}/${apiName}/${apiVersion}/vnf_lcm_op_occs/${vnfLcmOpOccId}
    \    ${status}=    Output    response status
    \    Check Response Status    200    ${status}
    \    ${body}=    Output    response body
    \    ${json}=    evaluate    json.loads('''${body}''')    json
    \    ${operationState}=    Get Value From Json    ${json}    $..operationState
    \    Run Keyword If    Should Not Be Equal    ${initial_status}    ${operationState}    Exit For Loop
    \    Sleep    ${POLLING_INTERVAL}
    Should Be Equal    ${final_status}    ${operationState}
    
Create a new Grant - Synchronous mode
Create a new Grant - Synchronous mode
    Log    Request a new Grant for a VNF LCM operation by POST to ${apiRoot}/${apiName}/${apiVersion}/grants
    Log    Request a new Grant for a VNF LCM operation by POST to ${apiRoot}/${apiName}/${apiVersion}/grants
    Pass Execution If    ${SYNC_MODE} == 0    The Granting process is asynchronous mode. Skipping the test
    Pass Execution If    ${SYNC_MODE} == 0    The Granting process is asynchronous mode. Skipping the test
+1 −1

File changed.

Contains only whitespace changes.