-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
test(kafka): Refactor integration tests #108
Conversation
697c857
to
acf0387
Compare
acf0387
to
88c0cc0
Compare
1b172fb
to
a693814
Compare
a693814
to
73dafe1
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.
Nice find and thanks for cleaning all this stuff up. Just some small questions.
name: Rebalance integration test | ||
runs-on: ubuntu-latest | ||
|
||
steps: |
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.
Do we need to do devservices up
again in this separate job?
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.
We don't because the makefile recipe for rebalance has build
and reset-kafka
as prerequisites.
test-rebalance: build reset-kafka
So when we do make test-rebalance
it will automatically do make build
and make reset-kafka
for us (which does a devservices up & down)
) | ||
update_topic_partitions(topic_name, num_partitions) | ||
# Ensure topic exists and has correct number of partitions | ||
create_topic(topic_name, num_partitions) |
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.
What happens if the topic already exists?
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 think this will print an error message and continue, but usually we run this with make test_rebalance
, it always clears the kafka container, because reset-kafka
is a prerequisite
Overview
to:
so that finding integration tests would be easier as we add more
5. Update the makefile recipe for the integration test so that they delete the test output later. This ensures that the output only gets cleaned up after the test returns with 0 exit code.
6. Increase minimum time before a consumer startup and it recieving a shutdown signal from 1 seconds to 4 seconds. For some reason, with a fresh kafka topic created using the python integration test. If a new consumer starts up and shuts down before a partition assignment, it will print a kafka broker error when shutting down. This trips the error output check in the integration test causing it to fail but no data is lost / double processed.
I would like to dive deeper to why this is happening and why it only happens when a topic is created in the python integration test, but I would like to unblock us first. Also, in a real prod environment, we never shut down our consumer that fast.Okay I figured it out, kafka has a setting calledgroup.initial.rebalance.delay.ms
(doc here), it controls how long to wait to respond to a consumerJoinGroupRequest
when a consumer group is created. Before, the unit tests already creates the task-worker consumer group, so when the integration test runs, there are no delays from the broker when the consumers are starting. But now, because we are recreating the kafka container from scratch, the broker waits when the consumers are sending theJoinGroupRequest
, and since our integration test can send shutdown signal in 1 second, we get the timeout error because the consumer is sending aLeaveGroupRequest
while the broker is still not responding to theJoinGroupRequest
from when it first starts, causing the timeout: