pandaapo opened a new issue, #3887: URL: https://github.com/apache/eventmesh/issues/3887
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/eventmesh/issues?q=is%3Aissue) and found no similar issues. ### Enhancement Request **org.apache.eventmesh.common.loadbalance.RandomLoadBalanceSelectorTest** ``` { ...... // just assert success if no exception Assert.assertTrue(true); } ``` This method of verifying no exception thrown is not appropriate. **org.apache.eventmesh.common.loadbalance.WeightRandomLoadBalanceSelectorTest** ``` // testRange = 100000 Assert.assertTrue(Math.abs(addressToNum.get("192.168.0.3") - addressToNum.get("192.168.0.2") * 2) < testRange / 20); Assert.assertTrue(Math.abs(addressToNum.get("192.168.0.3") - addressToNum.get("192.168.0.1") * 4) < testRange / 20); ``` [bug]: Map `addressToNum` is the result of weighted random selection for 100000 times. Key is a address and value is times. The weight of "192.168.0.3":"192.168.0.2":"192.168.0.1" is 4:2:1. So `addressToNum.get("192.168.0.3")` should ≈ `addressToNum.get("192.168.0.2") * 2`. Three cases, pairwise verification should be conducted, otherwise the verification is insufficient. In java 9 and later version, Reflection access private field is regard as illegal reflective access operation. It cause warning, even exception according to VM options. **org.apache.eventmesh.common.loadbalance.WeightRoundRobinLoadBalanceSelectorTest** The capacity of Map in `#testSelect()` is definite. ### Describe the solution you'd like **org.apache.eventmesh.common.loadbalance.RandomLoadBalanceSelectorTest** Use `Assert.fail()` **org.apache.eventmesh.common.loadbalance.WeightRandomLoadBalanceSelectorTest** [bug]: Set the error rate to 0.05 instead of 5000(=100000/20). Verify "192.168.0.2" : "192.168.0.2":"192.168.0.1". User getter access private field. **org.apache.eventmesh.common.loadbalance.WeightRoundRobinLoadBalanceSelectorTest** Init map with a specified capacity. ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
