-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[chore] internal/kafka: introduce kafkatest package #38882
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
Conversation
This package will hold test-related code for Kafka components. Initially is provides a single function for creating a fake Kafka cluster using franz-go's kfake, along with a configkafka ClientConfig for connecting to it. We use this in new tests for NewSaramaClient.
internal/kafka/client_test.go
Outdated
func init() { | ||
// Disable the go-metrics registry, as there's a goroutine | ||
// leak in the Sarama code that uses it. | ||
metrics.UseNilMetrics = true | ||
} |
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 am never a big fan of seeing init statements, is there a way that this could be raised as in issue in the upstream repo to address the leak of the go routine?
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.
Once we have the issue created, can you comment it here so we can follow up later on?
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.
There was an issue, it went stale: IBM/sarama#1321
My fix would be to swap to franz-go ;)
I'll see if we can work around the bug another 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.
P.S. this is also the documented by Sarama as the way to disable metrics: https://github.com/IBM/sarama/blob/d6ca80a198c4fbc467c67f7430182eda6881b12c/config.go#L513
So I thought it made sense for the tests, but not non-test code because that might inadvertently disable metrics in other components.
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.
The suggestion in IBM/sarama#1321 (comment) to explicitly unregister metrics doesn't help. I can't see a better alternative.
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.
Mm, I'd still like a reference in the comment to the issue so I can come back to it once I get some free time.
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.
👍 added a comment
…8882) #### Description This package will hold test-related code for Kafka components. Initially, the package provides a single function for creating a fake Kafka cluster using franz-go's kfake, along with a configkafka.ClientConfig for connecting to it. We use this in new tests for NewSaramaClient. #### Link to tracking issue N/A #### Testing N/A, only adding test code. #### Documentation N/A
Description
This package will hold test-related code for Kafka components.
Initially, the package provides a single function for creating a fake Kafka cluster using franz-go's kfake, along with a configkafka.ClientConfig for connecting to it. We use this in new tests for NewSaramaClient.
Link to tracking issue
N/A
Testing
N/A, only adding test code.
Documentation
N/A