use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestAbsolute method evaluatePositiveGroupByDouble.
@Test
public void evaluatePositiveGroupByDouble() throws Exception {
SeekableView view2 = SeekableViewsForTest.generator(START_TIME, INTERVAL, NUM_POINTS, false, 10, 1);
DataPoints dps2 = PowerMockito.mock(DataPoints.class);
when(dps2.iterator()).thenReturn(view2);
when(dps2.metricNameAsync()).thenReturn(Deferred.fromResult("sys.mem"));
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals(METRIC, results[0].metricName());
assertEquals("sys.mem", results[1].metricName());
long ts = START_TIME;
double v = 1;
for (DataPoint dp : results[0]) {
assertEquals(ts, dp.timestamp());
assertTrue(dp.isInteger());
assertEquals((long) v, dp.longValue());
ts += INTERVAL;
v += 1;
}
ts = START_TIME;
v = 10;
for (DataPoint dp : results[1]) {
assertEquals(ts, dp.timestamp());
assertFalse(dp.isInteger());
assertEquals(v, dp.doubleValue(), 0.001);
ts += INTERVAL;
v += 1;
}
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestAlias method evaluateWithTags.
@Test
public void evaluateWithTags() throws Exception {
SeekableView view2 = SeekableViewsForTest.generator(START_TIME, INTERVAL, NUM_POINTS, true, 10, 1);
DataPoints dps2 = PowerMockito.mock(DataPoints.class);
when(dps2.iterator()).thenReturn(view2);
when(dps2.metricName()).thenReturn("sys.mem");
when(dps2.getTagsAsync()).thenReturn(Deferred.fromResult(tags));
when(dps2.getTagUids()).thenReturn(tag_uids);
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
params.add("My Alias.@host.@dc");
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals("My Alias.web01.lga", results[0].metricName());
assertEquals("My Alias.web01.lga", results[1].metricName());
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestAlias method evaluateGroupByDouble.
@Test
public void evaluateGroupByDouble() throws Exception {
SeekableView view2 = SeekableViewsForTest.generator(START_TIME, INTERVAL, NUM_POINTS, false, 10, 1);
DataPoints dps2 = PowerMockito.mock(DataPoints.class);
when(dps2.iterator()).thenReturn(view2);
when(dps2.metricName()).thenReturn("sys.mem");
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
params.add("My Alias");
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals("My Alias", results[0].metricName());
assertEquals("My Alias", results[1].metricName());
long ts = START_TIME;
double v = 1;
for (DataPoint dp : results[0]) {
assertEquals(ts, dp.timestamp());
assertTrue(dp.isInteger());
assertEquals((long) v, dp.longValue());
ts += INTERVAL;
v += 1;
}
ts = START_TIME;
v = 10;
for (DataPoint dp : results[1]) {
assertEquals(ts, dp.timestamp());
assertFalse(dp.isInteger());
assertEquals(v, dp.doubleValue(), 0.001);
ts += INTERVAL;
v += 1;
}
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestAlias method evaluateWithATag.
@Test
public void evaluateWithATag() throws Exception {
SeekableView view2 = SeekableViewsForTest.generator(START_TIME, INTERVAL, NUM_POINTS, true, 10, 1);
DataPoints dps2 = PowerMockito.mock(DataPoints.class);
when(dps2.iterator()).thenReturn(view2);
when(dps2.metricName()).thenReturn("sys.mem");
when(dps2.getTagsAsync()).thenReturn(Deferred.fromResult(tags));
when(dps2.getTagUids()).thenReturn(tag_uids);
group_bys = new DataPoints[] { dps, dps2 };
query_results.clear();
query_results.add(group_bys);
params.add("My Alias.@dc");
final DataPoints[] results = func.evaluate(data_query, query_results, params);
assertEquals(2, results.length);
assertEquals("My Alias.lga", results[0].metricName());
assertEquals("My Alias.lga", results[1].metricName());
}
use of net.opentsdb.core.DataPoints in project opentsdb by OpenTSDB.
the class TestDiffSeries method diffTooManyResultSets.
@Test(expected = IllegalArgumentException.class)
public void diffTooManyResultSets() throws Exception {
SeekableView view2 = SeekableViewsForTest.generator(START_TIME, INTERVAL, NUM_POINTS, true, 10, 1);
DataPoints dps2 = PowerMockito.mock(DataPoints.class);
when(dps2.iterator()).thenReturn(view2);
when(dps2.metricName()).thenReturn("sys.mem");
when(dps2.metricUID()).thenReturn(new byte[] { 0, 0, 2 });
group_bys = new DataPoints[] { dps2 };
// doesn't matter what they are
for (int i = 0; i < 100; i++) {
query_results.add(group_bys);
}
func.evaluate(data_query, query_results, params);
}
Aggregations