[test] add RoundRobinLoadBalancer tests for selection logic and distribution#6093
Merged
loongs-zhang merged 5 commits intoapache:masterfrom Aug 13, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves the RoundRobinLoadBalanceTest by adding meaningful assertions to verify load balancer functionality. The existing test method only invoked the select method without any verification, making it ineffective for catching bugs.
Key changes:
- Add assertions to verify selected upstreams are not null and from the provided list
- Add round-robin distribution testing with equal weights to verify balanced selection
- Import additional assertion methods for comprehensive testing
...loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/spi/RoundRobinLoadBalanceTest.java
Outdated
Show resolved
Hide resolved
...loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/spi/RoundRobinLoadBalanceTest.java
Show resolved
Hide resolved
- Introduce SELECTION_ITERATIONS constant to replace magic number 30 - Update test to use the new constant for better readability and maintainability
loongs-zhang
approved these changes
Aug 13, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The roundRobinLoadBalanceTest method only calls the methods but contains no assertions, making it an ineffective test.
Fix:Add proper assertions to verify
Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.