From 75e35f140a061af838c651486c75bdee7da1dc4a Mon Sep 17 00:00:00 2001
From: Nikolay Stanchev <ns17@it-innovation.soton.ac.uk>
Date: Tue, 21 Aug 2018 09:45:22 +0100
Subject: [PATCH] Updates CLMC TOSCA validator test data

---
 .../invalid/alerts_test_config-1.yaml         | 20 ++++++++++
 .../invalid/alerts_test_config-10.yaml        | 20 ++++++++++
 .../invalid/alerts_test_config-2.yaml         | 19 ++++------
 .../invalid/alerts_test_config-7.yaml         | 15 ++++++++
 .../invalid/alerts_test_config-8.yaml         | 37 +++++++++++++++++++
 .../valid/alerts_test_config-2.yaml           | 20 ++++++++++
 .../valid/alerts_test_config-3.yaml           |  4 +-
 .../valid/alerts_test_config-4.yaml           | 18 +++++++++
 .../valid/alerts_test_config-5.yaml           | 21 +++++++++++
 9 files changed, 161 insertions(+), 13 deletions(-)

diff --git a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-1.yaml b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-1.yaml
index b24fd3a..4848c18 100644
--- a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-1.yaml
+++ b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-1.yaml
@@ -30,6 +30,26 @@ topology_template:
               implementation:
                 - http://sfemc.flame.eu/notify
                 - http://companyA.alert-handler.flame.eu/high-latency
+    - requests_diff_policy:
+        type: eu.ict-flame.policies.StateChange
+        triggers:
+          increase_in_requests:
+            description: |
+              This event triggers when the number of requests has increased relative to the number of requests received
+              120 seconds ago.
+            event_type: relative
+            metric: storage.requests
+            condition:
+              threshold: 100
+              granularity: 120
+              resource_type:
+                sf_package: storage
+                sf: storage-users
+                location: watershed
+              comparison_operator: gte
+            action:
+              implementation:
+              - http://sfemc.flame.eu/notify
     - low_requests_policy:
         type: eu.ict-flame.policies.StateChange
         triggers:
diff --git a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-10.yaml b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-10.yaml
index ec5de6e..491d1e7 100644
--- a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-10.yaml
+++ b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-10.yaml
@@ -30,6 +30,26 @@ topology_template:
               implementation:
                 - http://sfemc.flame.eu/notify
                 - http://companyA.alert-handler.flame.eu/high-latency
+    - requests_diff_policy:
+        type: eu.ict-flame.policies.StateChange
+        triggers:
+          decrease_in_requests:
+            description: |
+              This event triggers when the number of requests has decreased relative to the number of requests received
+              120 seconds ago.
+            event_type: relative
+            metric: storage.requests
+            condition:
+              threshold: -100  # requests have decreased by at least 100
+              granularity: 120
+              resource_type:
+                sf_package: storage
+                sf: storage-users
+                location: watershed
+              comparison_operator: lte
+            action:
+              implementation:
+              - http://sfemc.flame.eu/notify
     - low_requests_policy:
         type: eu.ict-flame.policies.StateChange
         triggers:
diff --git a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-2.yaml b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-2.yaml
index 3ff9985..afa4d86 100644
--- a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-2.yaml
+++ b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-2.yaml
@@ -12,24 +12,21 @@ metadata:
 topology_template:
 
   policies:
-    - high_latency_policy:
+    - missing_measurement_policy:
         type: eu.ict-flame.policies.StateChange
         triggers:
-          high_latency:
-            description: This event triggers when the mean network latency in a given location exceeds a given threshold (in ms).
-            event_type: threshold
-            metric: network.latency
+          missing_storage_measurements:
+            description: This event triggers when the number of storage measurements reported falls below the threshold value.
+            event_type: deadman
+            metric: storage.*
             condition:
-              threshold: 45
-              granularity: 120
-              aggregation_method: mean
+              threshold: 0
+              granularity: 60
               resource_type:
-                location: watershed
-              comparison_operator: gt
+                sf_package: storage
             action:
               implementation:
                 - http://sfemc.flame.eu/notify
-                - http://companyA.alert-handler.flame.eu/high-latency
     - low_requests_policy:
         type: eu.ict-flame.policies.StateChange
         triggers:
diff --git a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-7.yaml b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-7.yaml
index 10e47bc..2285e66 100644
--- a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-7.yaml
+++ b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-7.yaml
@@ -52,3 +52,18 @@ topology_template:
               implementation:
                 - http://sfemc.flame.eu/notify
                 - http://companyA.alert-handler.flame.eu/low-requests
+    - missing_measurement_policy:
+        type: eu.ict-flame.policies.StateChange
+        triggers:
+          missing_storage_measurements:
+            description: This event triggers when the number of storage measurements reported falls below the threshold value.
+            event_type: deadman
+            metric: storage.*
+            condition:
+              threshold: 0
+              granularity: 60
+              resource_type:
+                sf_package: storage
+            action:
+              implementation:
+              - http://sfemc.flame.eu/notify
\ No newline at end of file
diff --git a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-8.yaml b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-8.yaml
index 92ca88d..bd960b5 100644
--- a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-8.yaml
+++ b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-8.yaml
@@ -38,3 +38,40 @@ topology_template:
               implementation:
                 - http://sfemc.flame.eu/notify
                 - http://companyA.alert-handler.flame.eu/low-requests
