BlockHound
BlockHound copied to clipboard
When Blockhound is used with EmbeddedKafka for unit test, kafka wont terminate
When Blockhound is used with EmbeddedKafka for unit test, Kafka won't terminate after the test is completed. If Blockhound is disabled, no problem in running tests.
Expected Behavior
After tests are completed, embedded Kafka should be terminated.
Actual Behavior
After tests are completed, embedded Kafka is not terminated. So other tests are not running and the system is waiting for Kafka to stop.
Steps to Reproduce
@SpringBootTest(classes = {KafkaConfiguration.class})
@EmbeddedKafka(partitions = 1, brokerProperties = {TestConstants.SERVER, TestConstants.PORT})
@DirtiesContext
@Slf4j
class OrderUpdateTest {
@BeforeEach
public void init() {
BlockHound.install();
log.info("Installed blockhound");
}
@Test
public void testProducer()
throws Exception {
log.info("test");
}
@AfterEach
public void after() {
log.info("finished test");
}
}
Your Environment
- OS: macOS Big Sur
- Java:
JDK11 - Spring Boot
2.4.2 - Blockhound
1.0.4.RELEASE - Spring Kafka
2.5.6.RELEASE
let's see if we can close this old issue ...
So, I have difficulties to reproduce this issue; I'm using this project which is similar to your use case. I have modified the pom.xml in order to add a dependency on bockhound 1.0.6.RELEASE, then I changed the SpringBootEmbeddedKafka class in order to install BlockHound from SpringBootEmbeddedKafka.setUpClass() method. and using JDK 11, it seems to work well for me.
if you still want this issue to be investigated, please try to update the above sample code, and try to reproduce.
thanks.