Add measurement valueMeta

Changes tests to use the new Metric constructor with valueMeta

Requires the changes to monasca-common from

Implements: blueprint measurement-meta-data

Change-Id: Ibba190c14fb1cb9d5ab2a7b0e4da9bfcfba9874d
This commit is contained in:
Craig Bryant 2015-03-02 19:02:35 -07:00
parent f85e95bced
commit 2b62c0477b
5 changed files with 42 additions and 26 deletions

View File

@ -1,3 +1,19 @@
/*
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package monasca.thresh.domain.model;
import java.io.Serializable;

View File

@ -362,7 +362,7 @@ public class ThresholdingEngineAlarmTest extends TopologyTestCase {
for (final MetricDefinitionAndTenantId metricDefinitionAndTenantId : mtids) {
metricSpout.feed(new Values(new TenantIdAndMetricName(metricDefinitionAndTenantId), time,
new Metric(metricDefinitionAndTenantId.metricDefinition, time,
(double) 555)));
(double) 555, null)));
}
try {
Thread.sleep(500);

View File

@ -260,11 +260,11 @@ public class ThresholdingEngineTest extends TopologyTestCase {
final MetricDefinitionAndTenantId cpuMtid = new MetricDefinitionAndTenantId(cpuMetricDef,
TEST_ALARM_TENANT_ID);
metricSpout.feed(new Values(new TenantIdAndMetricName(cpuMtid), time, new Metric(cpuMetricDef.name, cpuMetricDef.dimensions,
time, (double) (++goodValueCount == 15 ? 1 : 555))));
time, (double) (++goodValueCount == 15 ? 1 : 555), null)));
final MetricDefinitionAndTenantId memMtid = new MetricDefinitionAndTenantId(memMetricDef,
TEST_ALARM_TENANT_ID);
metricSpout.feed(new Values(new TenantIdAndMetricName(memMtid), time, new Metric(memMetricDef.name, extraMemMetricDefDimensions,
time, (double) (goodValueCount == 15 ? 1 : 555))));
time, (double) (goodValueCount == 15 ? 1 : 555), null)));
if (--feedCount == 0) {
waitCount = 3;

View File

@ -115,13 +115,13 @@ public class MetricAggregationBoltTest {
long t1 = System.currentTimeMillis() / 1000;
bolt.aggregateValues(new MetricDefinitionAndTenantId(metricDef1, TENANT_ID), new Metric(
metricDef1.name, metricDef1.dimensions, t1, 100));
metricDef1.name, metricDef1.dimensions, t1, 100, null));
bolt.aggregateValues(new MetricDefinitionAndTenantId(metricDef1, TENANT_ID), new Metric(
metricDef1.name, metricDef1.dimensions, t1, 80));
metricDef1.name, metricDef1.dimensions, t1, 80, null));
bolt.aggregateValues(new MetricDefinitionAndTenantId(metricDef2, TENANT_ID), new Metric(
metricDef2.name, metricDef2.dimensions, t1, 50));
metricDef2.name, metricDef2.dimensions, t1, 50, null));
bolt.aggregateValues(new MetricDefinitionAndTenantId(metricDef2, TENANT_ID), new Metric(
metricDef2.name, metricDef2.dimensions, t1, 40));
metricDef2.name, metricDef2.dimensions, t1, 40, null));
SubAlarmStatsRepository orCreateSubAlarmStatsRepo = bolt.getOrCreateSubAlarmStatsRepo(new MetricDefinitionAndTenantId(metricDef1, TENANT_ID));
SubAlarmStats alarmData =
@ -146,9 +146,9 @@ public class MetricAggregationBoltTest {
sendSubAlarmCreated(metricDef3, subAlarm3);
// Send metrics for subAlarm1
bolt.execute(createMetricTuple(metricDef1, new Metric(metricDef1, t1, 100)));
bolt.execute(createMetricTuple(metricDef1, new Metric(metricDef1, t1 - 60, 95)));
bolt.execute(createMetricTuple(metricDef1, new Metric(metricDef1, t1 - 120, 88)));
bolt.execute(createMetricTuple(metricDef1, new Metric(metricDef1, t1, 100, null)));
bolt.execute(createMetricTuple(metricDef1, new Metric(metricDef1, t1 - 60, 95, null)));
bolt.execute(createMetricTuple(metricDef1, new Metric(metricDef1, t1 - 120, 88, null)));
t1 += 20;
bolt.setCurrentTime(t1);
@ -166,10 +166,10 @@ public class MetricAggregationBoltTest {
reset(collector);
// Drive subAlarm1 to ALARM
bolt.execute(createMetricTuple(metricDef1, new Metric(metricDef1, t1, 99)));
bolt.execute(createMetricTuple(metricDef1, new Metric(metricDef1, t1, 99, null)));
// Drive subAlarm2 to ALARM and subAlarm3 to OK since they use the same MetricDefinition
t1 += 10;
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1, 94)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1, 94, null)));
t1 += 50;
bolt.setCurrentTime(t1);
bolt.execute(tickTuple);
@ -189,9 +189,9 @@ public class MetricAggregationBoltTest {
bolt.setCurrentTime(t1);
sendSubAlarmCreated(metricDef2, subAlarm2);
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1, 100)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1++, 95)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1++, 88)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1, 100, null)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1++, 95, null)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1++, 88, null)));
t1 += 60;
bolt.setCurrentTime(t1);
@ -203,9 +203,9 @@ public class MetricAggregationBoltTest {
sendSubAlarmResend(metricDef2, subAlarm2);
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1, 100)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1++, 95)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1++, 88)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1, 100, null)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1++, 95, null)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1++, 88, null)));
t1 += 60;
bolt.setCurrentTime(t1);
@ -248,9 +248,9 @@ public class MetricAggregationBoltTest {
long t1 = 50;
bolt.setCurrentTime(t1);
sendSubAlarmCreated(metricDef2, subAlarm2);
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1, 1.0)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1, 1.0, null)));
t1 += 1;
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1, 1.0)));
bolt.execute(createMetricTuple(metricDef2, new Metric(metricDef2, t1, 1.0, null)));
bolt.setCurrentTime(t1 += 60);
final Tuple tickTuple = createTickTuple();

View File

@ -143,13 +143,13 @@ public class MetricFilteringBoltTest {
final long oldestTimestamp = prepareTime - MetricFilteringBolt.LAG_MESSAGE_PERIOD_DEFAULT;
final Tuple lateMetricTuple =
createMetricTuple(metricDefinition, oldestTimestamp, new Metric(metricDefinition,
oldestTimestamp, 42.0));
oldestTimestamp, 42.0, null));
bolt.execute(lateMetricTuple);
verify(collector, times(1)).ack(lateMetricTuple);
bolt.setCurrentTime(prepareTime + MetricFilteringBolt.LAG_MESSAGE_PERIOD_DEFAULT);
final Tuple lateMetricTuple2 =
createMetricTuple(metricDefinition, prepareTime, new Metric(metricDefinition, prepareTime,
42.0));
42.0, null));
bolt.execute(lateMetricTuple2);
verify(collector, times(1)).ack(lateMetricTuple2);
verify(collector, times(1)).emit(MetricAggregationBolt.METRIC_AGGREGATION_CONTROL_STREAM,
@ -158,7 +158,7 @@ public class MetricFilteringBoltTest {
long caughtUpTimestamp = bolt.getCurrentTime() - MetricFilteringBolt.MIN_LAG_VALUE_DEFAULT;
final Tuple metricTuple =
createMetricTuple(metricDefinition, caughtUpTimestamp, new Metric(metricDefinition,
caughtUpTimestamp, 42.0));
caughtUpTimestamp, 42.0, null));
bolt.execute(metricTuple);
// Metrics are caught up so there should not be another METRICS_BEHIND message
verify(collector, times(1)).ack(metricTuple);
@ -184,7 +184,7 @@ public class MetricFilteringBoltTest {
for (int i = 0; i < MetricFilteringBolt.MAX_LAG_MESSAGES_DEFAULT + 1; i++) {
final Tuple lateMetricTuple =
createMetricTuple(metricDefinition, prepareTime, new Metric(metricDefinition,
prepareTime, 42.0));
prepareTime, 42.0, null));
bolt.setCurrentTime(prepareTime + MetricFilteringBolt.LAG_MESSAGE_PERIOD_DEFAULT);
bolt.execute(lateMetricTuple);
verify(collector, times(1)).ack(lateMetricTuple);
@ -199,7 +199,7 @@ public class MetricFilteringBoltTest {
long timestamp = bolt.getCurrentTime() - MetricFilteringBolt.LAG_MESSAGE_PERIOD_DEFAULT;
final Tuple metricTuple =
createMetricTuple(metricDefinition, timestamp,
new Metric(metricDefinition, timestamp, 42.0));
new Metric(metricDefinition, timestamp, 42.0, null));
bolt.execute(metricTuple);
verify(collector, times(1)).ack(metricTuple);
// Won't be any more of these
@ -279,7 +279,7 @@ public class MetricFilteringBoltTest {
for (MetricDefinitionAndTenantId mtid : alarm.getAlarmedMetrics()) {
final Tuple exactTuple =
createMetricTuple(mtid.metricDefinition, metricTimestamp++, new Metric(
mtid.metricDefinition, metricTimestamp, 42.0));
mtid.metricDefinition, metricTimestamp, 42.0, null));
bolt1.execute(exactTuple);
verify(collector1, times(1)).ack(exactTuple);
verify(collector1, howMany)