While using parallel gradle tests (org.gradle.parallel=true) to minimize overall test-execution time with junit5 and the @EmbeddedKafka annotation (I need to do integration-tests for > 20 different kafka-based micro-services; using parallel-testing allows me to divide execution-time by a factor 10), I started experimenting timeout exceptions as part of the createTopics method of EmbeddedKafkaBroker.
This problem could be easily remediated by setting up a custom value for the adminTimeout member of EmbeddedKafkaBroker...The problem is I can't see how to achieve this while using junit5 and @EmbeddedKafka annotation...any suggestion ?
thanks a lot in advance for your expertise and your time.
Best Regards
Asked
Active
Viewed 570 times
0

user2038596
- 535
- 1
- 3
- 14
1 Answers
1
The method of the EmbeddedKafkaBroker
:
/**
* Set the timeout in seconds for admin operations (e.g. topic creation, close).
* Default 30 seconds.
* @param adminTimeout the timeout.
* @since 2.2
*/
public void setAdminTimeout(int adminTimeout) {
is just not exposed into an @EmbeddedKafka
.
Feel free to raise a GH issue so we will consider to add it in the future.
As a workaround you can setup such an embedded broker manually: private static EmbeddedKafkaBroker embeddedKafka;
@BeforeAll
static void setup() {
embeddedKafka = new EmbeddedKafkaBroker(1, true, topic1, topic2);
embeddedKafka.setAdminTimeout(100);
embeddedKafka.afterPropertiesSet();
}
@AfterAll
static void tearDown() {
embeddedKafka.destroy();
}

Artem Bilan
- 113,505
- 11
- 91
- 118
-
As per your suggestion, I created request #2059 under GH spring-kafka project. Thanks again for your feedback, Artem ! – user2038596 Jan 04 '22 at 12:48
-
You might also want to explore using a single broker for the entire test suite https://docs.spring.io/spring-kafka/docs/current/reference/html/#using-the-same-brokers-for-multiple-test-classes – Gary Russell Jan 04 '22 at 21:23