-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add Support for Clients #113
Conversation
Signed-off-by: see-quick <maros.orsak159@gmail.com> # Conflicts: # src/main/java/io/strimzi/test/container/StrimziKafkaContainer.java
Signed-off-by: see-quick <maros.orsak159@gmail.com>
Signed-off-by: see-quick <maros.orsak159@gmail.com>
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, I left a few comments
src/main/java/io/strimzi/test/container/StrimziConsumerContainer.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/test/container/StrimziProducerContainer.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/test/container/StrimziProducerContainer.java
Outdated
Show resolved
Hide resolved
src/test/java/io/strimzi/test/container/StrimziProducerConsumerContainerKRaftIT.java
Show resolved
Hide resolved
src/test/java/io/strimzi/test/container/StrimziProducerConsumerContainerKRaftIT.java
Outdated
Show resolved
Hide resolved
consumerContainer.start(); | ||
|
||
// Wait for the consumer to receive the message | ||
Utils.waitFor("Consumer receives message", Duration.ofSeconds(1).toMillis(), Duration.ofSeconds(20).toMillis(), |
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.
Not directly related to this PR but Utils.waitFor()
should accept Duration
arguments and convert those into the unit it needs internally. Otherwise calling it is really cumbersome. I find Duration.ofSeconds(1).toMillis()
less readable than 1000
.
src/test/java/io/strimzi/test/container/StrimziProducerConsumerContainerKRaftIT.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/test/container/StrimziConsumerContainer.java
Outdated
Show resolved
Hide resolved
Can you elaborate on the value of this? |
Signed-off-by: see-quick <maros.orsak159@gmail.com>
API-wise I wonder if it's worth supporting all the flags from the console producer and consumer. Some of the flags enable special behavior but many of them are just proxy for setting a configuration. Instead of all these configuration methods, maybe just supporting providing a Overall the proposed API will be helpful for testing the metrics reporter. It might be worth checking with other component owners (I'm thinking of strimzi-kafka-oauth in particular which should have similar testing requirements) whether this satisfy their needs. |
Aren't the official Kafka clients in Java using exactly this? What is then the benefit of supporting the Kafka scripts, which can change with each new version of the Kafka? I mean, you have there the Or do you think that the
I'm not familiar with the use-case of this in the metrics reporter (sorry about that) so maybe this will be a dumb question, but you will use it for testing of some clients' related metrics? |
Let me start by explaining my requirements, so you can advise me on the best options. The So far I've added integration tests for brokers using Now I would like to do something similar for the client side. To do so I need to start a Kafka cluster, and clients. Unfortunately this is not something I can do today with I believe this requirement is not unique to Ideally I'd like to avoid all of that and write the whole integration test suite of |
@Frawless added some tests using the Kafka cluster with usage of I mean, I'm not against implementing this, if it is really needed and I just don't see the use-case. But what I see is that:
These are just few things that came to my mind. And with the test-clients images, I think it's not a big issue to use them directly in the particular repository with usage of the basic TestContainers (where you will add the image and other configuration), if it is really needed -> as we can see in the case of the Apicurio in our test-clients ITs, @Frawless added the TestContainer for that without big issues (but correct me if I'm wrong Jakub). |
@mimaison I think this is a very hacky way for using test containers. I wonder ... what prevents you from using the clients from the test directly? Don't they have the metrics reporter on the classpath? If not, I think having a dedicated system test suite for this that simply does this on its own might be better? |
My main concern with this approach is that the metrics reporter opens a port. Running the client in a container is way nicer than requiring the host that is running tests to have specific ports available. In unit tests we can use 0 as the port to dynamically pick a suitable port and use a getter exposed for tests to find the actual value. However when running the reporter in a client, if we use 0 we'd have to parse the client logs to find the actual value. In these tests, I consider the client to be part of the environment. The actual test, the code that retrieves and checks the metrics, runs directly in the test and not in a container. You're right that this may look like system tests. All the target environments are so simple with either one broker, or one broker and one client (we could probably not even require the broker to check client metrics) that standing it all in containers in Java is attractive. |
Closing this, as we discovered that using |
This PR adds support for Kafka clients inside our test container ecosystem. Specifically producer and consumer.