From 88bff1084246b48e0e65ebaf14f34be1fc7534b5 Mon Sep 17 00:00:00 2001
From: Elian Kraja <e.kraja@nextworks.it>
Date: Fri, 16 Nov 2018 16:25:58 +0100
Subject: [PATCH] Adding notification file for Performance Management

---
 .../PerformanceManagementNotification.robot   | 58 +++++++++++++++++++
 .../environment/generic.txt                   | 19 ++++++
 ...manceInformationAvailableNotification.json | 13 +++++
 .../jsons/ThresholdCrossedNotification.json   | 16 +++++
 .../schemas/ProblemDetails.schema.json        |  1 +
 TrackingStatus.txt                            |  2 +-
 6 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100644 SOL003/VNFPerformanceManagementNotification-API_nxw/PerformanceManagementNotification.robot
 create mode 100644 SOL003/VNFPerformanceManagementNotification-API_nxw/environment/generic.txt
 create mode 100644 SOL003/VNFPerformanceManagementNotification-API_nxw/jsons/PerformanceInformationAvailableNotification.json
 create mode 100644 SOL003/VNFPerformanceManagementNotification-API_nxw/jsons/ThresholdCrossedNotification.json
 create mode 100644 SOL003/VNFPerformanceManagementNotification-API_nxw/schemas/ProblemDetails.schema.json

