Merge "[Ceilometer] Add CeilometerAlarms.create_alarm_and_get_history scenario"

This commit is contained in:
Jenkins 2015-03-19 18:04:56 +00:00 committed by Gerrit Code Review
commit a3357f3d51
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

@ -213,6 +213,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", {})
@ -730,6 +731,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):