Commit 5e01be6a authored by Giacomo Bernini's avatar Giacomo Bernini
Browse files

example of VNF instantiation with HL code

parent 6da7037b
*** Setting *** *** Setting ***
Suite Setup Create Sessions Suite Setup Initialize System
Suite Teardown Terminate All Processes kill=true Suite Teardown Terminate All Processes kill=true
Resource variables.txt Resource variables.txt
Library OperatingSystem Library OperatingSystem
...@@ -11,39 +11,25 @@ Library String ...@@ -11,39 +11,25 @@ Library String
Library JSONSchemaLibrary schemas/ Library JSONSchemaLibrary schemas/
Library JSONLibrary Library JSONLibrary
Library REST ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT} Library REST ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}
Documentation
... Preconditions:
... ... Mock server's jar should be locally present on the same directory when the test will run
... ... The notification endpoint will be configured on http://localhost:8888/subscribe
... ... Subscription to LCM operations previously performed using as callback_URI: http://localhost:8888/subscribe.
*** Variables ***
${headers}
${vnfLcmOpOccId}
${response}
&{notification_request}
&{notification_response}
${vnfInstanceId}
*** Test Cases *** *** Test Cases ***
Create VNFInstance VNF Instantiation
Log Start Notification handler Send VNF Instantiation Request
${req}= Start Notification Handler VnfIdentifierCreationNotification ${callback_endpoint} Check HTTP Response Status Code Is 202
Log Create VNF Instance Resource Check HTTP Response Header Contains Location
${resource_response} = Create VNF Resource Check Operation Occurrence Id
Validate Status Code ${resource_response.status_code} 201 Check Operation Notification STARTING
Validate Header ${resource_response.headers} Location Check Operation Notification PROCESSING
Validate Header ${resource_response.headers} Content-Type Check Operation Notification COMPLETED
Validate JsonSchema ${resource_response.body} vnfInstance.schema.json Check Postcondition
Verify Notification Handler ${req}
Log Instantiate VNF
${req}= Start Notification Handler VnfLcmOperationOccurrenceNotification ${callback_endpoint}
${instance_response}= Instantiate VNF ${resource_response.body.id}
Validate Status Code ${instance_response.status_code} 202
Validate Header ${instance_response.headers} Location
Verify Notification Handler ${req}
Wait Until VNF Instantiated ${instance_response.headers.Location}
Log Retrieve VNF Instance
${get_response}= Retrieve VNFinstance ${instance_response.body.id}
Should Not Be Empty ${get_response}
Validate Status Code ${get_response.status_code} 200
Should Be Equal ${instance_response.body.id} ${get_response.body.id}
Validate Header ${get_response.headers} Content-Type
Validate JsonSchema ${get_response.body} vnfInstance.schema.json
*** Keywords *** *** Keywords ***
Create VNF Resource Create VNF Resource
...@@ -52,83 +38,91 @@ Create VNF Resource ...@@ -52,83 +38,91 @@ Create VNF Resource
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/createVnfRequest.json ${body}= Get File json/createVnfRequest.json
Post ${apiRoot}/${apiName}/${apiVersion}/vnf_instances ${body} ${response}= Post ${apiRoot}/${apiName}/${apiVersion}/vnf_instances ${body}
[Return] response
Send VNF Instantiation Request
Instantiate VNF Log Instantiate a VNF Instance
[Arguments] ${vnfInstanceId}
Log Instantiate 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/instantiateVnfRequest.json ${body}= Get File json/instantiateVnfRequest.json
Post ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/instantiate ${body} ${response}= Post ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfInstanceId}/instantiate ${body}
[Return] response
Validate Status Code Check HTTP Response Status Code Is
[Arguments] ${curr_status} ${exp_status} [Arguments] ${expected_status}
Should Be Equal ${curr_status} ${exp_status} Should Be Equal ${response.status_code} ${expected_status}
Log Status code validated Log Status code validated
Check HTTP Response Header Contains
Validate Header [Arguments] ${CONTENT_TYPE}
[Arguments] ${headers} ${CONTENT_TYPE} Should Contain ${response.headers} ${CONTENT_TYPE}
Should Contain ${headers} ${CONTENT_TYPE}
Log Header is present Log Header is present
Check Operation Occurrence Id
${vnfLcmOpOccId}= Get Value From Json ${response.headers} $..Location
Should Not Be Empty ${vnfLcmOpOccId}
Validate JsonSchema Check HTTP Response Body Json Schema Is
[Arguments] ${body} ${schema} [Arguments] ${schema}
${json}= evaluate json.loads('''${body}''') json ${json}= evaluate json.loads('''${response.body}''') json
Validate Json ${schema} ${json} Validate Json ${schema} ${json}
Log Validation OK ${vnfInstanceId}= ${response.body.id}
Log Json Schema Validation OK
Validate VNF Status Check VNF Status
[Arguments] ${current} ${expected} [Arguments] ${current} ${expected}
Should Be Equal As Strings ${current} ${expected} Should Be Equal As Strings ${current} ${expected}
Log VNF Status in the correct status Log VNF Status in the correct status
Retrieve VNFinstance Check VNF Instance
[Arguments] ${vnfId} [Arguments] ${vnfId}
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}"}
Get ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfId} ${response}= Get ${apiRoot}/${apiName}/${apiVersion}/vnf_instances/${vnfId}
[Return] response
Create Sessions Create Sessions
Start Process java -jar mockserver-netty-5.3.0-jar-with-dependencies.jar -serverPort ${callback_port} alias=mockInstance Start Process java -jar mockserver-netty-5.3.0-jar-with-dependencies.jar -serverPort ${callback_port} alias=mockInstance
Wait For Process handle=mockInstance timeout=5s on_timeout=continue Wait For Process handle=mockInstance timeout=5s on_timeout=continue
Create Mock Session ${callback_uri}:${callback_port} Create Mock Session ${callback_uri}:${callback_port}
Configure Notification Handler
Start Notification Handler
[Arguments] ${element} ${endpoint} [Arguments] ${element} ${endpoint}
${json}= Get File schemas/${element}.schema.json ${json}= Get File schemas/${element}.schema.json
${BODY}= evaluate json.loads('''${json}''') json ${BODY}= evaluate json.loads('''${json}''') json
Log Creating mock request and response to handle ${element} Log Creating mock request and response to handle ${element}
&{req}= Create Mock Request Matcher Schema POST ${endpoint} body=${BODY} &{notification_request}= Create Mock Request Matcher Schema POST ${endpoint} body=${BODY}
&{rsp}= Create Mock Response Schema headers="Content-Type: application/json" status_code=204 &{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}
[Return] ${req}
Verify Notification Handler
[Arguments] ${request}
Verify Mock Expectation ${request}
Clear Requests ${callback_endpoint}
Wait Until VNF Instantiated Check Operation Notification
[Arguments] ${vnfLcmOpOccId} [Arguments] ${status}
${req}= Start Notification Handler VnfLcmOperationOccurrenceNotification ${callback_endpoint} Configure Notification Handler VnfLcmOperationOccurrenceNotification ${callback_endpoint}
:FOR ${i} IN RANGE 20 Wait Until Keyword Succeeds 2 min 10 sec Verify Notification ${status}
\ Sleep 10s Get ${vnfLcmOpOccId}
\ Verify Mock Expectation ${req} ${body}= Output response body
\ Get ${vnfLcmOpOccId} Should Be Equal ${body.operationState} ${status}
\ ${body}= Output response body Clear Requests ${callback_endpoint}
\ Exit For Loop If ${body.operationState} == COMPLETED
Clear Requests ${callback_endpoint}
Verify Notification COMPLETED
[Arguments] ${status}
\ No newline at end of file Verify Mock Expectation ${notification_request}
Initialize System
Create Sessions
Configure Notification Handler VnfIdentifierCreationNotification ${callback_endpoint}
Create VNF Resource
Check HTTP Response Status Code Is 201
Check HTTP Response Header Contains Location
Check HTTP Response Header Contains ${response.headers} Content-Type
Check HTTP Response Body Json Schema Is vnfInstance.schema.json
Check Postcondition
Log Retrieve VNF Instance
Check VNF Instance ${vnfInstanceId}
Should Not Be Empty ${response}
Check HTTP Status Code Is 200
Should Be Equal ${response.body.id} ${vnfInstanceId}
Check HTTP Response Header Contains Content-Type
Check HTTP Response Json Schema ${response.body} vnfInstance.schema.json
Check VNF Status ${response.body.instantiationState} INSTANTIATED
\ No newline at end of file
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