use of org.apache.storm.testing.AckFailMapTracker in project storm by apache.
the class TestingTest method testDisableTupleTimeout.
@Test
public void testDisableTupleTimeout() throws Exception {
Config daemonConf = new Config();
daemonConf.put(Config.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS, false);
try (LocalCluster cluster = new LocalCluster.Builder().withDaemonConf(daemonConf).withSimulatedTime().build()) {
FeederSpout feeder = new FeederSpout(new Fields("field1"));
AckFailMapTracker tracker = new AckFailMapTracker();
feeder.setAckFailDelegate(tracker);
Map<String, Thrift.SpoutDetails> spoutMap = new HashMap<>();
spoutMap.put("1", Thrift.prepareSpoutDetails(feeder));
Map<String, Thrift.BoltDetails> boltMap = new HashMap<>();
boltMap.put("2", Thrift.prepareBoltDetails(Collections.singletonMap(Utils.getGlobalStreamId("1", null), Thrift.prepareShuffleGrouping()), new AckEveryOtherBolt()));
StormTopology topology = Thrift.buildTopology(spoutMap, boltMap);
Config stormConf = new Config();
stormConf.put(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 10);
stormConf.put(Config.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS, false);
cluster.submitTopology("disable-timeout-tester", stormConf, topology);
feeder.feed(new Values("a"), 1);
feeder.feed(new Values("b"), 2);
feeder.feed(new Values("c"), 3);
cluster.advanceClusterTime(9);
assertAcked(tracker, 1, 3);
assertThat(tracker.isFailed(2), is(false));
cluster.advanceClusterTime(12);
assertThat(tracker.isFailed(2), is(false));
}
}
use of org.apache.storm.testing.AckFailMapTracker in project storm by apache.
the class TopologyIntegrationTest method testTimeout.
@Test
public void testTimeout() throws Exception {
try (LocalCluster cluster = new LocalCluster.Builder().withSimulatedTime().withSupervisors(4).withDaemonConf(Collections.singletonMap(Config.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS, true)).build()) {
FeederSpout feeder = new FeederSpout(new Fields("field1"));
AckFailMapTracker tracker = new AckFailMapTracker();
feeder.setAckFailDelegate(tracker);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("1", feeder);
builder.setBolt("2", new AckEveryOtherBolt()).globalGrouping("1");
StormTopology topology = builder.createTopology();
cluster.submitTopology("timeout-tester", Collections.singletonMap(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 10), topology);
cluster.advanceClusterTime(11);
feeder.feed(new Values("a"), 1);
feeder.feed(new Values("b"), 2);
feeder.feed(new Values("c"), 3);
cluster.advanceClusterTime(9);
assertAcked(tracker, 1, 3);
assertThat(tracker.isFailed(2), is(false));
cluster.advanceClusterTime(12);
assertFailed(tracker, 2);
}
}
use of org.apache.storm.testing.AckFailMapTracker in project storm by apache.
the class TopologyIntegrationTest method testSubmitInactiveTopology.
@Test
public void testSubmitInactiveTopology() throws Exception {
try (LocalCluster cluster = new LocalCluster.Builder().withSimulatedTime().withDaemonConf(Collections.singletonMap(Config.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS, true)).build()) {
FeederSpout feeder = new FeederSpout(new Fields("field1"));
AckFailMapTracker tracker = new AckFailMapTracker();
feeder.setAckFailDelegate(tracker);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("1", feeder);
builder.setSpout("2", new OpenTrackedSpout());
builder.setBolt("3", new PrepareTrackedBolt()).globalGrouping("1");
boltPrepared = false;
spoutOpened = false;
StormTopology topology = builder.createTopology();
cluster.submitTopologyWithOpts("test", Collections.singletonMap(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 10), topology, new SubmitOptions(TopologyInitialStatus.INACTIVE));
cluster.advanceClusterTime(11);
feeder.feed(new Values("a"), 1);
cluster.advanceClusterTime(9);
assertThat(boltPrepared, is(false));
assertThat(spoutOpened, is(false));
cluster.getNimbus().activate("test");
cluster.advanceClusterTime(12);
assertAcked(tracker, 1);
assertThat(boltPrepared, is(true));
assertThat(spoutOpened, is(true));
}
}
use of org.apache.storm.testing.AckFailMapTracker in project storm by apache.
the class TopologyIntegrationTest method testResetTimeout.
@Test
public void testResetTimeout() throws Exception {
try (LocalCluster cluster = new LocalCluster.Builder().withSimulatedTime().withDaemonConf(Collections.singletonMap(Config.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS, true)).build()) {
FeederSpout feeder = new FeederSpout(new Fields("field1"));
AckFailMapTracker tracker = new AckFailMapTracker();
feeder.setAckFailDelegate(tracker);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("1", feeder);
builder.setBolt("2", new ResetTimeoutBolt()).globalGrouping("1");
StormTopology topology = builder.createTopology();
cluster.submitTopology("reset-timeout-tester", Collections.singletonMap(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 10), topology);
// The first tuple wil be used to check timeout reset
feeder.feed(new Values("a"), 1);
// The second tuple is used to wait for the spout to rotate its pending map
feeder.feed(new Values("b"), 2);
cluster.advanceClusterTime(9);
// The other tuples are used to reset the first tuple's timeout,
// and to wait for the message to get through to the spout (acks use the same path as timeout resets)
feeder.feed(new Values("c"), 3);
assertAcked(tracker, 3);
cluster.advanceClusterTime(9);
feeder.feed(new Values("d"), 4);
assertAcked(tracker, 4);
cluster.advanceClusterTime(2);
// The time is now twice the message timeout, the second tuple should expire since it was not acked
// Waiting for this also ensures that the first tuple gets failed if reset-timeout doesn't work
assertFailed(tracker, 2);
// Put in a tuple to cause the first tuple to be acked
feeder.feed(new Values("e"), 5);
assertAcked(tracker, 5);
// The first tuple should be acked, and should not have failed
assertThat(tracker.isFailed(1), is(false));
assertAcked(tracker, 1);
}
}
use of org.apache.storm.testing.AckFailMapTracker in project storm by apache.
the class TickTupleTest method testTickTupleWorksWithSystemBolt.
@Test
public void testTickTupleWorksWithSystemBolt() throws Exception {
try (ILocalCluster cluster = new LocalCluster.Builder().withSimulatedTime().build()) {
TopologyBuilder builder = new TopologyBuilder();
FeederSpout feeder = new FeederSpout(new Fields("field1"));
AckFailMapTracker tracker = new AckFailMapTracker();
feeder.setAckFailDelegate(tracker);
builder.setSpout("Spout", feeder);
builder.setBolt("Bolt", new NoopBolt()).shuffleGrouping("Spout");
Config topoConf = new Config();
topoConf.put(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, TICK_INTERVAL_SECS);
try (ILocalTopology topo = cluster.submitTopology("test", topoConf, builder.createTopology())) {
// Use a bootstrap tuple to wait for topology to be running
feeder.feed(new Values("val"), 1);
AssertLoop.assertAcked(tracker, 1);
/*
* Verify that some ticks are received. The interval between ticks is validated by the bolt.
* Too few and the checks will time out. Too many and the bolt may crash (not reliably, but the test should become flaky).
*/
try {
cluster.advanceClusterTime(TICK_INTERVAL_SECS);
waitForTicks(1);
cluster.advanceClusterTime(TICK_INTERVAL_SECS);
waitForTicks(2);
cluster.advanceClusterTime(TICK_INTERVAL_SECS);
waitForTicks(3);
} catch (ConditionTimeoutException e) {
throw new AssertionError(e.getMessage());
}
assertNull("The bolt got a tuple that is not a tick tuple " + nonTickTuple.get(), nonTickTuple.get());
}
}
}
Aggregations