From 4990bc9541746682ee0866f8897d54d93e5ed166 Mon Sep 17 00:00:00 2001 From: mxzhao Date: Mon, 17 Dec 2018 17:56:08 +0100 Subject: [PATCH] Update high level workflow SOL003 LCM --- ...iateVNFTaskWithCheckAndNotifications.robot | 2 +- .../ScaleVNFTaskWorkflow.robot | 66 +++++++++++-------- .../SubscriptionKeywords.robot | 40 ++++++----- .../VnfLcmMntOperationKeywords.robot | 45 +++++-------- 4 files changed, 81 insertions(+), 72 deletions(-) diff --git a/SOL003/VNFLifecycleManagement-API/InstantiateVNFTaskWithCheckAndNotifications.robot b/SOL003/VNFLifecycleManagement-API/InstantiateVNFTaskWithCheckAndNotifications.robot index b755559c..e087dfcf 100644 --- a/SOL003/VNFLifecycleManagement-API/InstantiateVNFTaskWithCheckAndNotifications.robot +++ b/SOL003/VNFLifecycleManagement-API/InstantiateVNFTaskWithCheckAndNotifications.robot @@ -22,7 +22,7 @@ ${vnfInstanceId} *** Test Cases *** VNF Instantiation -[Documentation] Test ID: 5.x.y.x + [Documentation] Test ID: 5.x.y.x ... Test title: VNF Instantiation ... Test objective: The objective is to test the instantiation of a VNF instance ... Pre-conditions: VNF instance resources is created (Test ID: 5.a.b.c) diff --git a/SOL003/VNFLifecycleManagement-API/ScaleVNFTaskWorkflow.robot b/SOL003/VNFLifecycleManagement-API/ScaleVNFTaskWorkflow.robot index a1127bcb..4aad647a 100644 --- a/SOL003/VNFLifecycleManagement-API/ScaleVNFTaskWorkflow.robot +++ b/SOL003/VNFLifecycleManagement-API/ScaleVNFTaskWorkflow.robot @@ -7,16 +7,16 @@ Library OperatingSystem Library BuiltIn Library Collections Library JSONLibrary - +Suite Teardown Terminate All Processes kill=true -*** 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} +*** variables *** +${LccnSubscriptions} +${scaleInfo} +${element} +${aspectId} -POST Scale Out a vnfInstance +*** Test Cases *** +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 @@ -26,33 +26,41 @@ POST Scale Out a vnfInstance ... 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 + Precondition Checks + ${response} ${aspectId}= Send VNFScaleOut request ${vnfInstanceId} + Check Response Status 202 ${response.status} + Check HTTP Response Header Contains Location ${response.headers} + ${vnfLcmOpOccId}= Get VnfLcmOpOccId ${response.headers} + Check Operation Notification STARTING ${notification_ep} Create a new Grant - Synchronous mode + Check Operation Notification PROCESSING ${notification_ep} + Check Operation Notification COMPLETED ${notification_ep} + Postcondition Checks -Wait for Notification - PROCESSING - Deliver a notification - Operation Occurence - ${VnfLcmOccInstance}= Get VnfLcmOccInstance ${vnfLcmOpOccId} - Check operationState PROCESSING ${VnfLcmOccInstance} +*** Keywords *** -Wait for Notification - COMPLETED - Deliver a notification - Operation Occurence - ${VnfLcmOccInstance}= Get VnfLcmOccInstance ${vnfLcmOpOccId} - Check operationState COMPLETED ${VnfLcmOccInstance} +Precondition Checks + Check resource instantiated + ${LccnSubscriptions}= Check subscriptions about one VNFInstance and operation type ${vnfInstanceId} VnfLcmOperationOccurrenceNotification operationType=SCALE + ${scaleInfo}= Get Vnf Scale Info ${vnfInstanceId} Postcondition Checks Check resource instantiated ${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 diff --git a/SOL003/VNFLifecycleManagement-API/SubscriptionKeywords.robot b/SOL003/VNFLifecycleManagement-API/SubscriptionKeywords.robot index 708c03f5..d2eb4d2a 100644 --- a/SOL003/VNFLifecycleManagement-API/SubscriptionKeywords.robot +++ b/SOL003/VNFLifecycleManagement-API/SubscriptionKeywords.robot @@ -1,8 +1,10 @@ *** Settings *** 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 BuiltIn +Library Process Library JSONLibrary Library MockServerLibrary @@ -18,21 +20,29 @@ Check subscriptions about one VNFInstance and operation type 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 + +Configure Notification Handler + [Arguments] ${element} ${endpoint} + ${json}= Get File schemas/${element}.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} + Log Creating mock request and response to handle ${element} + &{notification_request}= Create Mock Request Matcher Schema POST ${endpoint} body=${BODY} + &{notification_response}= Create Mock Response Schema headers="Content-Type: application/json" status_code=204 + Create Mock Expectation ${notification_request} ${notification_response} + [Return] &{notification_request} + +Check Operation Notification + [Arguments] ${status} ${endpoint} + ${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 diff --git a/SOL003/VNFLifecycleManagement-API/VnfLcmMntOperationKeywords.robot b/SOL003/VNFLifecycleManagement-API/VnfLcmMntOperationKeywords.robot index 1b3df8fb..90e3dbef 100644 --- a/SOL003/VNFLifecycleManagement-API/VnfLcmMntOperationKeywords.robot +++ b/SOL003/VNFLifecycleManagement-API/VnfLcmMntOperationKeywords.robot @@ -1,9 +1,9 @@ *** Settings *** -Resource environment/variables.txt -Library REST http://${VNFM_HOST}:${VNFM_PORT} spec=SOL003-VNFLifecycleManagement-API.yaml -Library OperatingSystem -Library BuiltIn -Library JSONLibrary +Resource environment/variables.txt +Library REST http://${VNFM_HOST}:${VNFM_PORT} spec=SOL003-VNFLifecycleManagement-API.yaml +Library OperatingSystem +Library BuiltIn +Library JSONLibrary Library JSONSchemaLibrary schemas/ @@ -17,7 +17,7 @@ Get Vnf Instance Get ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId} ${body}= Output response body ${json}= evaluate json.loads('''${body}''') json - [Return] ${json} + [Return] ${json} ${body.aspectId} Check resource Instantiated Set Headers {"Accept":"${ACCEPT}"} @@ -36,22 +36,27 @@ Get Vnf Scale Info Check Response Status [Arguments] ${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 + [Arguments] ${vnfInstanceId} 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} + ${body}= Get File json/scaleVnfOutRequest.json + ${response}= Post ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/scale ${body} + [Return] ${response} Get VnfLcmOpOccId [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} [Return] ${vnfLcmOpOccId} @@ -67,20 +72,6 @@ Check operationState ${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 -- GitLab