use of com.yahoo.bullet.storm.testing.CustomTopologyContext in project bullet-storm by yahoo.
the class DRPCQuerySubscriberTest method setup.
@BeforeMethod
public void setup() {
DRPCConfig config = new DRPCConfig("src/test/resources/test_drpc_config.yaml");
// 1 task for the component named "foo" with task index 0
CustomTopologyContext context = new CustomTopologyContext(Collections.singletonList(1), "foo", 0);
config.set(DRPCConfig.STORM_CONTEXT, context);
Map stormConfig = new Config("src/test/resources/test_storm_config.yaml").getAll(Optional.empty());
config.set(DRPCConfig.STORM_CONFIG, stormConfig);
subscriber = new DRPCQuerySubscriber(config, 5);
DRPCOutputCollector collector = subscriber.getCollector();
// Override the DRPCSpout with our own that emits using our collector.
injectedMockSpout = new MockDRPCSpout("foo", collector);
subscriber.setSpout(injectedMockSpout);
}
use of com.yahoo.bullet.storm.testing.CustomTopologyContext in project bullet-storm by yahoo.
the class JoinBoltTest method setup.
public void setup(JoinBolt bolt) {
collector = new CustomCollector();
context = new CustomTopologyContext();
this.bolt = ComponentUtils.prepare(new HashMap<>(), bolt, context, collector);
}
use of com.yahoo.bullet.storm.testing.CustomTopologyContext in project bullet-storm by yahoo.
the class QueryBoltTest method testMetricsUpdateOnMetricsDisabled.
@Test
public void testMetricsUpdateOnMetricsDisabled() {
CustomTopologyContext context = new CustomTopologyContext();
CustomCollector collector = new CustomCollector();
TestQueryBolt bolt = new TestQueryBolt(new BulletStormConfig());
ComponentUtils.prepare(new HashMap<>(), bolt, context, collector);
Assert.assertFalse(bolt.isMetricsEnabled());
bolt.execute(null);
IMetric averager = context.getRegisteredMetricByName("foo");
IMetric counter = context.getRegisteredMetricByName("bar");
Assert.assertNull(averager.getValueAndReset());
Assert.assertEquals(counter.getValueAndReset(), 0L);
}
use of com.yahoo.bullet.storm.testing.CustomTopologyContext 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.CustomTopologyContext in project bullet-storm by yahoo.
the class FilterBoltTest method testFilteringLatency.
@Test
public void testFilteringLatency() {
config = new BulletStormConfig();
// Don't use the overridden aggregation default size but turn on built in metrics
config.set(BulletStormConfig.TOPOLOGY_METRICS_BUILT_IN_ENABLE, true);
collector = new CustomCollector();
CustomTopologyContext context = new CustomTopologyContext();
bolt = new FilterBolt(TopologyConstants.RECORD_COMPONENT, config);
ComponentUtils.prepare(new HashMap<>(), bolt, context, collector);
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeFieldFilterQuery("bar"), METADATA);
bolt.execute(query);
BulletRecord record = RecordBox.get().add("field", "foo").getRecord();
long start = System.currentTimeMillis();
IntStream.range(0, 10).mapToObj(i -> makeRecordTuple(record, System.currentTimeMillis())).forEach(bolt::execute);
long end = System.currentTimeMillis();
double actualLatecy = context.getDoubleMetric(TopologyConstants.LATENCY_METRIC);
Assert.assertTrue(actualLatecy <= end - start);
}
Aggregations