[Ceilometer] Add CeilometerAlarms.create_alarm_and_get_history scenario

Added new scenario for testing Ceilometer alarms

Change-Id: If7a47a52244cf187218d90f8c6cd151d458bfe78
This commit is contained in:
vgusev 2015-02-09 14:19:21 +03:00
parent a360eb0bca
commit 13ad8f6468
4 changed files with 84 additions and 0 deletions

View File

@ -176,6 +176,29 @@
failure_rate:
max: 0
CeilometerAlarms.create_alarm_and_get_history:
-
args:
meter_name: "ram_util"
threshold: 10.0
type: "threshold"
state: "ok"
statistic: "avg"
alarm_actions: ["http://localhost:8776/alarm"]
ok_actions: ["http://localhost:8776/ok"]
insufficient_data_actions: ["http://localhost:8776/notok"]
runner:
type: "constant"
times: 10
concurrency: 5
context:
users:
tenants: 2
users_per_tenant: 2
sla:
failure_rate:
max: 0
CeilometerAlarms.list_alarms:
-
runner:

View File

@ -0,0 +1,27 @@
{
"CeilometerAlarms.create_alarm_and_get_history": [
{
"args": {
"meter_name": "ram_util",
"threshold": 10.0,
"type": "threshold",
"state": "ok",
"statistic": "avg",
"alarm_actions": ["http://localhost:8776/alarm"],
"ok_actions": ["http://localhost:8776/ok"],
"insufficient_data_actions": ["http://localhost:8776/notok"]
},
"runner": {
"type": "constant",
"times": 10,
"concurrency": 5
},
"context": {
"users": {
"tenants": 2,
"users_per_tenant": 2
}
}
}
]
}

View File

@ -0,0 +1,20 @@
---
CeilometerAlarms.create_alarm_and_get_history:
-
args:
meter_name: "ram_util"
threshold: 10.0
type: "threshold"
state: "ok"
statistic: "avg"
alarm_actions: ["http://localhost:8776/alarm"]
ok_actions: ["http://localhost:8776/ok"]
insufficient_data_actions: ["http://localhost:8776/notok"]
runner:
type: "constant"
times: 10
concurrency: 5
context:
users:
tenants: 2
users_per_tenant: 2

View File

@ -207,6 +207,7 @@ class FakeAlarm(FakeResource):
super(FakeAlarm, self).__init__(manager)
self.meter_name = kwargs.get("meter_name")
self.threshold = kwargs.get("threshold")
self.state = kwargs.get("state", "fake-alarm-state")
self.alarm_id = kwargs.get("alarm_id", "fake-alarm-id")
self.optional_args = kwargs.get("optional_args", {})
@ -716,6 +717,19 @@ class FakeAlarmManager(FakeManager):
del self.cache[alarm.id]
self.resources_order.remove(alarm.id)
def get_state(self, alarm_id):
alarm = self.find(alarm_id=alarm_id)
if alarm is not None:
return getattr(alarm, "state", "fake-alarm-state")
def get_history(self, alarm_id):
return ["fake-alarm-history"]
def set_state(self, alarm_id, state):
alarm = self.find(alarm_id=alarm_id)
if alarm is not None:
return setattr(alarm, "state", state)
class FakeSampleManager(FakeManager):