Search in sources :

Example 6 with CustomCollector

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);
}
Also used : CustomCollector(com.yahoo.bullet.storm.testing.CustomCollector) IMetric(org.apache.storm.metric.api.IMetric) CustomTopologyContext(com.yahoo.bullet.storm.testing.CustomTopologyContext) Test(org.testng.annotations.Test)

Example 7 with CustomCollector

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));
}
Also used : CustomCollector(com.yahoo.bullet.storm.testing.CustomCollector) Tuple(org.apache.storm.tuple.Tuple) TupleUtils.makeIDTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple) Test(org.testng.annotations.Test)

Example 8 with CustomCollector

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"));
}
Also used : Querier(com.yahoo.bullet.querying.Querier) CustomCollector(com.yahoo.bullet.storm.testing.CustomCollector) Metadata(com.yahoo.bullet.pubsub.Metadata) Tuple(org.apache.storm.tuple.Tuple) TupleUtils.makeIDTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple) Test(org.testng.annotations.Test)

Example 9 with CustomCollector

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"));
}
Also used : Querier(com.yahoo.bullet.querying.Querier) CustomCollector(com.yahoo.bullet.storm.testing.CustomCollector) Metadata(com.yahoo.bullet.pubsub.Metadata) Tuple(org.apache.storm.tuple.Tuple) TupleUtils.makeIDTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple) Test(org.testng.annotations.Test)

Example 10 with CustomCollector

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();
}
Also used : CustomCollector(com.yahoo.bullet.storm.testing.CustomCollector) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

CustomCollector (com.yahoo.bullet.storm.testing.CustomCollector)12 Test (org.testng.annotations.Test)8 TupleUtils.makeIDTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple)6 Tuple (org.apache.storm.tuple.Tuple)6 Querier (com.yahoo.bullet.querying.Querier)4 CustomTopologyContext (com.yahoo.bullet.storm.testing.CustomTopologyContext)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 Metadata (com.yahoo.bullet.pubsub.Metadata)3 CountDistinctTest (com.yahoo.bullet.aggregations.CountDistinctTest)2 DistributionTest (com.yahoo.bullet.aggregations.DistributionTest)2 TopKTest (com.yahoo.bullet.aggregations.TopKTest)2 CountDistinct (com.yahoo.bullet.aggregations.CountDistinct)1 Distribution (com.yahoo.bullet.aggregations.Distribution)1 TopK (com.yahoo.bullet.aggregations.TopK)1 GroupData (com.yahoo.bullet.aggregations.grouping.GroupData)1 GroupOperation (com.yahoo.bullet.aggregations.grouping.GroupOperation)1 COUNT (com.yahoo.bullet.aggregations.grouping.GroupOperation.GroupOperationType.COUNT)1 COUNT_FIELD (com.yahoo.bullet.aggregations.sketches.QuantileSketch.COUNT_FIELD)1 END_EXCLUSIVE (com.yahoo.bullet.aggregations.sketches.QuantileSketch.END_EXCLUSIVE)1 NEGATIVE_INFINITY_START (com.yahoo.bullet.aggregations.sketches.QuantileSketch.NEGATIVE_INFINITY_START)1