Commit 6da7037b authored by mengxuan.zhao's avatar mengxuan.zhao
Browse files

workflow SOL003 VNF LCM

parent 4f0b2dbc
*** Settings ***
Resource variables.txt
Resource VnfLcmMntOperationKeywords.robot
Resource SubscriptionKeywords.robot
Library REST http://${VNFM_HOST}:${VNFM_PORT} spec=SOL003-VNFLifecycleManagement-API.yaml
Library OperatingSystem
Library BuiltIn
Library Collections
Library JSONLibrary
*** Test Cases ***
Precondition Checks
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
... Test title: Scale out VNF operation
... Test objective: The objective is to test a scale out of an existing VNF instance
... Pre-conditions: VNF instance in INSTANTIATED state (Test ID: 5.a.b.c)
... Reference: section 5.4.5 - SOL003 v2.4.1
... Config ID: Config_prod_VNFM
... Applicability: Scale operation is supported for the VNF (as capability in the VNFD)
... NFVO is not subscribed for
... Post-Conditions: VNF instance still in INSTANTIATED state and VNF was scaled
${headers} ${status}= Send VNFScaleOut request
Check Response Status 202 ${status}
${vnfLcmOpOccId}= Get VnfLcmOpOccId ${headers}
Wait for Notification - STARTING
Deliver a notification - Operation Occurence
${VnfLcmOccInstance}= Get VnfLcmOccInstance ${vnfLcmOpOccId}
Check operationState STARTING ${VnfLcmOccInstance}
Granting exchange
Create a new Grant - Synchronous mode
Wait for Notification - PROCESSING
Deliver a notification - Operation Occurence
${VnfLcmOccInstance}= Get VnfLcmOccInstance ${vnfLcmOpOccId}
Check operationState PROCESSING ${VnfLcmOccInstance}
Wait for Notification - COMPLETED
Deliver a notification - Operation Occurence
${VnfLcmOccInstance}= Get VnfLcmOccInstance ${vnfLcmOpOccId}
Check operationState COMPLETED ${VnfLcmOccInstance}
Postcondition Checks
Check resource instantiated
${newScaleInfo}= Get Vnf Scale Info ${vnfInstanceId}
#TODO: How to check if VNF is scaled?
\ No newline at end of file
*** Settings ***
Resource variables.txt
Library REST http://${VNFM_HOST}:${VNFM_PORT} spec=SOL003-VNFLifecycleManagement-API.yaml
Library OperatingSystem
Library BuiltIn
Library JSONLibrary
Library MockServerLibrary
*** Variables ***
${sleep_interval} 20s
*** Keywords ***
Check subscriptions about one VNFInstance and operation type
[Arguments] ${vnfInstanceId} ${notificationType} ${operationType}="" ${operationState}=""
Set Headers {"Accept": "${ACCEPT}"}
Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"Authorization": "${AUTHORIZATION}"}
Run Keyword If ${notificationType}=="VnfIdentifierCreationNotification" or ${notificationType}=="VnfIdentifierDeletionNotification" GET ${apiRoot}/${apiName}/${apiVersion}/subscriptions?vnfInstanceIds=${vnfInstanceId}&notificationTypes=${notificationType}
... ELSE GET ${apiRoot}/${apiName}/${apiVersion}/subscriptions?vnfInstanceIds=${vnfInstanceId}&notificationTypes=${notificationType}&operationTypes=${operationType}&operationStates=${operationState}
Integer response status 200
Array response body minItems=1
${body} Output response body
[Return] ${body}
Deliver a notification - Operation Occurence
log The POST method delivers a notification from the server to the client.
${json}= Get File schemas/vnfLcmOperationOccurrenceNotification.schema.json
${BODY}= evaluate json.loads('''${json}''') json
Log Creating mock request and response to handle vnfLcmOperationOccurrenceNotification
&{req}= Create Mock Request Matcher POST ${notification_ep} body_type='JSON_SCHEMA' body=${BODY}
&{rsp}= Create Mock Response 204 headers="Content-Type: application/json" body_type='JSON_SCHEMA'
Create Mock Expectation ${req} ${rsp}
Sleep ${sleep_interval}
Log Verifying results
Verify Mock Expectation ${req}
Log Cleaning the endpoint
Clear Requests ${notification_ep}
\ No newline at end of file
*** Settings ***
Resource variables.txt
Library REST http://${VNFM_HOST}:${VNFM_PORT} spec=SOL003-VNFLifecycleManagement-API.yaml
Library OperatingSystem
Library BuiltIn
Library JSONLibrary
Library JSONSchemaLibrary schemas/
*** Variables ***
${GRANT_POLLING_TOT} 2
${GRANT_POLLING_INTERVAL} 5s
${SCALE_POLLING_TOT} 10
${SCALE_POLLING_INTERVAL} 15s
*** Keywords ***
Get Vnf Instance
[Arguments] ${vnfInstanceId}
Set Headers {"Accept":"${ACCEPT}"}
Set Headers {"Content-Type": "${CONTENT_TYPE}"}
Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"Authorization":"${AUTHORIZATION}"}
Get ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}
${body}= Output response body
${json}= evaluate json.loads('''${body}''') json
[Return] ${json}
Check resource Instantiated
Set Headers {"Accept":"${ACCEPT}"}
Set Headers {"Content-Type": "${CONTENT_TYPE}"}
Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"Authorization":"${AUTHORIZATION}"}
Get ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}
Integer response status 200
String response body instantiationState INSTANTIATED
Get Vnf Scale Info
[Arguments] ${vnfInstanceId}
${vnfInstance}= Get Vnf Instance ${vnfInstanceId}
${scaleInfo}= Get Value From Json ${vnfInstance} $..scaleStatus
[Return] ${scaleInfo}
Check Response Status
[Arguments] ${expected_status} ${status}
Should Be Equal ${expected_status} ${status}
Send VNFscaleOut Request
Log Trying to scale a vnf Instance
Set Headers {"Accept":"${ACCEPT}"}
Set Headers {"Content-Type": "${CONTENT_TYPE}"}
Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"Authorization":"${AUTHORIZATION}"}
${body}= Get File json/scaleVnfOutRequest.json
Post ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale ${body}
${headers}= Output response headers
${json}= evaluate json.loads('''${headers}''') json
${status}= Output response status
[Return] ${json} ${status}
Get VnfLcmOpOccId
[Arguments] ${headers}
${vnfLcmOpOccId}= Get Value From Json ${headers} $..Location
Should Not Be Empty ${vnfLcmOpOccId}
[Return] ${vnfLcmOpOccId}
Get VnfLcmOccInstance
[Arguments] ${vnfLcmOpOccId}
GET ${apiRoot}/${apiName}/${apiVersion}/vnf_lcm_op_occs/${vnfLcmOpOccId}
${body}= Output response body
${json}= evaluate json.loads('''${body}''') json
[Return] ${json}
Check operationState
[Arguments] ${operationState} ${VnfLcmOccInstance}
${currentState}= Get Value From Json ${VnfLcmOccInstance} $..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
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
Set Headers {"Accept":"${ACCEPT}"}
Set Headers {"Content-Type": "${CONTENT_TYPE}"}
Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"Authorization":"${AUTHORIZATION}"}
${body}= Get File json/grantRequest.json
Post ${apiRoot}/${apiName}/${apiVersion}/grants ${body}
Integer response status 201
Log Status code validated
${headers}= Output response headers
Should Contain ${headers} Location
${contentType}= Output response headers Content-Type
Should Contain ${contentType} ${CONTENT_TYPE}
${result}= Output response body
${json}= evaluate json.loads('''${result}''') json
Validate Json grant.schema.json ${json}
Log Validation OK
Create a new Grant - Asynchronous mode
Log Request a new Grant for a VNF LCM operation by POST to ${apiRoot}/${apiName}/${apiVersion}/grants
Pass Execution If ${SYNC_MODE} == 1 The Granting process is synchronous mode. Skipping the test
Set Headers {"Accept": "${ACCEPT}"}
Set Headers {"Content-Type": "${CONTENT_TYPE}"}
Run Keyword If ${AUTH_USAGE} == 1 Set Headers {"Authorization": "${AUTHORIZATION}"}
${body}= Get File json/grantRequest.json
Post ${apiRoot}/${apiName}/${apiVersion}/grants ${body}
Output response
Integer response status 202
Log Status code validated
${headers}= Output response headers
Should Contain ${headers} Location
${contentType}= Output response headers Content-Type
Should Contain ${contentType} ${CONTENT_TYPE}
Log Validation OK
\ No newline at end of file
{
"vnfInstanceId": "myVnfInstanceId",
"vnfLcmOpOccId": "myLcmOccId",
"vnfdId": "myVnF",
"flavourId": "string",
"operation": "INSTANTIATE",
"isAutomaticInvocation": true,
"_links": {
"vnfLcmOpOcc": {
"href": "string"
},
"vnfInstance": {
"href": "string"
}
}
}
\ No newline at end of file
...@@ -36,6 +36,4 @@ ${notification_port} 9091 ...@@ -36,6 +36,4 @@ ${notification_port} 9091
${VnfLcmOperationOccurrenceNotification} {} ${VnfLcmOperationOccurrenceNotification} {}
${VnfIdentifierCreationNotification} {} ${VnfIdentifierCreationNotification} {}
${VnfIdentifierDeletionNotification} {} ${VnfIdentifierDeletionNotification} {}
${callback_uri} http://localhost ${SYNC_MODE} 0
${callback_port} 8888 \ No newline at end of file
${callback_endpoint} /subscribe
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment