Commit 77e0ea04 authored by zafar's avatar zafar Committed by Giacomo Bernini
Browse files

NotificationEndpoint and NotificationConsumer resources added in NSIUN-API

parent 2f952ddf
Loading
Loading
Loading
Loading
+24 −1
Original line number Original line Diff line number Diff line
@@ -4,6 +4,7 @@ Library REST ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT} ssl_verify=fals
Library    OperatingSystem
Library    OperatingSystem
Library    JSONLibrary
Library    JSONLibrary
Library    JSONSchemaLibrary    schemas/
Library    JSONSchemaLibrary    schemas/
Library    String


*** Keywords ***
*** Keywords ***
Check HTTP Response Status Code Is
Check HTTP Response Status Code Is
@@ -196,3 +197,25 @@ DELETE Individual subscription
    Delete    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}    
    Delete    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}    
    ${outputResponse}=    Output    response
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}
	Set Global Variable    ${response}    ${outputResponse}

Check resource existence and get CallbackUri
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    Get    ${apiRoot}/${apiName}/${apiVersion}/subscriptions/${subscriptionId}
    Integer    response status    200
    Validate Json    response body    subscription.schema.json
    Set Global Variable    ${callbackResp}    response body callbackUri

POST NS Instance Usage Notification
    log    Trying to perform a POST to deliver notification
    Set Headers  {"Accept":"${ACCEPT_JSON}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE_JSON}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"Authorization":"${AUTHORIZATION}"}
    ${template} =    Get File    jsons/NSInstanceUsageNotification.json  
    ${body}=    Format String    ${template}    subscriptionId=${subscriptionId}
    Post    ${callbackResp}    ${body}
    ${outputResponse}=    Output    response
	Set Global Variable    ${response}    ${outputResponse}

    
 No newline at end of file
+21 −0
Original line number Original line Diff line number Diff line
*** Settings ***
Library    JSONSchemaLibrary    schemas/
Resource   environment/variables.txt
Resource   NSInstanceUsageNotificationKeywords.robot  
Library    REST    ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}    ssl_verify=false
Library    OperatingSystem
Library    JSONLibrary
Suite Setup    Check resource existence and get CallbackUri

*** Test Cases ***
NS Instance Usage Notification
    [Documentation]    Test ID: 9.3.4.4.1
    ...    Test title: NS Instance Usage Notification
    ...    Test objective: The objective is to test that NS Instance Usage Notification is delivered with success to the notification consumer
    ...    Pre-conditions: A subscription for instance usage notification is available in the NFVO.
    ...    Reference: Clause 8.5.5.3.1 - ETSI GS NFV-SOL 011 [6] v3.3.1
    ...    Config ID: Config_prod_Notif_Endpoint
    ...    Applicability: none
    ...    Post-Conditions: none 
    POST NS Instance Usage Notification
    Check HTTP Response Status Code Is    204
 No newline at end of file
+112 −0
Original line number Original line Diff line number Diff line
*** Settings ***
Suite Setup       Create Sessions
Suite Teardown    Terminate All Processes    kill=true
Resource          environment/variables.txt
Library           MockServerLibrary
Library           Process
Library           OperatingSystem
Library           Collections

*** Test Cases ***
NS Instance Usage START Notification
    [Documentation]    Test ID: 9.3.4.3.1
    ...    Test title: NS Instance Usage START Notification
    ...    Test objective: The objective is to test the dispatch of NS Instance Usage Start Notification when the usage of an NS instance is started, and perform a JSON schema and content validation of the delivered notification. The action that triggers the notification under test is an explicit test step, but it is not performed by the test system.
    ...    Pre-conditions: A subscription for NS instance usage notification is available in the NFVO.
    ...    Reference: Clause 8.5.5.3.1 - ETSI GS NFV-SOL 011 [6] v3.3.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none 
    Trigger a change in NS instance usage START (external action) 
    Check NS Instance Usage Start Notification Http POST Request Body Json Schema Is    NsInstanceUsageNotification
    Check NS Instance Usage Start Notification Http POST Request Body notificationType attribute Is    NsInstanceUsageNotification
    Check NS Instance Usage Start Notification Http POST Request Body notificationStatus attribute Is    START

NS Instance Usage END Notification
    [Documentation]    Test ID: 9.3.4.3.2
    ...    Test title: NS Instance Usage END Notification
    ...    Test objective: The objective is to test the dispatch of NS Instance Usage End Notification when the usage of an NS instance is ended, and perform a JSON schema and content validation of the delivered notification. The action that triggers the notification under test is an explicit test step, but it is not performed by the test system.
    ...    Pre-conditions: A subscription for NS instance usage notification is available in the NFVO.
    ...    Reference: Clause 8.5.5.3.1 - ETSI GS NFV-SOL 011 [6] v3.3.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none 
    Trigger a change in NS instance usage END (external action) 
    Check NS Instance Usage End Notification Http POST Request Body Json Schema Is    NsInstanceUsageNotification
    Check NS Instance Usage End Notification Http POST Request Body notificationType attribute Is    NsInstanceUsageNotification
    Check NS Instance Usage End Notification Http POST Request Body notificationStatus attribute Is    END
    
*** Keywords ***
Create Sessions
    Start Process  java  -jar  ${MOCK_SERVER_JAR}  -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}:${callback_port}
    
