Search in sources :

Example 1 with TupleUtils.makeIDTuple

use of com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple in project bullet-storm by yahoo.

the class FilterBoltTest method testRateLimiting.

@Test
public void testRateLimiting() {
    config = new BulletStormConfig();
    RateLimitError rateLimitError = new RateLimitError(42.0, config);
    bolt = new RateLimitedFilterBolt(2, rateLimitError, config);
    bolt = ComponentUtils.prepare(new HashMap<>(), bolt, collector);
    Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeSimpleAggregationFilterQuery("field", singletonList("b235gf23b"), EQUALS, RAW, 100, Window.Unit.RECORD, 1, Window.Unit.RECORD, 1), METADATA);
    bolt.execute(query);
    BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
    Tuple matching = makeRecordTuple(record);
    bolt.execute(matching);
    bolt.execute(matching);
    Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
    Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
    bolt.execute(matching);
    Tuple error = TupleUtils.makeIDTuple(TupleClassifier.Type.ERROR_TUPLE, "42", rateLimitError);
    Assert.assertTrue(collector.wasNthEmitted(error, 3));
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) HashMap(java.util.HashMap) RateLimitError(com.yahoo.bullet.querying.RateLimitError) TupleUtils.makeTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeTuple) TupleUtils.makeRawTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeRawTuple) Tuple(org.apache.storm.tuple.Tuple) TupleUtils.makeIDTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple) Test(org.testng.annotations.Test) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Aggregations

CountDistinctTest (com.yahoo.bullet.aggregations.CountDistinctTest)1 DistributionTest (com.yahoo.bullet.aggregations.DistributionTest)1 TopKTest (com.yahoo.bullet.aggregations.TopKTest)1 RateLimitError (com.yahoo.bullet.querying.RateLimitError)1 BulletRecord (com.yahoo.bullet.record.BulletRecord)1 TupleUtils.makeIDTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple)1 TupleUtils.makeRawTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeRawTuple)1 TupleUtils.makeTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeTuple)1 HashMap (java.util.HashMap)1 Tuple (org.apache.storm.tuple.Tuple)1 Test (org.testng.annotations.Test)1