Commit 7b951530 authored by Najam UI Hassan's avatar Najam UI Hassan Committed by Giacomo Bernini
Browse files

Added Test Cases for NotificationEndpoint.robot

parent 836d7330
Loading
Loading
Loading
Loading
+113 −0
Original line number Diff line number Diff line
*** Setting ***
Resource	environment/notifications.txt
Resource	environment/variables.txt
Suite Setup    Create Sessions
Suite Teardown    Terminate All Processes    kill=true
Library    MockServerLibrary
Library    Process
Library    OperatingSystem
Library    BuiltIn
Library    Collections
Library    String


*** Test Cases ***
Performance Information Availability Notification
    [Documentation]    Test ID: 8.3.2.8.1
    ...    Test title: Performance Information Availability Notification
    ...    Test objective: The objective is to test the dispatch of Performance Information Availability Notification when new performance information is available in the NFV-MANO, 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 performance job is created, and a subscription for information availability notifications is available in the NFV-MANO.
    ...    Reference: clause 6.5.10.3.1 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none 
    Trigger the availability of Performance Information (external action) 
    Check Performance Information Available Notification Http POST Request Body Json Schema Is    PerformanceInformationAvailableNotification
    Check Performance Information Available Notification Http POST Request Body notificationType attribute Is    PerformanceInformationAvailableNotification

Threshold Crossed Notification
    [Documentation]    Test ID: 8.3.2.8.2
    ...    Test title: Threshold Crossed Notification
    ...    Test objective: The objective is to test the dispatch of Threshold Crossed Notification when a previously set performance metric threshold is crossed, 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 performance job is created, and a threshold subscription is available in the NFV-MANO.
    ...    Reference: clause 6.5.10.3.1 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none 
    Trigger the cross of Performance Threshold (external action) 
    Check Threshold Crossed Notification Http POST Request Body Json Schema Is    ThresholdCrossedNotification
    Check Threshold Crossed Notification Http POST Request Body notificationType attribute Is    ThresholdCrossedNotification


*** Keywords ***
Trigger the availability of Performance Information (external action) 
    #do nothing
    Log    do nothing

Trigger the cross of Performance Threshold (external action) 
    #do nothing
    Log    do nothing   
  
Check Performance Information Available 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 Performance Information Available Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification Performance Information Available Handler    ${callback_endpoint_fwd}    ${type}
    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}

Check Threshold Crossed 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 Threshold Crossed Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification Threshold Crossed Handler    ${callback_endpoint_fwd}    ${type}
    Wait Until Keyword Succeeds    2 min   10 sec   Verify Mock Expectation    ${notification_request}
    Clear Requests    ${callback_endpoint}
    Clear Requests    ${callback_endpoint_fwd}
    
    
Check Threshold Crossed Notification Http POST Request Body changeType attribute Is
    [Arguments]    ${type}
    #do nothing
    Log    do nothing 
    
    
Configure Notification Performance Information Available Handler
    [Arguments]    ${endpoint}    ${type}
    ${json}=    evaluate    {}
    set to dictionary    ${json}    notificationType    ${type}    
    ${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 Threshold Crossed Handler
    [Arguments]    ${endpoint}    ${type}
    ${json}=    evaluate    {}
    set to dictionary   ${json}    notificationType    ${type}
    ${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 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}

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}
 No newline at end of file
+12 −0
Original line number Diff line number Diff line
*** Variables ***
${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}    []
 No newline at end of file
