Skip to content

Commit

Permalink
Fix a few more broken integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Negrea committed Mar 12, 2015
1 parent 1af0fbd commit 015243c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,10 @@ public BucketedOutput doApply(NumericMetric metric) {
// Currently, if a bucket does not contain any data, we set max/min/avg to Double.NaN.
// DoubleSummaryStatistics however uses Double.Infinity for max/min and 0.0 for avg.
if (e.getValue().getCount() > 0) {
return new BucketDataPoint(metric.getId().getName(), e.getKey(), e.getValue()
return new BucketDataPoint(e.getKey(), e.getValue()
.getMin(), e.getValue().getAverage(), e.getValue().getMax());
}
return new BucketDataPoint(metric.getId().getName(), e.getKey(), Double.NaN,
Double.NaN, Double.NaN);
return new BucketDataPoint(e.getKey(), Double.NaN, Double.NaN, Double.NaN);
})
.collect(toList()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.hawkular.metrics.core.api;

import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.base.Objects;

/**
Expand All @@ -36,6 +37,7 @@ public MetricId(String name, Interval interval) {
this.interval = interval;
}

@JsonValue
public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,20 @@ public class BucketDataPoint {
private double min;
private double max;
private double avg;
private String id;
private long timestamp;
private double value;

public BucketDataPoint() {
}

public BucketDataPoint(String id, long timestamp, double min, double avg, double max) {
public BucketDataPoint(long timestamp, double min, double avg, double max) {
super();
this.setId(id);
this.setTimestamp(timestamp);
this.min = min;
this.max = max;
this.avg = avg;
}

@ApiModelProperty(value = "Id of the metric")
public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

@ApiModelProperty(value = "Time when the value was obtained in milliseconds since epoch")
public long getTimestamp() {
return timestamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,23 @@
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* @author John Sanda
*/
// TODO: Remove or move this class to a better package
public class BucketedOutput {

private String tenantId;

private String name;

@JsonInclude(Include.NON_EMPTY)
private String id;
private Map<String, String> metadata = new HashMap<>();

@JsonInclude(Include.NON_EMPTY)
private List<BucketDataPoint> data = new ArrayList<>();

public BucketedOutput() {
}

public BucketedOutput(String tenantId, String name, Map<String, String> metadata) {
public BucketedOutput(String tenantId, String id, Map<String, String> metadata) {
this.tenantId = tenantId;
this.name = name;
this.id = id;
this.metadata = metadata;
}

Expand All @@ -57,12 +49,12 @@ public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}

public String getName() {
return name;
public String getId() {
return id;
}

public void setName(String name) {
this.name = name;
public void setId(String id) {
this.id = id;
}

public Map<String, String> getMetadata() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,40 +128,32 @@ class CassandraBackendITest extends RESTTest {
])
assertEquals(200, response.status)

response = hawkularMetrics.get(path: "${tenantId}/metrics/numeric/$metric/data", query: [start : start.millis, end: end.millis,
buckets: 10, bucketWidthSeconds: 0])
response = hawkularMetrics.get(path: "${tenantId}/metrics/numeric/$metric/data",
query: [start : start.millis, end: end.millis, buckets: 10])
assertEquals(200, response.status)

System.out.println(response.data);

def expectedData = [
tenantId: tenantId,
id: metric,
data: [
[timestamp: buckets[0], empty: false, max: 12.37, min: 12.22, avg: (12.22 + 12.37) /
2, value: 0, id: metric],
[timestamp: buckets
[1], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0, id: metric],
[timestamp: buckets
[2], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0, id: metric],
[timestamp: buckets
[3], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0, id: metric],
[timestamp: buckets[4], empty: false, max: 25.0, min: 25.0, avg: 25.0, value: 0, id: metric],
[timestamp: buckets
[5], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0, id: metric],
[timestamp: buckets
[6], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0, id: metric],
[timestamp: buckets
[7], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0, id: metric],
[timestamp: buckets
[8], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0, id: metric],
[timestamp: buckets[9], empty: false, max: 19.01, min: 18.367, avg: (18.367 + 19.01) /
2, value: 0, id: metric],
[timestamp: buckets[0], empty: false, max: 12.37, min: 12.22, avg: (12.22 + 12.37) /2, value: 0],
[timestamp: buckets[1], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0],
[timestamp: buckets[2], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0],
[timestamp: buckets[3], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0],
[timestamp: buckets[4], empty: false, max: 25.0, min: 25.0, avg: 25.0, value: 0],
[timestamp: buckets[5], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0],
[timestamp: buckets[6], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0],
[timestamp: buckets[7], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0],
[timestamp: buckets[8], empty: true, max: Double.NaN, min: Double.NaN, avg: Double.NaN, value: 0],
[timestamp: buckets[9], empty: false, max: 19.01, min: 18.367, avg: (18.367 + 19.01) / 2, value: 0],
]
]

def assertBucketEquals = { expected, actual ->
assertEquals(expected.timestamp, actual.timestamp)
assertEquals(expected.empty, actual.empty)
assertEquals(expected.id, actual.id)
assertDoubleEquals(expected.max, actual.max)
assertDoubleEquals(expected.min, actual.min)
assertDoubleEquals(expected.avg, actual.avg)
Expand Down

0 comments on commit 015243c

Please sign in to comment.