-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MINOR: Refactor ShareConsumerTest to use ClusterTestExtensions. #18656
base: trunk
Are you sure you want to change the base?
Conversation
this.cluster = cluster; | ||
} | ||
|
||
private void setup() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be preferable if it was possible to put this in a @BeforeEach
method. Is that no longer an option, even with code gymnastics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndrewJSchofield I think not - since the clusterInstance is not populated at that time. It shows up as null.
Using @BeforeEach
- it throws an exception
org.opentest4j.AssertionFailedError
at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:46)
at org.junit.jupiter.api.Assertions.fail(Assertions.java:161)
at kafka.test.api.ShareConsumerTest.setup(ShareConsumerTest.java:144)
...
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.kafka.common.test.KafkaClusterTestKit.waitForReadyBrokers()" because "this.clusterTestKit" is null
at org.apache.kafka.common.test.api.RaftClusterInvocationContext$RaftClusterInstance.waitForReadyBrokers(RaftClusterInvocationContext.java:219)
at kafka.test.api.ShareConsumerTest.setup(ShareConsumerTest.java:136)
... 17 more
I checked a couple of implementations and they are using this approach to perform pre-test initializations. The internal KafkaClusterTestKit
object is not populated when beforeEach is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mumrah Is there something I am missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment, we can't use the ClusterInstance inside a @BeforeEach
with @ClusterTest
. I'll see if we can fix that in a safe way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #18662 to add support for this. For now, we can do the explicit "setup" call as done in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, LGTM!
ShareConsumerTest
suite usesKafkaClusterTestKit
to create kafka clusters and assert various scenarios. However, the current implementation is not open for parameterization.ClusterTestExtensions
and associated abstractions which makes the tests cleaner and easy to parameterise.ShareConsumer
instance creation factory method inClusterInstance
interface.