use of net.opentsdb.tree.TreeRule in project opentsdb by OpenTSDB.
the class TestTreeRule method storeRuleInvalidMissingCustomFieldTagvCustom.
@Test(expected = IllegalArgumentException.class)
public void storeRuleInvalidMissingCustomFieldTagvCustom() throws Exception {
setupStorage();
final TreeRule rule = new TreeRule(1);
rule.setLevel(1);
rule.setOrder(0);
rule.setType(TreeRuleType.TAGV_CUSTOM);
rule.setNotes("Just some notes");
rule.setField("foo");
rule.syncToStorage(storage.getTSDB(), false).joinUninterruptibly();
}
use of net.opentsdb.tree.TreeRule in project opentsdb by OpenTSDB.
the class TestTreeRule method storeRuleInvalidMissingFieldMetricCustom.
@Test(expected = IllegalArgumentException.class)
public void storeRuleInvalidMissingFieldMetricCustom() throws Exception {
setupStorage();
final TreeRule rule = new TreeRule(1);
rule.setLevel(1);
rule.setOrder(0);
rule.setType(TreeRuleType.METRIC_CUSTOM);
rule.setNotes("Just some notes");
rule.syncToStorage(storage.getTSDB(), false).joinUninterruptibly();
}
use of net.opentsdb.tree.TreeRule in project opentsdb by OpenTSDB.
the class TestTreeRule method setupStorage.
/**
* Mocks classes for testing the storage calls
*/
private void setupStorage() throws Exception {
storage = new MockBase(tsdb, client, true, true, true, true);
final List<byte[]> families = new ArrayList<byte[]>();
families.add(Tree.TREE_FAMILY());
storage.addTable(TREE_TABLE, families);
final TreeRule stored_rule = new TreeRule(1);
stored_rule.setLevel(2);
stored_rule.setOrder(1);
stored_rule.setType(TreeRuleType.METRIC_CUSTOM);
stored_rule.setField("host");
stored_rule.setCustomField("owner");
stored_rule.setDescription("Host owner");
stored_rule.setNotes("Owner of the host machine");
// pretend there's a tree definition in the storage row
storage.addColumn(TREE_TABLE, new byte[] { 0, 1 }, Tree.TREE_FAMILY(), "tree".getBytes(MockBase.ASCII()), new byte[] { 1 });
// add a rule to the row
storage.addColumn(TREE_TABLE, new byte[] { 0, 1 }, Tree.TREE_FAMILY(), "tree_rule:2:1".getBytes(MockBase.ASCII()), JSON.serializeToBytes(stored_rule));
}
use of net.opentsdb.tree.TreeRule in project opentsdb by OpenTSDB.
the class TestTreeRule method storeRuleBadID65536.
@Test(expected = IllegalArgumentException.class)
public void storeRuleBadID65536() throws Exception {
setupStorage();
final TreeRule rule = new TreeRule(65536);
rule.syncToStorage(storage.getTSDB(), false);
}
use of net.opentsdb.tree.TreeRule in project opentsdb by OpenTSDB.
the class TestTreeRule method fetchRule.
@Test
public void fetchRule() throws Exception {
setupStorage();
final TreeRule rule = TreeRule.fetchRule(storage.getTSDB(), 1, 2, 1).joinUninterruptibly();
assertNotNull(rule);
assertEquals(1, rule.getTreeId());
assertEquals(2, rule.getLevel());
assertEquals(1, rule.getOrder());
assertEquals("Host owner", rule.getDescription());
}
Aggregations