Search in sources :

Example 31 with TSDB

use of net.opentsdb.core.TSDB in project opentsdb by OpenTSDB.

the class NettyMocks method getMockedHTTPTSDB.

/**
   * Sets up a TSDB object for HTTP RPC tests that has a Config object
   * @return A TSDB mock
   */
public static TSDB getMockedHTTPTSDB() {
    final TSDB tsdb = mock(TSDB.class);
    final Config config = mock(Config.class);
    HashMap<String, String> properties = new HashMap<String, String>();
    properties.put("tsd.http.show_stack_trace", "true");
    Whitebox.setInternalState(config, "properties", properties);
    when(tsdb.getConfig()).thenReturn(config);
    return tsdb;
}
Also used : HashMap(java.util.HashMap) Config(net.opentsdb.utils.Config) TSDB(net.opentsdb.core.TSDB)

Example 32 with TSDB

use of net.opentsdb.core.TSDB in project opentsdb by OpenTSDB.

the class TestAnnotationRpc method before.

@Before
public void before() throws Exception {
    final Config config = new Config(false);
    tsdb = new TSDB(client, config);
    storage = new MockBase(tsdb, client, true, true, true, true);
    // add a global
    storage.addColumn(global_row_key, new byte[] { 1, 0, 0 }, ("{\"startTime\":1328140800,\"endTime\":1328140801,\"description\":" + "\"Description\",\"notes\":\"Notes\",\"custom\":{\"owner\":" + "\"ops\"}}").getBytes(MockBase.ASCII()));
    storage.addColumn(global_row_key, new byte[] { 1, 0, 1 }, ("{\"startTime\":1328140801,\"endTime\":1328140803,\"description\":" + "\"Global 2\",\"notes\":\"Nothing\"}").getBytes(MockBase.ASCII()));
    // add a local
    storage.addColumn(tsuid_row_key, new byte[] { 1, 0x0A, 0x02 }, ("{\"tsuid\":\"000001000001000001\",\"startTime\":1388450562," + "\"endTime\":1419984000,\"description\":\"Hello!\",\"notes\":" + "\"My Notes\",\"custom\":{\"owner\":\"ops\"}}").getBytes(MockBase.ASCII()));
    storage.addColumn(tsuid_row_key, new byte[] { 1, 0x0A, 0x03 }, ("{\"tsuid\":\"000001000001000001\",\"startTime\":1388450563," + "\"endTime\":1419984000,\"description\":\"Note2\",\"notes\":" + "\"Nothing\"}").getBytes(MockBase.ASCII()));
    // add some data points too
    storage.addColumn(tsuid_row_key, new byte[] { 0x50, 0x10 }, new byte[] { 1 });
    storage.addColumn(tsuid_row_key, new byte[] { 0x50, 0x18 }, new byte[] { 2 });
}
Also used : Config(net.opentsdb.utils.Config) TSDB(net.opentsdb.core.TSDB) MockBase(net.opentsdb.storage.MockBase) Before(org.junit.Before)

Example 33 with TSDB

use of net.opentsdb.core.TSDB in project opentsdb by OpenTSDB.

the class TestTreeRule method before.

@Before
public void before() throws Exception {
    final Config config = new Config(false);
    tsdb = new TSDB(client, config);
    rule = new TreeRule();
}
Also used : TreeRule(net.opentsdb.tree.TreeRule) Config(net.opentsdb.utils.Config) TSDB(net.opentsdb.core.TSDB) Before(org.junit.Before)

Example 34 with TSDB

use of net.opentsdb.core.TSDB in project opentsdb by OpenTSDB.

the class TestTree method before.

@Before
public void before() throws Exception {
    final Config config = new Config(false);
    config.overrideConfig("tsd.storage.enable_compaction", "false");
    tsdb = new TSDB(client, config);
}
Also used : Config(net.opentsdb.utils.Config) TSDB(net.opentsdb.core.TSDB) Before(org.junit.Before)

Example 35 with TSDB

use of net.opentsdb.core.TSDB in project opentsdb by OpenTSDB.

the class TestRpcManager method loadRpcPlugin.

@Test
public void loadRpcPlugin() throws Exception {
    Config config = mock(Config.class);
    when(config.hasProperty("tsd.rpc.plugins")).thenReturn(true);
    when(config.getString("tsd.rpc.plugins")).thenReturn("net.opentsdb.tsd.DummyRpcPlugin");
    when(config.hasProperty("tsd.rpcplugin.DummyRPCPlugin.hosts")).thenReturn(true);
    when(config.getString("tsd.rpcplugin.DummyRPCPlugin.hosts")).thenReturn("blah");
    when(config.getInt("tsd.rpcplugin.DummyRPCPlugin.port")).thenReturn(1000);
    when(config.getString("tsd.core.enable_api")).thenReturn("true");
    when(config.getString("tsd.core.enable_ui")).thenReturn("true");
    when(config.getString("tsd.no_diediedie")).thenReturn("false");
    TSDB tsdb = mock(TSDB.class);
    when(tsdb.getConfig()).thenReturn(config);
    PluginLoader.loadJAR("plugin_test.jar");
    mgr_under_test = RpcManager.instance(tsdb);
    assertFalse(mgr_under_test.getRpcPlugins().isEmpty());
}
Also used : Config(net.opentsdb.utils.Config) TSDB(net.opentsdb.core.TSDB) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

TSDB (net.opentsdb.core.TSDB)43 Config (net.opentsdb.utils.Config)41 Before (org.junit.Before)16 Test (org.junit.Test)14 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 MockBase (net.opentsdb.storage.MockBase)13 KeyValue (org.hbase.async.KeyValue)12 ArrayList (java.util.ArrayList)11 Matchers.anyString (org.mockito.Matchers.anyString)11 UniqueIdType (net.opentsdb.uid.UniqueId.UniqueIdType)8 Field (java.lang.reflect.Field)6 NoSuchUniqueName (net.opentsdb.uid.NoSuchUniqueName)5 IOException (java.io.IOException)4 UnitTestException (net.opentsdb.core.BaseTsdbTest.UnitTestException)4 Deferred (com.stumbleupon.async.Deferred)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 DataPoint (net.opentsdb.core.DataPoint)2 Query (net.opentsdb.core.Query)2 HBaseException (org.hbase.async.HBaseException)2