Yurii Prokulevych | af09dd9 | 2016-12-15 16:14:17 +0100 | [diff] [blame] | 1 | # |
| 2 | # Tests for gnocchi-threshold-alarm |
| 3 | # |
| 4 | # user_id : c8ecb587-d38c-426f-a58d-22b8d4a9a1d3 |
| 5 | # project_id : 709f6ed6-bfb3-4649-b303-0019a7f6aef2 |
| 6 | # alarm name : gabbi-gnocchi-threshold-resource-alarm |
| 7 | # resource_id : gabbi-mock-resource |
| 8 | # archive policy : gabbiliveceph |
| 9 | # |
| 10 | |
| 11 | defaults: |
| 12 | request_headers: |
| 13 | x-auth-token: $ENVIRON['ADMIN_TOKEN'] |
| 14 | |
| 15 | tests: |
| 16 | # |
| 17 | # Setup gnocchi archive policy/resource type/resource/metrics |
| 18 | # |
| 19 | |
| 20 | - name: SETUP. create archive policy gabbiliveceph |
| 21 | desc: create archve policy 'gabbiliveceph' for tests |
| 22 | POST: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/archive_policy |
| 23 | status: 201 |
| 24 | request_headers: |
| 25 | content-type: application/json |
| 26 | data: |
| 27 | name: gabbiliveceph |
| 28 | back_window: 0 |
| 29 | definition: |
| 30 | - granularity: 1 second |
| 31 | points: 60 |
| 32 | - granularity: 20 second |
| 33 | timespan: 1 minute |
| 34 | - points: 5 |
| 35 | timespan: 5 minute |
| 36 | aggregation_methods: |
| 37 | - mean |
| 38 | - min |
| 39 | - max |
| 40 | response_json_paths: |
| 41 | $.name: gabbiliveceph |
| 42 | $.back_window: 0 |
| 43 | $.aggregation_methods.`len`: 3 |
| 44 | |
| 45 | - name: create resource type ceph_account |
| 46 | desc: needed to create a resource |
| 47 | POST: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource_type |
| 48 | status: 201 || 409 |
| 49 | request_headers: |
| 50 | content-type: application/json |
| 51 | data: |
| 52 | name: ceph_account |
| 53 | |
| 54 | - name: create resource of ceph_account type |
| 55 | POST: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource/ceph_account |
| 56 | request_headers: |
| 57 | content-type: application/json |
| 58 | data: |
Julien Danjou | 0cf2f9f | 2017-02-01 17:42:05 +0100 | [diff] [blame] | 59 | id: 662e46f3-8c06-430c-8a9c-adcaedd1272c |
Yurii Prokulevych | af09dd9 | 2016-12-15 16:14:17 +0100 | [diff] [blame] | 60 | user_id: 27e342e4-4489-424f-a7e4-ba8ed9ad729c |
| 61 | project_id: d6d32769-c351-4758-b0a2-458fa1a065a3 |
| 62 | metrics: |
| 63 | radosgw.objects: |
| 64 | archive_policy_name: gabbiliveceph |
| 65 | radosgw.objects.size: |
| 66 | archive_policy_name: gabbiliveceph |
| 67 | radosgw.objects.containers: |
| 68 | archive_policy_name: gabbiliveceph |
| 69 | radosgw.api.request: |
| 70 | archive_policy_name: gabbiliveceph |
| 71 | radosgw.containers.objects: |
| 72 | archive_policy_name: gabbiliveceph |
| 73 | radosgw.containers.objects.size: |
| 74 | archive_policy_name: gabbiliveceph |
| 75 | status: 201 |
| 76 | response_json_paths: |
| 77 | $.user_id: 27e342e4-4489-424f-a7e4-ba8ed9ad729c |
| 78 | $.project_id: d6d32769-c351-4758-b0a2-458fa1a065a3 |
| 79 | $.metrics.`len`: 6 |
| 80 | |
| 81 | # |
| 82 | # Actual tests |
| 83 | # |
| 84 | |
| 85 | - name: search 'gabbi-gnocchi-threshold-resource-alarm' alarm doesnt exist |
| 86 | desc: search for alarm using user_id, project_id, alarm_name |
| 87 | GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms |
| 88 | query_parameters: |
| 89 | q.field: |
| 90 | - user_id |
| 91 | - project_id |
| 92 | - name |
| 93 | q.op: |
| 94 | - eq |
| 95 | - eq |
| 96 | - eq |
| 97 | q.value: |
| 98 | - c8ecb587-d38c-426f-a58d-22b8d4a9a1d3 |
| 99 | - 709f6ed6-bfb3-4649-b303-0019a7f6aef2 |
| 100 | - gabbi-gnocchi-threshold-resource-alarm |
| 101 | method: GET |
| 102 | response_json_paths: |
| 103 | $.`len`: 0 |
| 104 | |
Yurii Prokulevych | af09dd9 | 2016-12-15 16:14:17 +0100 | [diff] [blame] | 105 | - name: create alarm 'gabbi-gnocchi-threshold-resource-alarm' |
| 106 | desc: create a threshold alarm gabbi-gnocchi-threshold-resource-alarm |
| 107 | POST: $ENVIRON['AODH_SERVICE_URL']/v2/alarms |
| 108 | request_headers: |
| 109 | content-type: application/json |
| 110 | data: |
| 111 | alarm_actions: |
| 112 | - "http://site:8000/gnocchi-threshold-resource" |
| 113 | alarm_id: null |
| 114 | description: An gabbilive threshold based alarm |
| 115 | enabled: true |
| 116 | insufficient_data_actions: |
| 117 | - "http://site:8000/nodata-gnocchi-threshold-resource" |
| 118 | name: "gabbi-gnocchi-threshold-resource-alarm" |
| 119 | ok_actions: |
| 120 | - "http://site:8000/ok-gnocchi-threshold-resource" |
| 121 | project_id: 709f6ed6-bfb3-4649-b303-0019a7f6aef2 |
| 122 | repeat_actions: false |
| 123 | severity: moderate |
| 124 | state: "insufficient data" |
| 125 | type: gnocchi_resources_threshold |
| 126 | gnocchi_resources_threshold_rule: |
| 127 | evaluation_periods: 3 |
| 128 | metric: "radosgw.objects.size" |
Julien Danjou | 0cf2f9f | 2017-02-01 17:42:05 +0100 | [diff] [blame] | 129 | resource_id: "662e46f3-8c06-430c-8a9c-adcaedd1272c" |
Yurii Prokulevych | af09dd9 | 2016-12-15 16:14:17 +0100 | [diff] [blame] | 130 | aggregation_method: "mean" |
| 131 | granularity: 60 |
| 132 | threshold: 5.0 |
| 133 | comparison_operator: "ge" |
| 134 | resource_type: ceph_account |
| 135 | user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3 |
| 136 | status: 201 |
| 137 | response_json_paths: |
| 138 | $.name: gabbi-gnocchi-threshold-resource-alarm |
| 139 | $.type: gnocchi_resources_threshold |
| 140 | $.user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3 |
| 141 | $.project_id: 709f6ed6-bfb3-4649-b303-0019a7f6aef2 |
| 142 | $.severity: moderate |
| 143 | |
| 144 | - name: retrieve history about 'gabbi-gnocchi-threshold-resource-alarm' creation |
| 145 | desc: get history about alarm creation |
| 146 | GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.alarm_id']/history |
| 147 | request_headers: |
| 148 | content-type: application/json |
| 149 | poll: |
| 150 | count: 5 |
| 151 | delay: 2 |
| 152 | response_json_paths: |
| 153 | $.`len`: 1 |
| 154 | $.[0].type: creation |
| 155 | $.[0].alarm_id: $RESPONSE['$.alarm_id'] |
| 156 | |
| 157 | - name: update severity for alarm 'gabbi-gnocchi-threshold-resource-alarm' |
| 158 | desc: update severity for alarm gabbi-gnocchi-threshold-resource-alarm |
| 159 | PUT: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.[0].alarm_id'] |
| 160 | status: 200 |
| 161 | request_headers: |
| 162 | content-type: application/json |
| 163 | data: |
| 164 | alarm_actions: |
| 165 | - "http://site:8000/gnocchi-threshold-resource" |
| 166 | alarm_id: null |
| 167 | description: An gabbilive threshold based alarm |
| 168 | enabled: true |
| 169 | insufficient_data_actions: |
| 170 | - "http://site:8000/nodata-gnocchi-threshold-resource" |
| 171 | name: "gabbi-gnocchi-threshold-resource-alarm" |
| 172 | ok_actions: |
| 173 | - "http://site:8000/ok-gnocchi-threshold-resource" |
| 174 | project_id: 709f6ed6-bfb3-4649-b303-0019a7f6aef2 |
| 175 | repeat_actions: false |
| 176 | severity: low |
| 177 | state: "insufficient data" |
| 178 | type: gnocchi_resources_threshold |
| 179 | gnocchi_resources_threshold_rule: |
| 180 | evaluation_periods: 3 |
| 181 | metric: "radosgw.objects.size" |
Julien Danjou | 0cf2f9f | 2017-02-01 17:42:05 +0100 | [diff] [blame] | 182 | resource_id: "662e46f3-8c06-430c-8a9c-adcaedd1272c" |
Yurii Prokulevych | af09dd9 | 2016-12-15 16:14:17 +0100 | [diff] [blame] | 183 | aggregation_method: "mean" |
| 184 | granularity: 60 |
| 185 | threshold: 5.0 |
| 186 | comparison_operator: "ge" |
| 187 | resource_type: ceph_account |
| 188 | user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3 |
| 189 | response_json_paths: |
| 190 | $.name: gabbi-gnocchi-threshold-resource-alarm |
| 191 | $.type: gnocchi_resources_threshold |
| 192 | $.user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3 |
| 193 | $.project_id: 709f6ed6-bfb3-4649-b303-0019a7f6aef2 |
| 194 | $.severity: low |
| 195 | $.state: "insufficient data" |
| 196 | |
| 197 | - name: retrieve history for 'gabbi-gnocchi-threshold-resource-alarm' |
| 198 | desc: get history for rule_change |
| 199 | GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.alarm_id']/history |
| 200 | request_headers: |
| 201 | content-type: application/json |
| 202 | poll: |
| 203 | count: 5 |
| 204 | delay: 2 |
| 205 | response_json_paths: |
| 206 | $.`len`: 2 |
| 207 | $.[0].type: rule change |
| 208 | $.[0].alarm_id: $RESPONSE['$.alarm_id'] |
| 209 | $.[0].detail: '{"severity": "low"}' |
| 210 | |
| 211 | - name: update alarm state for 'gabbi-gnocchi-threshold-resource-alarm' |
| 212 | desc: update state for alarm |
| 213 | PUT: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.[0].alarm_id']/state |
| 214 | request_headers: |
| 215 | content-type: application/json |
| 216 | data: '"ok"' |
| 217 | status: 200 |
| 218 | response_strings: |
| 219 | "ok" |
| 220 | |
| 221 | - name: search 'gabbi-gnocchi-threshold-resource-alarm' alarm exist |
| 222 | desc: search for alarm using user_id, project_id, alarm_name |
| 223 | GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms |
| 224 | query_parameters: |
| 225 | q.field: |
| 226 | - user_id |
| 227 | - project_id |
| 228 | - name |
| 229 | q.op: |
| 230 | - eq |
| 231 | - eq |
| 232 | - eq |
| 233 | q.value: |
| 234 | - c8ecb587-d38c-426f-a58d-22b8d4a9a1d3 |
| 235 | - 709f6ed6-bfb3-4649-b303-0019a7f6aef2 |
| 236 | - gabbi-gnocchi-threshold-resource-alarm |
| 237 | poll: |
| 238 | count: 5 |
| 239 | delay: 2 |
| 240 | response_json_paths: |
| 241 | $.`len`: 1 |
| 242 | |
| 243 | - name: get info about 'gabbi-gnocchi-threshold-resource-alarm' alarm |
| 244 | desc: access alarm using its ID |
| 245 | GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.[0].alarm_id'] |
| 246 | response_json_paths: |
| 247 | $.alarm_id: $RESPONSE['$.[0].alarm_id'] |
| 248 | $.alarm_actions: ["http://site:8000/gnocchi-threshold-resource"] |
| 249 | $.name: gabbi-gnocchi-threshold-resource-alarm |
Julien Danjou | 0cf2f9f | 2017-02-01 17:42:05 +0100 | [diff] [blame] | 250 | $.gnocchi_resources_threshold_rule.resource_id: "662e46f3-8c06-430c-8a9c-adcaedd1272c" |
Yurii Prokulevych | af09dd9 | 2016-12-15 16:14:17 +0100 | [diff] [blame] | 251 | $.gnocchi_resources_threshold_rule.metric: "radosgw.objects.size" |
| 252 | $.gnocchi_resources_threshold_rule.resource_type: "ceph_account" |
| 253 | $.user_id: c8ecb587-d38c-426f-a58d-22b8d4a9a1d3 |
| 254 | |
| 255 | - name: get alarm state for 'gabbi-gnocchi-threshold-resource-alarm' |
| 256 | desc: get state for alarm |
| 257 | GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.alarm_id']/state |
| 258 | request_headers: |
| 259 | content-type: application/json |
| 260 | status: 200 |
| 261 | response_strings: |
| 262 | - "ok" |
| 263 | |
| 264 | # |
| 265 | # Teardown |
| 266 | # |
| 267 | |
| 268 | - name: CLEANUP. search 'gabbi-gnocchi-threshold-resource' alarm exist |
| 269 | desc: Find alarm id using user_id, project_id, alarm_name |
| 270 | GET: $ENVIRON['AODH_SERVICE_URL']/v2/alarms |
| 271 | query_parameters: |
| 272 | q.field: |
| 273 | - user_id |
| 274 | - project_id |
| 275 | - name |
| 276 | q.op: |
| 277 | - eq |
| 278 | - eq |
| 279 | - eq |
| 280 | q.value: |
| 281 | - c8ecb587-d38c-426f-a58d-22b8d4a9a1d3 |
| 282 | - 709f6ed6-bfb3-4649-b303-0019a7f6aef2 |
| 283 | - gabbi-gnocchi-threshold-resource-alarm |
| 284 | response_json_paths: |
| 285 | $.`len`: 1 |
| 286 | |
| 287 | - name: CLEANUP. delete threshold alarm 'gabbi-gnocchi-threshold-resource' |
| 288 | DELETE: $ENVIRON['AODH_SERVICE_URL']/v2/alarms/$RESPONSE['$.[0].alarm_id'] |
| 289 | status: 204 |
| 290 | |
Julien Danjou | 0cf2f9f | 2017-02-01 17:42:05 +0100 | [diff] [blame] | 291 | - name: CLEANUP. Get resource by name '662e46f3-8c06-430c-8a9c-adcaedd1272c' |
| 292 | desc: retrieve resource by 662e46f3-8c06-430c-8a9c-adcaedd1272c to get its ID |
| 293 | GET: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource/generic/662e46f3-8c06-430c-8a9c-adcaedd1272c |
Yurii Prokulevych | af09dd9 | 2016-12-15 16:14:17 +0100 | [diff] [blame] | 294 | status: 200 |
| 295 | |
Julien Danjou | 0cf2f9f | 2017-02-01 17:42:05 +0100 | [diff] [blame] | 296 | - name: CLEANUP. delete test ceph_resource '662e46f3-8c06-430c-8a9c-adcaedd1272c' |
| 297 | desc: delete ceph_account resource 662e46f3-8c06-430c-8a9c-adcaedd1272c |
Yurii Prokulevych | af09dd9 | 2016-12-15 16:14:17 +0100 | [diff] [blame] | 298 | DELETE: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource/generic/$RESPONSE['$.id'] |
| 299 | status: 204 |
| 300 | |
| 301 | - name: CLEANUP. delete resource type ceph_account |
| 302 | DELETE: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource_type/ceph_account |
| 303 | status: 204 |
| 304 | |
| 305 | - name: CLEANUP. delete archive |
| 306 | DELETE: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/archive_policy/gabbiliveceph |
| 307 | status: 204 |
| 308 | xfail: True |
| 309 | |