blob: e9455569d6b17ceafbef4ac274f51848844aeb91 [file] [log] [blame]
piyush1107865c57d632015-09-17 11:47:20 +05301# 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
15from tempest.api.telemetry import base
16from tempest.common.utils import data_utils
17from tempest import test
18from tempest_lib import exceptions as lib_exc
19
20import uuid
21
22
liu-sheng67b730e2015-07-16 15:19:33 +080023class TelemetryAlarmingNegativeTest(base.BaseAlarmingTest):
Ken'ichi Ohmichi9e3dac02015-11-19 07:01:07 +000024 """Negative tests for show_alarm, update_alarm, show_alarm_history tests
25
piyush1107865c57d632015-09-17 11:47:20 +053026 ** 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-sheng67b730e2015-07-16 15:19:33 +080037 self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm,
piyush1107865c57d632015-09-17 11:47:20 +053038 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-sheng67b730e2015-07-16 15:19:33 +080049 body = self.alarming_client.create_alarm(
piyush1107865c57d632015-09-17 11:47:20 +053050 name=alarm_name,
51 type='threshold',
52 threshold_rule=rule)
53 alarm_id = body['alarm_id']
liu-sheng67b730e2015-07-16 15:19:33 +080054 self.alarming_client.delete_alarm(alarm_id)
piyush1107865c57d632015-09-17 11:47:20 +053055 # get the deleted alarm
liu-sheng67b730e2015-07-16 15:19:33 +080056 self.assertRaises(lib_exc.NotFound, self.alarming_client.show_alarm,
piyush1107865c57d632015-09-17 11:47:20 +053057 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-sheng67b730e2015-07-16 15:19:33 +080065 self.assertRaises(lib_exc.NotFound, self.alarming_client.update_alarm,
piyush1107865c57d632015-09-17 11:47:20 +053066 alarm_id, threshold_rule=updated_rule,
67 name=updated_alarm_name,
68 type='threshold')
69 # delete the deleted alarm
liu-sheng67b730e2015-07-16 15:19:33 +080070 self.assertRaises(lib_exc.NotFound, self.alarming_client.delete_alarm,
piyush1107865c57d632015-09-17 11:47:20 +053071 alarm_id)