Skip to content
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(s3stream): Unit tests for TrafficRateLimiter #2383

Merged
merged 1 commit into from
Apr 9, 2025

Conversation

TwoOnefour
Copy link
Contributor

@TwoOnefour TwoOnefour commented Mar 26, 2025

@TwoOnefour TwoOnefour changed the title test(s3stream): Unit tests for TrafficRateLimiter (#2365) test(s3stream): Unit tests for TrafficRateLimiter Mar 26, 2025
@Chillax-0v0 Chillax-0v0 linked an issue Mar 27, 2025 that may be closed by this pull request
@Chillax-0v0 Chillax-0v0 requested a review from Copilot March 27, 2025 08:30
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds unit tests for the TrafficRateLimiter class to verify its rate update and consumption behaviors.

  • Introduces a test to check boundary conditions in currentRate updates.
  • Adds a test to ensure that consuming traffic respects the set rate limit and timing constraints.
Comments suppressed due to low confidence (2)

s3stream/src/test/java/com/automq/stream/s3/operator/TrafficRateLimiterTest.java:56

  • Consider moving the consumeStarted.countDown() call to immediately after starting the consume method (before joining on its completion) to better ensure that the update(0) call occurs while consumption is still in progress, thereby testing concurrent behavior more accurately.
consumeStarted.countDown();

s3stream/src/test/java/com/automq/stream/s3/operator/TrafficRateLimiterTest.java:68

  • [nitpick] Consider revising the fixed 5-second threshold to account for potential variability in execution timing (e.g., by using a more flexible condition or providing additional context), in order to reduce the risk of test flakiness under varying system loads.
assertTrue(duration / 1000 <= 5);

@TwoOnefour TwoOnefour force-pushed the main branch 3 times, most recently from 8e55abe to a8a6c70 Compare April 9, 2025 06:33
@Chillax-0v0
Copy link
Contributor

@TwoOnefour Please ensure that checkstyle passes locally and submit all your code changes in one batch, rather than making incremental adjustments piece by piece.

@TwoOnefour
Copy link
Contributor Author

@TwoOnefour Please ensure that checkstyle passes locally and submit all your code changes in one batch, rather than making incremental adjustments piece by piece.

sry, I will handler it carefully.

@TwoOnefour
Copy link
Contributor Author

@Chillax-0v0
Since code have passed all checks, it's ready to be reviewed at this time. If there is any mistake, please inform me in this pr, thanks.

Copy link
Contributor

@Chillax-0v0 Chillax-0v0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Chillax-0v0 Chillax-0v0 merged commit 9c29b53 into AutoMQ:main Apr 9, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Good First Issue] Write Unit Tests for TrafficRateLimiter
2 participants