Search in sources :

Example 1 with FakeTaskTimer

use of net.opentsdb.core.BaseTsdbTest.FakeTaskTimer in project opentsdb by OpenTSDB.

the class TestPutRpc method before.

@Before
public void before() throws Exception {
    tsdb = NettyMocks.getMockedHTTPTSDB();
    when(tsdb.addPoint("sys.cpu.nice", 1365465600, 42, TAGS)).thenReturn(Deferred.fromResult(new Object()));
    when(tsdb.addPoint("sys.cpu.nice", 1365465600, -42, TAGS)).thenReturn(Deferred.fromResult(new Object()));
    when(tsdb.addPoint("sys.cpu.nice", 1365465600, 42.2f, TAGS)).thenReturn(Deferred.fromResult(new Object()));
    when(tsdb.addPoint("sys.cpu.nice", 1365465600, -42.2f, TAGS)).thenReturn(Deferred.fromResult(new Object()));
    when(tsdb.addPoint("sys.cpu.nice", 1365465600, 4220.0f, TAGS)).thenReturn(Deferred.fromResult(new Object()));
    when(tsdb.addPoint("sys.cpu.nice", 1365465600, -4220.0f, TAGS)).thenReturn(Deferred.fromResult(new Object()));
    when(tsdb.addPoint("sys.cpu.nice", 1365465600, .0042f, TAGS)).thenReturn(Deferred.fromResult(new Object()));
    when(tsdb.addPoint("sys.cpu.nice", 1365465600, -0.0042f, TAGS)).thenReturn(Deferred.fromResult(new Object()));
    when(tsdb.addPoint("sys.cpu.system", 1365465600, 24, TAGS)).thenReturn(Deferred.fromResult(new Object()));
    // errors
    when(tsdb.addPoint("doesnotexist", 1365465600, 42, TAGS)).thenThrow(new NoSuchUniqueName("metric", "doesnotexist"));
    when(tsdb.addPoint("sys.cpu.system", 1365465600, 1, TAGS)).thenReturn(Deferred.fromError(new RuntimeException("Wotcher!")));
    when(tsdb.addPoint("sys.cpu.system", 1365465600, 2, TAGS)).thenReturn(new Deferred<Object>());
    requests = Whitebox.getInternalState(PutDataPointRpc.class, "requests");
    requests.set(0);
    hbase_errors = Whitebox.getInternalState(PutDataPointRpc.class, "hbase_errors");
    hbase_errors.set(0);
    invalid_values = Whitebox.getInternalState(PutDataPointRpc.class, "invalid_values");
    invalid_values.set(0);
    illegal_arguments = Whitebox.getInternalState(PutDataPointRpc.class, "illegal_arguments");
    illegal_arguments.set(0);
    unknown_metrics = Whitebox.getInternalState(PutDataPointRpc.class, "unknown_metrics");
    unknown_metrics.set(0);
    writes_blocked = Whitebox.getInternalState(PutDataPointRpc.class, "writes_blocked");
    writes_blocked.set(0);
    timer = new FakeTaskTimer();
    handler = mock(StorageExceptionHandler.class);
    when(tsdb.getStorageExceptionHandler()).thenReturn(handler);
    when(tsdb.getTimer()).thenReturn(timer);
}
Also used : FakeTaskTimer(net.opentsdb.core.BaseTsdbTest.FakeTaskTimer) NoSuchUniqueName(net.opentsdb.uid.NoSuchUniqueName) Before(org.junit.Before)

Aggregations

FakeTaskTimer (net.opentsdb.core.BaseTsdbTest.FakeTaskTimer)1 NoSuchUniqueName (net.opentsdb.uid.NoSuchUniqueName)1 Before (org.junit.Before)1