diff --git a/SOL003/VNFPerformanceManagementNotification-API_nxw/PerformanceManagementNotification.robot b/SOL003/VNFPerformanceManagementNotification-API_nxw/PerformanceManagementNotification.robot
new file mode 100644
index 00000000..d40a65e1
--- /dev/null
+++ b/SOL003/VNFPerformanceManagementNotification-API_nxw/PerformanceManagementNotification.robot
@@ -0,0 +1,58 @@
+*** Setting ***
+Suite Setup    Create Sessions
+Suite Teardown    Terminate All Processes    kill=true
+Library    MockServerLibrary
+Library    Process
+Library    OperatingSystem
+Library    BuiltIn
+Library    RequestsLibrary
+Library    Collections
+Library    String
+
+*** Variable ***
+${callback_uri}    http://localhost
+${callback_port}    9091
+${callback_endpoint}    /endpoint
+${sleep_interval}    20s
+
+*** Test Cases ***
+Check Notification Endpoint
+    &{req}=  Create Mock Request Matcher Schema	GET  ${callback_endpoint}    
+    &{rsp}=  Create Mock Response Schema	headers="Content-Type: application/json"  status_code=204
+    Create Mock Expectation  ${req}  ${rsp}
+    Sleep  ${sleep_interval}
+    Verify Mock Expectation  ${req}
+    Clear Requests  ${callback_endpoint}
+    
+Post Performance Information Available Notification
+    ${json}=	Get File	jsons/PerformanceInformationAvailableNotification.json
+    ${BODY}=	evaluate	json.loads('''${json}''')	json
+    Log  Creating mock request and response to handle Performance Information Available Notification
+    &{req}=  Create Mock Request Matcher Schema	POST  ${callback_endpoint}  body=${BODY}
+    &{rsp}=  Create Mock Response Schema	headers="Content-Type: application/json"  status_code=204
+    Create Mock Expectation  ${req}  ${rsp}
+    Sleep  ${sleep_interval}
+    Log  Verifying results
+    Verify Mock Expectation  ${req}
+    Log  Cleaning the endpoint
+    Clear Requests  ${callback_endpoint}
+
+Post Threshold Crossed Notification
+    ${json}=	Get File	jsons/ThresholdCrossedNotification.json
+    ${BODY}=	evaluate	json.loads('''${json}''')	json
+    Log  Creating mock request and response to handle Threshold Crossed Notification
+    &{req}=  Create Mock Request Matcher Schema	POST  ${callback_endpoint}  body=${BODY}
+    &{rsp}=  Create Mock Response Schema	headers="Content-Type: application/json"  status_code=204
+    Create Mock Expectation  ${req}  ${rsp}
+    Sleep  ${sleep_interval}
+    Log  Verifying results
+    Verify Mock Expectation  ${req}
+    Log  Cleaning the endpoint
+    Clear Requests  ${callback_endpoint}
+
+*** Keywords ***
+Create Sessions
+    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
+	Create Session  server  ${callback_uri}:${callback_port}
+    Create Mock Session  ${callback_uri}:${callback_port}
\ No newline at end of file
diff --git a/SOL003/VNFPerformanceManagementNotification-API_nxw/environment/generic.txt b/SOL003/VNFPerformanceManagementNotification-API_nxw/environment/generic.txt
new file mode 100644
index 00000000..4f4b0194
--- /dev/null
+++ b/SOL003/VNFPerformanceManagementNotification-API_nxw/environment/generic.txt
@@ -0,0 +1,19 @@
+*** Variables ***
+${VNFM_HOST}      localhost    # Hostname of the VNFM
+${VNFM_PORT}      8080    # Listening port of the VNFM
+${NFVO_HOST}      localhost    # Hostname of the NFVO
+${NFVO_PORT}      8081    # Listening port of the NFVO
+${VNFM_SCHEMA}    https
+${NFVO_SCHEMA}    https
+${AUTHORIZATION}    Bearer 0b79bab50daca910b000d4f1a2b675d604257e42
+${CONTENT_TYPE_JSON}    application/json
+${ACCEPT_JSON}    application/json
+${apiRoot}        /
+${AUTH_USAGE}     1
+${NEG_AUTHORIZATION}    Bearer negativetoken
+${apiVersion}     v1
+${apiName}        vnfpm
+${FIELD_USAGE}    1
+${VNFM_AUTHENTICATION}    Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
+${VNFM_AUTH_USAGE}    1
+${VNFM_DUPLICATION}    1
diff --git a/SOL003/VNFPerformanceManagementNotification-API_nxw/jsons/PerformanceInformationAvailableNotification.json b/SOL003/VNFPerformanceManagementNotification-API_nxw/jsons/PerformanceInformationAvailableNotification.json
new file mode 100644
index 00000000..cbe45fa7
--- /dev/null
+++ b/SOL003/VNFPerformanceManagementNotification-API_nxw/jsons/PerformanceInformationAvailableNotification.json
@@ -0,0 +1,13 @@
+{
+	"id": "id",
+	"notificationType" : "PerformanceInformationAvailableNotification",
+	"subscriptionId ": "subscriptionId",
+	"timeStamp": "2012-04-21T18:25:43-05:00",
+	"objectInstanceId": "vnfID",
+	"_links": {
+			"subscription": "link to subscription",
+			"pmJob" : "link to PMJob",
+			"performanceReport": "link to PerformanceReport"
+	}
+	
+}
\ No newline at end of file
diff --git a/SOL003/VNFPerformanceManagementNotification-API_nxw/jsons/ThresholdCrossedNotification.json b/SOL003/VNFPerformanceManagementNotification-API_nxw/jsons/ThresholdCrossedNotification.json
new file mode 100644
index 00000000..23ee9e24
--- /dev/null
+++ b/SOL003/VNFPerformanceManagementNotification-API_nxw/jsons/ThresholdCrossedNotification.json
@@ -0,0 +1,16 @@
+{
+	"id": "id",
+	"notificationType" : "ThresholdCrossedNotification",
+	"subscriptionId ": "subscriptionId",
+	"timeStamp": "2012-04-21T18:25:43-05:00",
+	"thresholdId": "thresholdId",
+	"crossingDirection": "UP",
+	"objectInstanceId": "vnfID",
+	"performanceMetric": "performanceMetric",
+	"performanceValue": 7
+	"_links": {
+			"subscription": "link to subscription",
+			"threshold": "link to threshold"
+	}
+	
+}
\ No newline at end of file
diff --git a/SOL003/VNFPerformanceManagementNotification-API_nxw/schemas/ProblemDetails.schema.json b/SOL003/VNFPerformanceManagementNotification-API_nxw/schemas/ProblemDetails.schema.json
new file mode 100644
index 00000000..2af3ef9b
--- /dev/null
+++ b/SOL003/VNFPerformanceManagementNotification-API_nxw/schemas/ProblemDetails.schema.json
@@ -0,0 +1 @@
+{  "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",  "type": "object",  "required": [    "status",    "detail"  ],  "properties": {    "type": {      "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",      "type": "string",      "format": "URI"    },    "title": {      "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type.  It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",      "type": "string"    },    "status": {      "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",      "type": "integer"    },    "detail": {      "description": "A human-readable explanation specific to this occurrence of the problem.\n",      "type": "string"    },    "instance": {      "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",      "type": "string",      "format": "URI"    }  }}
\ No newline at end of file
diff --git a/TrackingStatus.txt b/TrackingStatus.txt
index 2b2fca53..27ecb284 100644
--- a/TrackingStatus.txt
+++ b/TrackingStatus.txt
@@ -94,7 +94,7 @@ SOL003
     * Subscriptions ---------------------------------------------> [DONE]
     * IndividualSubscription ------------------------------------> [DONE]
 
-  - VNFPerformanceManagementNotification-API_nxw  -----------> [NOT STARTED]
+  - VNFPerformanceManagementNotification-API_nxw  -----------> [DONE]
 
 SOL005
 
-- 
GitLab