MINOR: Wait for tasks to terminate to avoid exception in test teardown
Author: Rajini Sivaram
Reviewers: Ismael Juma
Closes from rajinisivaram/MINOR-consumerbounce-test
@@ -76,6 +76,8 @@ class ConsumerBounceTest extends IntegrationTestHarness with Logging {
override def tearDown() {
try {
executor.shutdownNow()
+ // Wait for any active tasks to terminate to ensure consumer is not closed while being used from another thread
+ assertTrue("Executor did not terminate", executor.awaitTermination(5000, TimeUnit.MILLISECONDS))
} finally {
super.tearDown()
}
@@ -339,6 +341,7 @@ class ConsumerBounceTest extends IntegrationTestHarness with Logging {
waitForRebalance(2000, rebalanceFuture, consumer2)
// Trigger another rebalance and shutdown all brokers
+ // This consumer poll() doesn't complete and `tearDown` shuts down the executor and closes the consumer
createConsumerToRebalance()
servers.foreach(server => killBroker(server.config.brokerId))
