piyush110786 | 5c57d63 | 2015-09-17 11:47:20 +0530 | [diff] [blame] | 1 | # Copyright 2015 GlobalLogic. All rights reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | from tempest.api.telemetry import base |
| 16 | from tempest.common.utils import data_utils |
| 17 | from tempest import test |
| 18 | from tempest_lib import exceptions as lib_exc |
| 19 | |
| 20 | import uuid |
| 21 | |
| 22 | |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 23 | class TelemetryAlarmingNegativeTest(base.BaseAlarmingTest): |
Ken'ichi Ohmichi | 9e3dac0 | 2015-11-19 07:01:07 +0000 | [diff] [blame] | 24 | """Negative tests for show_alarm, update_alarm, show_alarm_history tests |
| 25 | |
piyush110786 | 5c57d63 | 2015-09-17 11:47:20 +0530 | [diff] [blame] | 26 | ** show non-existent alarm |
| 27 | ** show the deleted alarm |
| 28 | ** delete deleted alarm |
| 29 | ** update deleted alarm |
| 30 | """ |
| 31 | |
| 32 | @test.attr(type=['negative']) |
| 33 | @test.idempotent_id('668743d5-08ad-4480-b2b8-15da34f81e7d') |
| 34 | def test_get_non_existent_alarm(self): |
| 35 | # get the non-existent alarm |
| 36 | non_existent_id = str(uuid.uuid4()) |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 37 | self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm, |
piyush110786 | 5c57d63 | 2015-09-17 11:47:20 +0530 | [diff] [blame] | 38 | non_existent_id) |
| 39 | |
| 40 | @test.attr(type=['negative']) |
| 41 | @test.idempotent_id('ef45000d-0a72-4781-866d-4cb7bf2582ad') |
| 42 | def test_get_update_show_history_delete_deleted_alarm(self): |
| 43 | # get, update and delete the deleted alarm |
| 44 | alarm_name = data_utils.rand_name('telemetry_alarm') |
| 45 | rule = {'meter_name': 'cpu', |
| 46 | 'comparison_operator': 'eq', |
| 47 | 'threshold': 100.0, |
| 48 | 'period': 90} |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 49 | body = self.alarming_client.create_alarm( |
piyush110786 | 5c57d63 | 2015-09-17 11:47:20 +0530 | [diff] [blame] | 50 | name=alarm_name, |
| 51 | type='threshold', |
| 52 | threshold_rule=rule) |
| 53 | alarm_id = body['alarm_id'] |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 54 | self.alarming_client.delete_alarm(alarm_id) |
piyush110786 | 5c57d63 | 2015-09-17 11:47:20 +0530 | [diff] [blame] | 55 | # get the deleted alarm |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 56 | self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm, |
piyush110786 | 5c57d63 | 2015-09-17 11:47:20 +0530 | [diff] [blame] | 57 | alarm_id) |
| 58 | |
| 59 | # update the deleted alarm |
| 60 | updated_alarm_name = data_utils.rand_name('telemetry_alarm_updated') |
| 61 | updated_rule = {'meter_name': 'cpu_new', |
| 62 | 'comparison_operator': 'eq', |
| 63 | 'threshold': 70, |
| 64 | 'period': 50} |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 65 | self.assertRaises(lib_exc.NotFound, self.alarming_client.update_alarm, |
piyush110786 | 5c57d63 | 2015-09-17 11:47:20 +0530 | [diff] [blame] | 66 | alarm_id, threshold_rule=updated_rule, |
| 67 | name=updated_alarm_name, |
| 68 | type='threshold') |
| 69 | # delete the deleted alarm |
liu-sheng | 67b730e | 2015-07-16 15:19:33 +0800 | [diff] [blame] | 70 | self.assertRaises(lib_exc.NotFound, self.alarming_client.delete_alarm, |
piyush110786 | 5c57d63 | 2015-09-17 11:47:20 +0530 | [diff] [blame] | 71 | alarm_id) |