Skip to content

Commit

Permalink
Fixed tests to work with new Metric/MetricId pair
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Burman committed Jul 27, 2015
1 parent 58c8aa9 commit c27d124
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public void call(Task task) {
metricsService.findCounterData(id, start, end)
.take(1)
.map(dataPoint -> dataPoint.getValue().doubleValue() / (end - start) * 1000)
.map(rate -> new Metric<>(id,
singletonList(new DataPoint<>(start, rate))))
.map(rate -> new Metric<>(id, singletonList(new DataPoint<>(start, rate))))
.flatMap(metric -> metricsService.addGaugeData(Observable.just(metric)))
.subscribe(
aVoid -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,9 @@ public Observable<DataPoint<Long>> findCounterData(MetricId id, long start, long

@Override
public Observable<DataPoint<Double>> findRateData(MetricId id, long start, long end) {
MetricId rateId = new MetricId(id.getTenantId(), COUNTER_RATE, id.getName(), id.getInterval());
return time(gaugeReadLatency, () ->
dataAccess.findData(id, start, end)
dataAccess.findData(rateId, start, end)
.flatMap(Observable::from)
.map(Functions::getGaugeDataPoint));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void insertAndFindGaugeRawData() throws Exception {
DateTime start = now().minusMinutes(10);
DateTime end = start.plusMinutes(6);

Metric<Double> metric = new Metric<>("tenant-1", GAUGE, new MetricId("metric-1"), asList(
Metric<Double> metric = new Metric<>(new MetricId("tenant-1", GAUGE, "metric-1"), asList(
new DataPoint<>(start.getMillis(), 1.23),
new DataPoint<>(start.plusMinutes(1).getMillis(), 1.234),
new DataPoint<>(start.plusMinutes(2).getMillis(), 1.234),
Expand All @@ -127,7 +127,7 @@ public void insertAndFindGaugeRawData() throws Exception {

dataAccess.insertData(metric, DEFAULT_TTL).toBlocking().last();

Observable<ResultSet> observable = dataAccess.findData("tenant-1", new MetricId("metric-1"), GAUGE,
Observable<ResultSet> observable = dataAccess.findData(new MetricId("tenant-1", GAUGE, "metric-1"),
start.getMillis(), end.getMillis());
List<DataPoint<Double>> actual = ImmutableList.copyOf(observable
.flatMap(Observable::from)
Expand All @@ -150,12 +150,12 @@ public void addMetadataToGaugeRawData() throws Exception {
DateTime end = start.plusMinutes(6);
String tenantId = "tenant-1";

Metric<Double> metric = new Metric<>(tenantId, GAUGE, new MetricId("metric-1"),
Metric<Double> metric = new Metric<>(new MetricId(tenantId, GAUGE, "metric-1"),
ImmutableMap.of("units", "KB", "env", "test"), DEFAULT_TTL);

dataAccess.addTagsAndDataRetention(metric).toBlocking().last();

metric = new Metric<>(tenantId, GAUGE, new MetricId("metric-1"), asList(
metric = new Metric<>(new MetricId(tenantId, GAUGE, "metric-1"), asList(
new DataPoint<>(start.getMillis(), 1.23),
new DataPoint<>(start.plusMinutes(2).getMillis(), 1.234),
new DataPoint<>(start.plusMinutes(4).getMillis(), 1.234),
Expand All @@ -164,7 +164,7 @@ public void addMetadataToGaugeRawData() throws Exception {

dataAccess.insertData(metric, DEFAULT_TTL).toBlocking().last();

Observable<ResultSet> observable = dataAccess.findData("tenant-1", new MetricId("metric-1"), GAUGE,
Observable<ResultSet> observable = dataAccess.findData(new MetricId("tenant-1", GAUGE, "metric-1"),
start.getMillis(), end.getMillis());
List<DataPoint<Double>> actual = ImmutableList.copyOf(observable
.flatMap(Observable::from)
Expand All @@ -186,13 +186,13 @@ public void insertAndFindAvailabilities() throws Exception {
DateTime start = now().minusMinutes(10);
DateTime end = start.plusMinutes(6);
String tenantId = "avail-test";
Metric<AvailabilityType> metric = new Metric<>(tenantId, AVAILABILITY, new MetricId("m1"),
Metric<AvailabilityType> metric = new Metric<>(new MetricId(tenantId, AVAILABILITY, "m1"),
singletonList(new DataPoint<>(start.getMillis(), UP)));

dataAccess.insertAvailabilityData(metric, 360).toBlocking().lastOrDefault(null);

List<DataPoint<AvailabilityType>> actual = dataAccess
.findAvailabilityData(tenantId, new MetricId("m1"), start.getMillis(), end.getMillis())
.findAvailabilityData(new MetricId(tenantId, AVAILABILITY, "m1"), start.getMillis(), end.getMillis())
.flatMap(Observable::from)
.map(Functions::getAvailabilityDataPoint)
.toList().toBlocking().lastOrDefault(null);
Expand Down

0 comments on commit c27d124

Please sign in to comment.