-
Notifications
You must be signed in to change notification settings - Fork 934
Add more async consumer unit & integration tests #2052
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
74bb1b9
basic rebalance test
fangnx 2a891ef
rebalance tests
fangnx 72c60dd
refactor and linter fix
fangnx a276173
feebdack
fangnx c080212
merge resolved
fangnx 07ff1c3
refactor and cleanup
fangnx 1d8bf25
update
fangnx 008a128
Merge branch 'async' into consumer-more-tests
fangnx 7c9410d
remove jit imports
fangnx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ def verify_connection(self): | |
list(metadata.topics.keys())) | ||
return True | ||
except Exception as e: | ||
self.logger.error("Failed to connect to Kafka at %s: %s", self.bootstrap_servers_str, e) | ||
self.logger.error("Failed to connect to Kafka: %s", e) | ||
return False | ||
|
||
def create_topic(self, topic, partitions=1, replication_factor=1): | ||
|
@@ -124,3 +124,30 @@ def wait_for_topic(self, topic_name, max_wait_time=30, initial_wait=0.1): | |
|
||
self.logger.error("Timeout waiting for topic '%s' after %ds", topic_name, max_wait_time) | ||
return False | ||
|
||
def add_partitions(self, topic_name, new_partition_count): | ||
"""Add partitions to an existing topic""" | ||
try: | ||
from confluent_kafka.admin import AdminClient, NewPartitions | ||
|
||
admin_client = AdminClient({'bootstrap.servers': self.bootstrap_servers_str}) | ||
metadata = admin_client.list_topics(timeout=10) | ||
|
||
|
||
if topic_name not in metadata.topics: | ||
raise ValueError(f"Topic {topic_name} does not exist") | ||
|
||
current_partitions = len(metadata.topics[topic_name].partitions) | ||
if new_partition_count <= current_partitions: | ||
return # No change needed | ||
|
||
# Add partitions | ||
new_partitions = NewPartitions(topic=topic_name, new_total_count=new_partition_count) | ||
fs = admin_client.create_partitions([new_partitions]) | ||
|
||
# Wait for completion | ||
for topic, f in fs.items(): | ||
f.result(timeout=30) | ||
|
||
except Exception as e: | ||
self.logger.error("Failed to add partitions to topic %s: %s", topic_name, e) | ||
raise |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
move imports to top, no need for JIT here