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

Added Test Cases for NotificationEndpoint.robot

parent b1af86fe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ Resource environment/variables.txt
Resource    FaultManagement-APIKeyword.robot 
Library    JSONLibrary
Library    JSONSchemaLibrary    schemas/
Library    REST    ${VNFM_SCHEMA}://${VNFM_HOST}:${VNFM_PORT}    
Library    REST    ${NFVMANO_SCHEMA}://${NFVMANO_HOST}:${NFVMANO_PORT}    

*** Test Cases ***
Post Individual Subscription - Method not implemented
+149 −0
Original line number Diff line number Diff line
*** Settings ***
Resource    environment/variables.txt 
Library    MockServerLibrary
Library    Process
Library    OperatingSystem
Library    Collections

Suite Setup    Create Sessions
Suite Teardown    Terminate All Processes    kill=true

*** Test Cases ***
NFV-MANO Fault Alarm Notification
    [Documentation]    Test ID: 8.3.3.5.1
    ...    Test title: NFV-MANO Fault Alarm Notification
    ...    Test objective: The objective is to test the dispatch of NFV-MANO Fault Alarm Notification when a virtualised resource within an NFV-MANO 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 NFV-MANO instance is instantiated, and a subscription for fault alarm notifications is available.
    ...    Reference: clause 7.5.7.3.1 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none 
    Trigger the fault of a virtualised resource in the NFV-MANO instance (external action) 
    Check Alarm Notification Http POST Request Body Json Schema Is    alarmNotification
    Check Alarm Notification Http POST Request Body notificationType attribute Is    alarmNotification

NFV-MANO Fault Alarm Cleared Notification
    [Documentation]    Test ID: 8.3.3.5.2
    ...    Test title: NFV-MANO Fault Alarm Cleared Notification
    ...    Test objective: The objective is to test the dispatch of NFV-MANO Fault Alarm Cleared Notification when a faulty virtualised resource within an NFV-MANO instance is cleared, 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 NFV-MANO instance is instantiated, a virtualised resource is in faulty state, and a subscription for fault alarm cleared notifications is available.
    ...    Reference: clause 7.5.7.3.1 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none 
    Trigger the clear of a faulty virtualised resource in the NFV-MANO instance (external action)
    Check Alarm cleared Notification Http POST Request Body Json Schema Is    alarmClearedNotification
    Check Alarm cleared Notification Http POST Request Body notificationType attribute Is    alarmClearedNotification

NFV-MANO Fault Alarm List Rebuilt Notification 
    [Documentation]    Test ID: 8.3.3.5.3
    ...    Test title: NFV-MANO Fault Alarm List Rebuilt Notification 
    ...    Test objective: The objective is to test the dispatch of NFV-MANO Fault Alarm List Rebuilt Notification when the NFV-MANO decides to rebuild the list of its NFV-MANO alarms, e.g. due to a corruption in the alarm storage, 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 NFV-MANO instance is instantiated, one or more virtualised resource are in faulty state, and a subscription for fault alarm list rebuilt notifications is available.
    ...    Reference: clause 7.5.7.3.1 - ETSI GS NFV-SOL 009 [5] V3.3.1
    ...    Config ID: Config_prod_NFV-MANO
    ...    Applicability: none
    ...    Post-Conditions: none 
    Trigger the NFV-MANO fault alarm list rebuild in the NFVO (external action) 
    Check Alarm list rebuilt Notification Http POST Request Body Json Schema Is    alarmListRebuiltNotification
    Check Alarm list rebuilt Notification Http POST Request Body notificationType attribute Is    alarmListRebuiltNotification


*** Keywords ***
Trigger the fault of a virtualised resource in the NFV-MANO instance (external action)  
    #do nothing
    Log    do nothing

Trigger the clear of a faulty virtualised resource in the NFV-MANO instance (external action)
    #do nothing
    Log    do nothing   

Trigger the NFV-MANO fault alarm list rebuild in the NFVO (external action) 
    #do nothing
    Log    do nothing 

Check Alarm List Rebuilt 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 Alarm List Rebuilt Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification Alarm List Rebuilt 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 Alarm 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 Alarm Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification Alarm 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 Alarm cleared 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 Alarm cleared Notification Http POST Request Body notificationType attribute Is
    [Arguments]    ${type}
    Configure Notification Alarm Cleareance 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 Alarm Clerance Notification Http POST Request Body changeType attribute Is
    [Arguments]    ${type}
    #do nothing
    Log    do nothing 
    

Configure Notification Alarm List Rebuilt 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 Alarm 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 Alarm Cleareance 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  ../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar  -serverPort  ${callback_port}  alias=mockInstance
    Wait For Process  handle=mockInstance  timeout=5s  on_timeout=continue
    Create Mock Session  ${callback_uri}:${callback_port}
+13 −2
Original line number Diff line number Diff line
@@ -31,5 +31,16 @@ ${sub_filter_invalid} filter_invalid

${subscriptionId}    6fc3539c-e602-4afa-8e13-962fb5a7d81f


${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}    []

${MOCK_SERVER_JAR}    ../../../bin/mockserver-netty-5.5.0-jar-with-dependencies.jar
 No newline at end of file
+80 −0
Original line number Diff line number Diff line
{
  "description": "This type represents an alarm cleared notification about VNF faults. The notification shall be triggered by the VNFM when an alarm has been cleared.\n",
  "type": "object",
  "required": [
    "id",
    "notificationType",
    "subscriptionId",
    "timeStamp",
    "alarmId",
    "alarmClearedTime",
    "_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 \"AlarmClearedNotification\" for this notification type.\n",
      "type": "string",
      "enum": [
        "AlarmClearedNotification"
      ]
    },
    "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"
    },
    "alarmId": {
      "description": "An identifier with the intention of being globally unique.\n",
      "type": "string"
    },
    "alarmClearedTime": {
      "description": "The time stamp indicating when the alarm was cleared.\n"
    },
    "_links": {
      "description": "Links to resources related to this notification.\n",
      "type": "object",
      "required": [
        "subscription",
        "alarm"
      ],
      "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"
            }
          }
        },
        "alarm": {
          "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
+71 −0
Original line number Diff line number Diff line
{
  "description": "This type represents a notification that the alarm list has been rebuilt, e.g. if the VNFM detects its storage holding the alarm list is corrupted. The notification shall be triggered by the VNFM when the alarm list has been rebuilt.\n",
  "type": "object",
  "required": [
    "id",
    "notificationType",
    "subscriptionId",
    "timeStamp",
    "_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 \"AlarmListRebuiltNotification\" for this notification type.\n",
      "type": "string",
      "enum": [
        "AlarmListRebuiltNotification"
      ]
    },
    "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"
    },
    "_links": {
      "description": "Links to resources related to this notification.\n",
      "type": "object",
      "required": [
        "subscription",
        "alarms"
      ],
      "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"
            }
          }
        },
        "alarms": {
          "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
Loading