Commit e0293cb6 authored by Elian Kraja's avatar Elian Kraja
Browse files

Added instrumentation platform hook for NSFaultManagement-AlarmNotification

parent ff6e5ba7
Loading
Loading
Loading
Loading
+62 −3
Original line number Original line Diff line number Diff line
@@ -6,6 +6,7 @@ Library MockServerLibrary
Library    Process
Library    Process
Library    OperatingSystem
Library    OperatingSystem
Library    Collections
Library    Collections
Library    REST     ${NFVO_SCHEMA}://${NFVO_HOST}:${NFVO_PORT}    ssl_verify=false


Suite Setup    Create Sessions
Suite Setup    Create Sessions
Suite Teardown    Terminate All Processes    kill=true
Suite Teardown    Terminate All Processes    kill=true
@@ -51,7 +52,25 @@ NS Fault Alarm List Rebuilt Notification
    Check Alarm list rebuilt Notification Http POST Request Body notificationType attribute Is    alarmListRebuiltNotification
    Check Alarm list rebuilt Notification Http POST Request Body notificationType attribute Is    alarmListRebuiltNotification




NS Fault Alarm Notification with instrumental platform hook
    [Documentation]    Test ID: 5.3.3.5.4
    ...    Test title: NS Fault Alarm Notification with instrumental platform hook
    ...    Test objective: The objective is to test the dispatch of NS Fault Alarm Notification when a virtualised resource within an NS instance fails, 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 NS instance is instantiated, and a subscription for fault alarm notifications is available in the NFVO.
    ...    Reference: Clause 8.4.6.3.1 - ETSI GS NFV-SOL 005 [3] v3.3.1
    ...    Config ID: Config_prod_NFVO
    ...    Applicability: none
    ...    Post-Conditions: none 
    Trigger the fault of a virtualised resource in the NS instance
    Check Alarm Notification Http POST Request Body Json Schema Is    alarmNotification
    Check Alarm Notification Http POST Request Body notificationType attribute Is    alarmNotification

*** Keywords ***
*** Keywords ***
Trigger the fault of a virtualised resource in the NS instance
    Create Alarm Subscription    AlarmNotification
    &{keyvalues}    Create Dictionary    eventType=COMMUNICATIONS_ALARM    delay=10s
    Trigger instrumentation platform    ${upperTesterUrlForAlarmNotifications}    ${nsInstanceIdForNotifications}    nsInstance    AlarmNotification    null    &{keyvalues}

Trigger the fault of a virtualised resource in the NS instance (external action)  
Trigger the fault of a virtualised resource in the NS instance (external action)  
    #do nothing
    #do nothing
    Log    do nothing
    Log    do nothing
@@ -114,7 +133,8 @@ Configure Notification Alarm List Rebuilt Handler
    set to dictionary    ${json}    notificationType    ${type}    
    set to dictionary    ${json}    notificationType    ${type}    
    ${BODY}=    evaluate    json.dumps(${json})    json
    ${BODY}=    evaluate    json.dumps(${json})    json
    Log  Creating mock request and response to handle status notification
    Log  Creating mock request and response to handle status notification
    &{notification_request}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    &{req}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    Set Global Variable    ${req}    ${notification_request}
    &{headers} =	Create Dictionary	Content-Type=application/json
    &{headers} =	Create Dictionary	Content-Type=application/json
    &{notification_response}=  Create Mock Response	headers=${headers}  status_code=204
    &{notification_response}=  Create Mock Response	headers=${headers}  status_code=204
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Create Mock Expectation  ${notification_request}  ${notification_response}
@@ -125,7 +145,8 @@ Configure Notification Alarm Handler
    set to dictionary    ${json}    notificationType    ${type}    
    set to dictionary    ${json}    notificationType    ${type}    
    ${BODY}=    evaluate    json.dumps(${json})    json
    ${BODY}=    evaluate    json.dumps(${json})    json
    Log  Creating mock request and response to handle status notification
    Log  Creating mock request and response to handle status notification
    &{notification_request}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    &{req}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    Set Global Variable    ${req}    ${notification_request}
    &{headers} =	Create Dictionary	Content-Type=application/json
    &{headers} =	Create Dictionary	Content-Type=application/json
    &{notification_response}=  Create Mock Response	headers=${headers}  status_code=204
    &{notification_response}=  Create Mock Response	headers=${headers}  status_code=204
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Create Mock Expectation  ${notification_request}  ${notification_response}
@@ -136,7 +157,8 @@ Configure Notification Alarm Cleareance Handler
    set to dictionary   ${json}    notificationType    ${type}
    set to dictionary   ${json}    notificationType    ${type}
    ${BODY}=    evaluate    json.dumps(${json})    json
    ${BODY}=    evaluate    json.dumps(${json})    json
    Log  Creating mock request and response to handle status notification
    Log  Creating mock request and response to handle status notification
    &{notification_request}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    &{req}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON"    body=${BODY}
    Set Global Variable    ${req}    ${notification_request}
    &{headers} =	Create Dictionary	Content-Type=application/json
    &{headers} =	Create Dictionary	Content-Type=application/json
    &{notification_response}=  Create Mock Response	headers=${headers}  status_code=204
    &{notification_response}=  Create Mock Response	headers=${headers}  status_code=204
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Create Mock Expectation  ${notification_request}  ${notification_response}
@@ -147,3 +169,40 @@ Configure Notification Forward
    &{notification_tmp}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON_SCHEMA"    body=${schema}
    &{notification_tmp}=  Create Mock Request Matcher	POST  ${endpoint}  body_type="JSON_SCHEMA"    body=${schema}
    &{notification_fwd}=  Create Mock Http Forward	${endpoint_fwd}
    &{notification_fwd}=  Create Mock Http Forward	${endpoint_fwd}
    Create Mock Expectation With Http Forward  ${notification_tmp}  ${notification_fwd}
    Create Mock Expectation With Http Forward  ${notification_tmp}  ${notification_fwd}
    


