Buggy code:
@ RunWith ( Parameterized . class ) public class KafkaPartitionableInputOperatorTest extends KafkaOperatorTestBase { private int totalBrokers = 0 ; @ Parameters ( name = "multi-cluster:<seq2seq4repair_space>{0},<seq2seq4repair_space>multi-partition:<seq2seq4repair_space>{1}" ) public static Collection < Boolean [ ] > testScenario ( ) { } public KafkaPartitionableInputOperatorTest ( boolean hasMultiCluster , boolean hasMultiPartition ) { } static final Logger logger = LoggerFactory . getLogger ( KafkaPartitionableInputOperatorTest . class ) ; static HashMap < String , List < ? > > collections = new HashMap < String , List < ? > > ( ) ; static AtomicInteger tupleCount = new AtomicInteger ( ) ; static CountDownLatch latch ; public static class CollectorModule < T > extends BaseOperator { public final transient KafkaPartitionableInputOperatorTest . CollectorInputPort < T > inputPort = new KafkaPartitionableInputOperatorTest . CollectorInputPort < T > ( "myInput" , this ) ; } public static class CollectorInputPort < T > extends DefaultInputPort < T > { ArrayList < T > list ; final String id ; public CollectorInputPort ( String id , Operator module ) { } @ Override public void process ( T tuple ) { } @ Override public void setConnected ( boolean flag ) { } } @ Test public void testPartitionableSimpleConsumerInputOperator ( ) throws Exception { } @ Test public void testPartitionableHighlevelConsumerInputOperator ( ) throws Exception { } public void testPartitionableInputOperator ( KafkaConsumer consumer ) throws Exception { KafkaPartitionableInputOperatorTest . latch = new CountDownLatch ( totalBrokers ) ; int totalCount = 10000 ; KafkaTestProducer p = new KafkaTestProducer ( TEST_TOPIC , hasMultiPartition , hasMultiCluster ) ; p . setSendCount ( totalCount ) ; new Thread ( p ) . start ( ) ; LocalMode lma = LocalMode . newInstance ( ) ; DAG dag = lma . getDAG ( ) ; PartitionableKafkaSinglePortStringInputOperator node = dag . addOperator ( "Kafka<seq2seq4repair_space>message<seq2seq4repair_space>consumer" , PartitionableKafkaSinglePortStringInputOperator . class ) ; node . setInitialPartitionCount ( 1 ) ; consumer . setTopic ( TEST_TOPIC ) ; consumer . setInitialOffset ( "earliest" ) ; node . setConsumer ( consumer ) ; String clusterString = ( "cluster1:localhost:" + ( TEST_ZOOKEEPER_PORT [ 0 ] ) ) + ( hasMultiCluster ? ",cluster2:localhost:" + ( TEST_ZOOKEEPER_PORT [ 1 ] ) : "" ) ; node . setZookeeper ( clusterString ) ; KafkaPartitionableInputOperatorTest . CollectorModule < String > collector = dag . addOperator ( "TestMessageCollector" , new KafkaPartitionableInputOperatorTest . CollectorModule < String > ( ) ) ; dag . addStream ( "Kafka<seq2seq4repair_space>message" , node . outputPort , collector . inputPort ) . setLocality ( CONTAINER_LOCAL ) ; final LocalMode . Controller lc = lma . getController ( ) ; lc . setHeartbeatMonitoringEnabled ( false ) ; lc . runAsync ( ) ; <START_BUG> Assert . assertTrue ( "TIMEOUT:<seq2seq4repair_space>30s<seq2seq4repair_space>" , KafkaPartitionableInputOperatorTest . latch . await ( 40000 , TimeUnit . MILLISECONDS ) ) ; <END_BUG> Assert . assertEquals ( "Collections<seq2seq4repair_space>size" , 1 , KafkaPartitionableInputOperatorTest . collections . size ( ) ) ; Assert . assertEquals ( "Tuple<seq2seq4repair_space>count" , totalCount , KafkaPartitionableInputOperatorTest . collections . get ( collector . inputPort . id ) . size ( ) ) ; KafkaPartitionableInputOperatorTest . logger . debug ( String . format ( "Number<seq2seq4repair_space>of<seq2seq4repair_space>emitted<seq2seq4repair_space>tuples:<seq2seq4repair_space>%d" , KafkaPartitionableInputOperatorTest . collections . get ( collector . inputPort . id ) . size ( ) ) ) ; p . close ( ) ; lc . shutdown ( ) ; Thread . sleep ( 5000 ) ; } }

Fix:
Assert . assertTrue ( "TIMEOUT:<seq2seq4repair_space>40s<seq2seq4repair_space>" , KafkaPartitionableInputOperatorTest . latch . await ( 40000 , TimeUnit . MILLISECONDS ) ) ;