This is an automated email from the ASF dual-hosted git repository.
hello-stephen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new c6039bb4a01 [fix](fe) Prevent random host selection from hanging FE
unit tests (#69138)
c6039bb4a01 is described below
commit c6039bb4a01c6f0b4ed8a2089908697551899647
Author: Socrates <[email protected]>
AuthorDate: Fri Oct 16 10:00:04 2026 +0800
[fix](fe) Prevent random host selection from hanging FE unit tests (#69138)
Problem Summary: The randomized FederationBackendPolicy tests can
generate one backend but request two distinct local hosts. The sampling
loop then never terminates, leaving FE UT running indefinitely.
Cap the host count by the available backend count in both tests. Run
each with 1, 2, and 99 backends to cover the single-backend boundary on
every execution while preserving the split-assignment assertions.
---
.../doris/planner/FederationBackendPolicyTest.java | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/planner/FederationBackendPolicyTest.java
b/fe/fe-core/src/test/java/org/apache/doris/planner/FederationBackendPolicyTest.java
index de51e607f47..a7d92cc14b3 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/planner/FederationBackendPolicyTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/planner/FederationBackendPolicyTest.java
@@ -36,6 +36,8 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -378,15 +380,15 @@ public class FederationBackendPolicyTest {
});
}
- @Test
- public void testGenerateRandomly() throws UserException {
+ @ParameterizedTest
+ @ValueSource(ints = {1, 2, 99})
+ public void testGenerateRandomly(int backendNum) throws UserException {
SystemInfoService service = new SystemInfoService();
ComputeGroupMgr cgmgr = new ComputeGroupMgr(service);
mockedEnvStatic.when(Env::getCurrentSystemInfo).thenReturn(service);
Mockito.when(env.getComputeGroupMgr()).thenReturn(cgmgr);
Random random = new Random();
- int backendNum = random.nextInt(100 - 1) + 1;
int minOctet3 = 0;
int maxOctet3 = 250;
@@ -424,7 +426,8 @@ public class FederationBackendPolicyTest {
int localSplitCount = random.nextInt(1000 - 100) + 100;
Set<String> totalLocalHosts = new HashSet<>();
for (int i = 0; i < localSplitCount; ++i) {
- int localHostNum = random.nextInt(3 - 1) + 1;
+ // A single backend cannot supply two distinct local hosts.
+ int localHostNum = random.nextInt(Math.min(2, backendNum)) + 1;
Set<String> localHosts = new HashSet<>();
String localHost;
List<Backend> backends =
service.getAllBackendsByAllCluster().values().asList();
@@ -488,15 +491,15 @@ public class FederationBackendPolicyTest {
}
}
- @Test
- public void testNonAliveNodes() throws UserException {
+ @ParameterizedTest
+ @ValueSource(ints = {1, 2, 99})
+ public void testNonAliveNodes(int backendNum) throws UserException {
SystemInfoService service = new SystemInfoService();
ComputeGroupMgr cgmgr = new ComputeGroupMgr(service);
mockedEnvStatic.when(Env::getCurrentSystemInfo).thenReturn(service);
Mockito.when(env.getComputeGroupMgr()).thenReturn(cgmgr);
Random random = new Random();
- int backendNum = random.nextInt(100 - 1) + 1;
int minOctet3 = 0;
int maxOctet3 = 250;
@@ -540,7 +543,8 @@ public class FederationBackendPolicyTest {
int localSplitCount = random.nextInt(1000 - 100) + 100;
Set<String> totalLocalHosts = new HashSet<>();
for (int i = 0; i < localSplitCount; ++i) {
- int localHostNum = random.nextInt(3 - 1) + 1;
+ // A single backend cannot supply two distinct local hosts.
+ int localHostNum = random.nextInt(Math.min(2, backendNum)) + 1;
Set<String> localHosts = new HashSet<>();
String localHost;
List<Backend> backends =
service.getAllBackendsByAllCluster().values().asList();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]