Fixed the rest of the tests
This commit is contained in:
parent
5c8158ed2a
commit
9d94fff545
@ -49,7 +49,7 @@ public class AlarmDAOImpl implements AlarmDAO {
|
||||
String subAlarmId = (String) row.get("id");
|
||||
Map<String, String> dimensions = findDimensionsById(handle, subAlarmId);
|
||||
AggregateFunction function = AggregateFunction.valueOf((String) row.get("function"));
|
||||
MetricDefinition metricDef = new MetricDefinition((String) row.get("namespace"), dimensions);
|
||||
MetricDefinition metricDef = new MetricDefinition((String) row.get("metric_name"), dimensions);
|
||||
AlarmOperator operator = AlarmOperator.valueOf((String) row.get("operator"));
|
||||
AlarmSubExpression subExpression = new AlarmSubExpression(function, metricDef, operator,
|
||||
(Double) row.get("threshold"), (Integer) row.get("period"), (Integer) row.get("periods"));
|
||||
|
@ -111,10 +111,10 @@ public class AlarmTest {
|
||||
|
||||
assertEquals(
|
||||
Alarm.buildStateChangeReason(AlarmState.UNDETERMINED, expressions),
|
||||
"No data was present for the sub-alarms: [avg(hpcs.compute{device=1, metric_name=cpu, instance_id=5}, 1) > 5.0 times 3, avg(hpcs.compute{flavor_id=3, metric_name=mem}, 2) < 4.0 times 3]");
|
||||
"No data was present for the sub-alarms: [avg(hpcs.compute{device=1, instance_id=5, metric_name=cpu}, 1) > 5.0 times 3, avg(hpcs.compute{flavor_id=3, metric_name=mem}, 2) < 4.0 times 3]");
|
||||
|
||||
assertEquals(
|
||||
Alarm.buildStateChangeReason(AlarmState.ALARM, expressions),
|
||||
"Thresholds were exceeded for the sub-alarms: [avg(hpcs.compute{device=1, metric_name=cpu, instance_id=5}, 1) > 5.0 times 3, avg(hpcs.compute{flavor_id=3, metric_name=mem}, 2) < 4.0 times 3]");
|
||||
"Thresholds were exceeded for the sub-alarms: [avg(hpcs.compute{device=1, instance_id=5, metric_name=cpu}, 1) > 5.0 times 3, avg(hpcs.compute{flavor_id=3, metric_name=mem}, 2) < 4.0 times 3]");
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class AlarmDAOImplTest {
|
||||
|
||||
handle.execute("insert into alarm (id, tenant_id, name, expression, state, created_at, updated_at) "
|
||||
+ "values ('123', 'bob', '90% CPU', 'avg(hpcs.compute{disk=vda, instance_id=123, metric_name=cpu}) > 10', 'UNDETERMINED', NOW(), NOW())");
|
||||
handle.execute("insert into sub_alarm (id, alarm_id, function, namespace, operator, threshold, period, periods, created_at, updated_at) "
|
||||
handle.execute("insert into sub_alarm (id, alarm_id, function, metric_name, operator, threshold, period, periods, created_at, updated_at) "
|
||||
+ "values ('111', '123', 'AVG', 'hpcs.compute', 'GT', 10, 60, 1, NOW(), NOW())");
|
||||
handle.execute("insert into sub_alarm_dimension values ('111', 'instance_id', '123')");
|
||||
handle.execute("insert into sub_alarm_dimension values ('111', 'disk', 'vda')");
|
||||
|
Loading…
x
Reference in New Issue
Block a user