-
Notifications
You must be signed in to change notification settings - Fork 47
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
Fix Kafka Client leaks in the SampleFilterIntegrationTest. #519
Conversation
60f4cac
to
65bb1e7
Compare
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.
LGTM
@@ -212,6 +211,9 @@ void assertConsumerRecordEquals(String value) { | |||
*/ | |||
void close() { | |||
this.tester.close(); | |||
this.admin.close(); |
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.
Im happy with this as a tactical choice, but longer term? Would a better fix not be to have test.close()
ensure all the clients it has handed out are closed?
I also wondered about making FilterIntegrationTest.admin
etc some sort of lazy function
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.
I had assumed (incorrectly) that tester.close()
also closed everything that had been created by the tester (i.e. admin, producer, consumer). Having the tester check what it created and then ensure they're all correctly disposed of on close makes the most sense to me.
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.
Sometimes we want the lifespan of the Kafka object (producer, consumer, admin) to extend beyond the lifespan of Kroxylicious instance. We use this so that we can ensure that clients are capable of reconnecting through a replacement instance.
One way to solve this problem might be to break the association between the lifecycle of the tester the lifecycle of the kroxylicious. That would retain the flexibility we need to write this sort of test:
try(var tester = kroxyliciousTester();// No longer creates a kroxylicious instance
var admin = tester.admin()) {
try(var kroxy = tester.kroxylicious()) { // Creates a Kroxylicious
// ...
// do something with admin
}
try(var kroxy = tester.kroxylicious()) { // Creates a Kroxylicious
// ...
// check admin reconnects
}
}
It would also mean tester.close()
could be given the semantics to ensure that everything it created has been closed, which is more obvious for the programmer to reason about.
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.
WDYT? @robobario @gracegrimwood @SamBarker ?
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.
Yeah that sounds like a good way to go. I've raised that proposal as #526
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.
Does that conflict with your other issue #378, if we can make clients independent of the existence of a Kroxylicious instance?
Another way would be to make KroxyliciousTester able to clean up dangling clients on close, and in special cases like the resilience test we construct them in the test using config supplied by the tester so they are detached from Tester.
moved discussion to issue #526
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.
Nice catch! LGTM
@@ -212,6 +211,9 @@ void assertConsumerRecordEquals(String value) { | |||
*/ | |||
void close() { | |||
this.tester.close(); | |||
this.admin.close(); |
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.
I had assumed (incorrectly) that tester.close()
also closed everything that had been created by the tester (i.e. admin, producer, consumer). Having the tester check what it created and then ensure they're all correctly disposed of on close makes the most sense to me.
c08f149
to
53183c0
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Type of change
Description
Fix Kafka Client leaks in the
SampleFilterIntegrationTest
. Closing the test doesn't close the admin/consumer/producersthat it created.
Additional Context
Why are you making this pull request?
Checklist
Please go through this checklist and make sure all applicable tasks have been done