+105 −0
Original line number Diff line number Diff line
{
    "description": "This notification informs the receiver that performance information is available. The timing of sending this notification is determined by the capability of the producing entity to evaluate the threshold crossing condition. The notification shall be triggered by the VNFM when new performance information collected by a PM job is available.\n",
    "type": "object",
    "required": [
      "id",
      "notificationType",
      "subscriptionId",
      "timeStamp",
      "objectInstanceId",
      "_links"
    ],
    "properties": {
      "id": {
        "description": "An identifier with the intention of being globally unique.\n",
        "type": "string"
      },
      "notificationType": {
        "description": "Discriminator for the different notification types. Shall be set to \"PerformanceInformationAvailableNotification\" for this notification type.\n",
        "type": "string",
        "enum": [
          "PerformanceInformationAvailableNotification"
        ]
      },
      "subscriptionId": {
        "description": "An identifier with the intention of being globally unique.\n",
        "type": "string"
      },
      "timeStamp": {
        "description": "Date-time stamp.  Representation: String formatted according to IETF RFC 3339.\n",
        "type": "string",
        "format": "date-time"
      },
      "objectInstanceId": {
        "description": "An identifier with the intention of being globally unique.\n",
        "type": "string"
      },
      "_links": {
        "description": "Links to resources related to this notification.\n",
        "type": "object",
        "required": [
          "subscription",
          "pmJob",
          "performanceReport"
        ],
        "properties": {
          "subscription": {
            "description": "This type represents a link to a resource.\n",
            "type": "object",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "description": "URI of the referenced resource.\n",
                "type": "string",
                "format": "url"
              }
            }
          },
          "objectInstance": {
            "description": "This type represents a link to a resource.\n",
            "type": "object",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "description": "URI of the referenced resource.\n",
                "type": "string",
                "format": "url"
              }
            }
          },
          "pmJob": {
            "description": "This type represents a link to a resource.\n",
            "type": "object",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "description": "URI of the referenced resource.\n",
                "type": "string",
                "format": "url"
              }
            }
          },
          "performanceReport": {
            "description": "This type represents a link to a resource.\n",
            "type": "object",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "description": "URI of the referenced resource.\n",
                "type": "string",
                "format": "url"
              }
            }
          }
        }
      }
    }
  }
 No newline at end of file
+113 −0
Original line number Diff line number Diff line
{
    "description": "This type represents a notification that is sent when a threshold has been crossed. The notification shall be triggered by the VNFM when a threshold has been crossed.\n",
    "type": "object",
    "required": [
      "id",
      "notificationType",
      "subscriptionId",
      "timeStamp",
      "thresholdId",
      "crossingDirection",
      "objectInstanceId",
      "performanceMetric",
      "performanceValue",
      "_links"
    ],
    "properties": {
      "id": {
        "description": "An identifier with the intention of being globally unique.\n",
        "type": "string"
      },
      "notificationType": {
        "description": "Discriminator for the different notification types. Shall be set to \"ThresholdCrossedNotification\" for this notification type.\n",
        "type": "string",
        "enum": [
          "ThresholdCrossedNotification"
        ]
      },
      "subscriptionId": {
        "description": "An identifier with the intention of being globally unique.\n",
        "type": "string"
      },
      "timeStamp": {
        "description": "Date-time stamp.  Representation: String formatted according to IETF RFC 3339.\n",
        "type": "string",
        "format": "date-time"
      },
      "thresholdId": {
        "description": "An identifier with the intention of being globally unique.\n",
        "type": "string"
      },
      "crossingDirection": {
        "type": "string",
        "enum": [
          "UP",
          "DOWN"
        ]
      },
      "objectInstanceId": {
        "description": "An identifier with the intention of being globally unique.\n",
        "type": "string"
      },
      "performanceMetric": {
        "description": "Performance metric associated with the threshold.\n",
        "type": "string"
      },
      "performanceValue": {
        "description": "Value of the metric that resulted in threshold crossing. The type of the \"performanceValue\" attribute (i.e. scalar, structure (Object in JSON), or array (of scalars, arrays or structures / Objects)) is assumed to be defined in the external measurement specification (see ETSI GS NFV-IFA 027).\n",
        "type": "object"
      },
      "_links": {
        "description": "Links to resources related to this notification.\n",
        "type": "object",
        "required": [
          "subscription",
          "threshold"
        ],
        "properties": {
          "subscription": {
            "description": "This type represents a link to a resource.\n",
            "type": "object",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "description": "URI of the referenced resource.\n",
                "type": "string",
                "format": "url"
              }
            }
          },
          "objectInstance": {
            "description": "This type represents a link to a resource.\n",
            "type": "object",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "description": "URI of the referenced resource.\n",
                "type": "string",
                "format": "url"
              }
            }
          },
          "threshold": {
            "description": "This type represents a link to a resource.\n",
            "type": "object",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "description": "URI of the referenced resource.\n",
                "type": "string",
                "format": "url"
              }
            }
          }
        }
      }
    }
  }
 No newline at end of file