use of com.yahoo.bullet.storm.testing.CustomCollector in project bullet-storm by yahoo.
the class QueryBoltTest method testMetricsUpdateOnMetricsEnabled.
@Test
public void testMetricsUpdateOnMetricsEnabled() {
CustomTopologyContext context = new CustomTopologyContext();
CustomCollector collector = new CustomCollector();
BulletStormConfig config = new BulletStormConfig();
config.set(BulletStormConfig.TOPOLOGY_METRICS_BUILT_IN_ENABLE, true);
config.validate();
TestQueryBolt bolt = new TestQueryBolt(config);
ComponentUtils.prepare(new HashMap<>(), bolt, context, collector);
Assert.assertTrue(bolt.isMetricsEnabled());
bolt.execute(null);
IMetric averager = context.getRegisteredMetricByName("foo");
IMetric counter = context.getRegisteredMetricByName("bar");
Assert.assertEquals(averager.getValueAndReset(), 1.0);
Assert.assertEquals(counter.getValueAndReset(), 1L);
}
use of com.yahoo.bullet.storm.testing.CustomCollector in project bullet-storm by yahoo.
the class QueryBoltTest method testPrepare.
@Test
public void testPrepare() {
CustomCollector collector = new CustomCollector();
TestQueryBolt bolt = new TestQueryBolt(new BulletStormConfig());
ComponentUtils.prepare(bolt, collector);
Assert.assertEquals(collector.getAckedCount(), 0);
bolt.getCollector().ack(null);
Assert.assertEquals(collector.getAckedCount(), 1);
Assert.assertEquals(bolt.getQueries().size(), 0);
Assert.assertEquals(bolt.getMetricsMapping(), BulletStormConfig.DEFAULT_TOPOLOGY_METRICS_BUILT_IN_EMIT_INTERVAL_MAPPING);
Assert.assertEquals(bolt.isMetricsEnabled(), BulletStormConfig.DEFAULT_TOPOLOGY_METRICS_ENABLE);
Tuple tuple = mock(Tuple.class);
doReturn(TopologyConstants.RECORD_COMPONENT).when(tuple).getSourceComponent();
Assert.assertEquals(bolt.getClassifier().classify(tuple), Optional.of(Type.RECORD_TUPLE));
}
use of com.yahoo.bullet.storm.testing.CustomCollector in project bullet-storm by yahoo.
the class QueryBoltTest method testMetaTupleRemovingQueries.
@Test
public void testMetaTupleRemovingQueries() {
CustomCollector collector = new CustomCollector();
TestQueryBolt bolt = new TestQueryBolt(new BulletStormConfig());
ComponentUtils.prepare(bolt, collector);
Map<String, Querier> queries = bolt.getQueries();
queries.put("foo", null);
Tuple complete = makeIDTuple(Type.METADATA_TUPLE, "foo", new Metadata(Signal.COMPLETE, null));
bolt.execute(complete);
Assert.assertFalse(queries.containsKey("foo"));
queries.put("foo", null);
Tuple fail = makeIDTuple(Type.METADATA_TUPLE, "foo", new Metadata(Signal.KILL, null));
bolt.execute(fail);
Assert.assertFalse(queries.containsKey("foo"));
}
use of com.yahoo.bullet.storm.testing.CustomCollector in project bullet-storm by yahoo.
the class QueryBoltTest method testRegularMetaTupleIgnored.
@Test
public void testRegularMetaTupleIgnored() {
CustomCollector collector = new CustomCollector();
TestQueryBolt bolt = new TestQueryBolt(new BulletStormConfig());
ComponentUtils.prepare(bolt, collector);
Map<String, Querier> queries = bolt.getQueries();
queries.put("foo", null);
Tuple meta = makeIDTuple(Type.METADATA_TUPLE, "foo", new Metadata(Signal.ACKNOWLEDGE, null));
bolt.execute(meta);
Assert.assertTrue(queries.containsKey("foo"));
}
use of com.yahoo.bullet.storm.testing.CustomCollector in project bullet-storm by yahoo.
the class ResultBoltTest method setup.
@BeforeMethod
public void setup() {
BulletStormConfig config = new BulletStormConfig("src/test/resources/test_config.yaml");
bolt = new ResultBolt(config);
collector = new CustomCollector();
ComponentUtils.prepare(bolt, collector);
publisher = (CustomPublisher) bolt.getPublisher();
}
Aggregations