Trigger a change in NS instance usage START (external action) 
    #do nothing
    Log    do nothing
    
Trigger a change in NS instance usage END (external action) 
    #do nothing
    Log    do nothing

Configure Notification Forward
    [Arguments]    ${schema}    ${endpoint}    ${endpoint_fwd}    
    Log  Creating mock Http POST forward to handle ${schema}
    &{notification_tmp}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON_SCHEMA"    body=${schema}
    &{notification_fwd}=  Create Mock Http Forward	${endpoint_fwd}
    Create Mock Expectation With Http Forward  ${notification_tmp}  ${notification_fwd}

Configure Notification NS Instance Usage Start Handler
    [Arguments]    ${endpoint}    ${type}    ${status}
    ${json}=    evaluate    {}
    set to dictionary   ${json}    notificationType    ${type}    changeType    ${status}
    ${BODY}=    evaluate    json.dumps(${json})    json
    Log  Creating mock request and response to handle status notification
    &{notification_request}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    &{notification_response}=  Create Mock Response	headers="Content-Type: application/json"  status_code=204
    Create Mock Expectation  ${notification_request}  ${notification_response}
    
Configure Notification NS Instance Usage End Handler
    [Arguments]    ${endpoint}    ${type}    ${status}
    ${json}=    evaluate    {}
    set to dictionary   ${json}    notificationType    ${type}    changeType    ${status}
    ${BODY}=    evaluate    json.dumps(${json})    json
    Log  Creating mock request and response to handle status notification
    &{notification_request}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    &{notification_response}=  Create Mock Response	headers="Content-Type: application/json"  status_code=204
    Create Mock Expectation  ${notification_request}  ${notification_response}
    
Check NS Instance Usage Start Notification Http POST Request Body Json Schema Is 
    [Arguments]    ${element}
    ${schema}=	Get File	schemas/${element}.schema.json
    Configure Notification Forward    ${schema}    ${callback_endpoint}    ${callback_endpoint_fwd}
    
Check NS Instance Usage Start Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification NS Instance Usage Start Handler    ${callback_endpoint_fwd}    ${type}    START
    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
    
Check NS Instance Usage Start Notification Http POST Request Body notificationStatus attribute Is
    [Arguments]    ${type}
    #do nothing
    Log    do nothing
    
Check NS Instance Usage End Notification Http POST Request Body Json Schema Is 
    [Arguments]    ${element}
    ${schema}=	Get File	schemas/${element}.schema.json
    Configure Notification Forward    ${schema}    ${callback_endpoint}    ${callback_endpoint_fwd}

Check NS Instance Usage End Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification NS Instance Usage End Handler    ${callback_endpoint_fwd}    ${type}    START
    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
    
Check NS Instance Usage End Notification Http POST Request Body notificationStatus attribute Is
    [Arguments]    ${type}
    #do nothing
    Log    do nothing    
 No newline at end of file
+19 −3
Original line number Original line Diff line number Diff line
@@ -4,6 +4,7 @@ ${NFVO_PORT} 8081 # Listening port of the NFVO
${NFVO_SCHEMA}    https
${NFVO_SCHEMA}    https
${AUTHORIZATION}    Bearer    QWxhZGRpbjpvcGVuIHNlc2FtZQ==
${AUTHORIZATION}    Bearer    QWxhZGRpbjpvcGVuIHNlc2FtZQ==
${CONTENT_TYPE}    application/json
${CONTENT_TYPE}    application/json
${CONTENT_TYPE_JSON}    application/json
${ACCEPT}         application/json
${ACCEPT}         application/json
${AUTH_USAGE}     1
${AUTH_USAGE}     1
${ACCEPT_JSON}         application/json
${ACCEPT_JSON}         application/json
@@ -13,10 +14,9 @@ ${apiVersion} v1


${SYNC_MODE}    1
${SYNC_MODE}    1


${response}    {}


${response}
${NFVO_DUPLICATION}    1

${NFVO_DUPLICATION}


${VNFM_HOST}      localhost    # Hostname of the VNFM
${VNFM_HOST}      localhost    # Hostname of the VNFM
${VNFM_PORT}      8080    # Listening port of the VNFM
${VNFM_PORT}      8080    # Listening port of the VNFM
@@ -40,3 +40,19 @@ ${fields} criteria,objectInstanceIds
${subscriptionId}    6fc3539c-e602-4afa-8e13-962fb5a7d81f
${subscriptionId}    6fc3539c-e602-4afa-8e13-962fb5a7d81f
${notification_ep}    notification
${notification_ep}    notification
${VrQuotaAvailNotification}    {}
${VrQuotaAvailNotification}    {}

${callback_uri}    http://localhost
${callback_port}    9091
${callback_endpoint}    /endpoint
${callback_endpoint_fwd}    /endpoint/check
${callback_endpoint_error}    /endpoint_404
${sleep_interval}    20s
${total_polling_time}   2 min
${polling_interval}     10 sec

${notification_request}    []
${notification_response}    []

${callbackResp}		127.0.0.1

${MOCK_SERVER_JAR}    ../../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar
+9 −0
Original line number Original line Diff line number Diff line
{{
  "id": "",
  "notificationType": "NSInstanceUsageNotification",
  "subscriptionId": "{subscriptionId}",
  "timeStamp": "",
  "nsInstanceId": "",
  "status": "START",
  "_links": ""
}}
 No newline at end of file
Loading