Create Alarm Subscription
    [Arguments]    ${notificationType}
    Log    Create subscription instance by POST to ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions
    Set Headers  {"Accept":"${ACCEPT}"}  
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE} == 1    Set Headers    {"${AUTHORIZATION_HEADER}":"${AUTHORIZATION_TOKEN}"}
    ${template}=    Get File    jsons/fmSubscriptionRequestForInstrumentationPlatform.json
    ${body}=        Format String   ${template}     callback_uri=${callback_uri}:${callback_port}    callback_endpoint=${callback_endpoint}    nsInstanceId=${nsInstanceIdForNotifications}    notificationType=${notificationType}
    Log  Creating mock request and response to handle GET operation on notification endpoint
    &{notification_request}=  Create Mock Request Matcher	GET  ${callback_endpoint}
    &{notification_response}=  Create Mock Response	status_code=204
    Log    Issue the subscription request
    Create Mock Expectation  ${notification_request}  ${notification_response}
    Post    ${apiRoot}/${apiName}/${apiMajorVersion}/subscriptions    ${body}    
	${output}=    Output    response
	Set Global Variable    ${response}    ${output}
	Clear Requests    ${callback_endpoint}
	

Trigger instrumentation platform    
     [Arguments]    ${upperTesterUrl}    ${resourceId}    ${resourceType}    ${event}    ${value}    &{keyvalues}
     Run Keyword If    ${event} == "AlarmNotification" or ${event} == "AlarmClearedNotification" or ${event} == "AlarmListRebuildNotification"   
     ...    Trigger Alarm Management UpperTester     ${upperTesterUrl}    ${resourceId}    ${resourceType}    ${event}    ${value}    &{keyvalues}
     
    
Trigger Alarm Management UpperTester
    [Arguments]    ${upperTesterUrl}    ${resourceId}    ${resourceType}    ${event}    ${value}    &{keyvalues}
    Set Headers  {"Content-Type": "${CONTENT_TYPE}"}
    Run Keyword If    ${AUTH_USAGE_UPPERTESTER} == 1    Set Headers    {"${AUTHORIZATION_HEADER_UPPERTESTER}":"${AUTHORIZATION_TOKEN_UPPERTESTER}"}
    ${template}=    Get File    jsons/AlarmNotificationUpperTester.json
    ${body}=        Format String   ${template}     resourceId=${resourceId}    resourceType=${resourceType}   event=${event}    value=${value}     keyvalues=${keyvalues}
    POST    ${upperTesterUrl}       ${body}
    ${output}=    Output    response
    Should Be Equal As Strings    ${output['status']}    202     
 No newline at end of file
+12 −0
Original line number Original line Diff line number Diff line
@@ -65,3 +65,15 @@ ${notification_request} []
${notification_response}    []
${notification_response}    []


${callbackResp}    127.0.0.1
${callbackResp}    127.0.0.1



### Instrumentation platform variables
${nsInstanceIdForNotifications}    SOME-ID
${AUTHORIZATION_HEADER_UPPERTESTER}    Authorization
${AUTHORIZATION_TOKEN_UPPERTESTER}    Bearer 0b79bab50daca910b000d4f1a2b675d604257e42
${AUTH_USAGE_UPPERTESTER}     0


${upperTesterUrlForAlarmNotifications}    http://localhost:9999/uppertester
+7 −0
Original line number Original line Diff line number Diff line
{{
	"resourceId":"{resourceId}",
	"resourceType":"{resourceType}",
	"event":"{event}",
	"value":"{value}",
	"keyvalue": "{keyvalue}"
}}
+0 −2
Original line number Original line Diff line number Diff line
{{
{{
  "filter": {{
  "filter": {{
    "nsInstanceSubscriptionFilter": {{
      "notificationTypes": [
      "notificationTypes": [
        "AlarmNotification"
        "AlarmNotification"
      ]
      ]
    }}
  }},
  }},
  "callbackUri": "{callback_uri}{callback_endpoint}"
  "callbackUri": "{callback_uri}{callback_endpoint}"
}}
}}
 No newline at end of file
+12 −0
Original line number Original line Diff line number Diff line
{{
  "filter": {{
    "nsInstanceSubscriptionFilter": {{
		"nsInstanceIds": ["{nsInstanceId}"]
    }},
    "notificationTypes": [
        "{notificationType}"
      ]
  }},
  "callbackUri": "{callback_uri}{callback_endpoint}"
}}