+    - requests_diff_policy:
+        type: eu.ict-flame.policies.StateChange
+        triggers:
+          increase_in_requests:
+            description: |
+              This event triggers when the number of requests has increased relative to the number of requests received
+              120 seconds ago.
+            event_type: relative
+            metric: storage.requests
+            condition:
+              threshold: 100  # requests have increased by at least 100
+              granularity: 120
+              resource_type:
+                sf_package: storage
+                sf: storage-users
+                location: watershed
+              comparison_operator: gte
+            action:
+              implementation:
+              - http://sfemc.flame.eu/notify
+          decrease_in_requests:
+            description: |
+              This event triggers when the number of requests has decreased relative to the number of requests received
+              120 seconds ago.
+            event_type: relative
+            metric: storage.requests
+            condition:
+              threshold: -100  # requests have decreased by at least 100
+              granularity: 120
+              resource_type:
+                sf_package: storage
+                sf: storage-users
+                location: watershed
+              comparison_operator: lte
+            action:
+              implementation:
+              - http://sfemc.flame.eu/notify
\ No newline at end of file
diff --git a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-2.yaml b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-2.yaml
index ebf78f0..a44743a 100644
--- a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-2.yaml
+++ b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-2.yaml
@@ -54,3 +54,23 @@ topology_template:
               implementation:
                 - http://sfemc.flame.eu/notify
                 - http://companyA.alert-handler.flame.eu/low-requests
+    - requests_diff_policy:
+        type: eu.ict-flame.policies.StateChange
+        triggers:
+          decrease_in_requests:
+            description: |
+              This event triggers when the number of requests has decreased relative to the number of requests received
+              120 seconds ago.
+            event_type: relative
+            metric: storage.requests
+            condition:
+              threshold: -100  # requests have decreased by at least 100
+              granularity: 120
+              resource_type:
+                sf_package: storage
+                sf: storage-users
+                location: watershed
+              comparison_operator: lte
+            action:
+              implementation:
+                - http://sfemc.flame.eu/notify
\ No newline at end of file
diff --git a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-3.yaml b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-3.yaml
index ae6471f..529152c 100644
--- a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-3.yaml
+++ b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-3.yaml
@@ -22,10 +22,10 @@ topology_template:
             condition:
               threshold: 45
               granularity: 120
-              aggregation_method: median
+              # aggregation_method is optional, default value is "mean"
               resource_type:
                 location: watershed
-              comparison_operator: gt
+              # comparison operator is optional, default value is >= or "gte"
             action:
               implementation:
                 - http://sfemc.flame.eu/notify
diff --git a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-4.yaml b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-4.yaml
index 5e716e8..8c10604 100644
--- a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-4.yaml
+++ b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-4.yaml
@@ -47,3 +47,21 @@ topology_template:
               implementation:
                 - http://sfemc.flame.eu/notify
                 - http://companyA.alert-handler.flame.eu/low-requests
+    - missing_measurement_policy:
+        type: eu.ict-flame.policies.StateChange
+        triggers:
+          missing_storage_measurements:
+            description: This event triggers when the number of storage measurements reported falls below the threshold value.
+            event_type: deadman
+            # deadman trigger instances monitor the whole measurement (storage in this case), so simply put a star for field value
+            # to be compliant with the <measurement>.<field> format
+            metric: storage.*
+            condition:
+              threshold: 0  # if requests are less than or equal to 0 (in other words, no measurements are reported)
+              granularity: 60  # check for for missing data for the last 60 seconds
+              resource_type:
+                sf_package: storage
+              comparison_operator: gte # although events of type deadman do not use a comparison operator, the validator will not complain if one is given, it will simply ignore it
+            action:
+              implementation:
+              - http://sfemc.flame.eu/notify
diff --git a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-5.yaml b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-5.yaml
index 0566801..54567e1 100644
--- a/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-5.yaml
+++ b/src/service/clmcservice/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-5.yaml
@@ -47,3 +47,24 @@ topology_template:
               implementation:
                 - https://sfemc.flame.eu/notify
                 - http://localhost:9999/low-requests  # localhost url is also allowed
+    - requests_diff_policy:
+        type: eu.ict-flame.policies.StateChange
+        triggers:
+          increase_in_requests:
+            description: |
+              This event triggers when the number of requests has increased relative to the number of requests received
+              120 seconds ago.
+            event_type: relative
+            metric: storage.requests
+            condition:
+              threshold: 100  # requests have increased by at least 100
+              granularity: 120
+              aggregation_method: first  # Although events of type relative do not require an aggregation method, the validator will not complain if one is given, it will simply ignore it
+              resource_type:
+                sf_package: storage
+                sf: storage-users
+                location: watershed
+              comparison_operator: gte
+            action:
+              implementation:
+              - http://sfemc.flame.eu/notify
-- 
GitLab