From e39806ea98f097eae1d3f95e9483c42ca79498cb Mon Sep 17 00:00:00 2001 From: yujun777 Date: Thu, 27 Jun 2024 11:15:35 +0800 Subject: [PATCH 1/4] make random replica diff bigger --- .../apache/doris/system/SystemInfoServiceTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java b/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java index 0ac72df4a6d3f6..c5e045622a250c 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java @@ -46,6 +46,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public class SystemInfoServiceTest { private SystemInfoService infoService; @@ -403,7 +404,7 @@ public void testSelectBackendIdsForReplicaCreation() throws Exception { ReplicaAllocation replicaAlloc = ReplicaAllocation.DEFAULT_ALLOCATION; // also check if the random selection logic can evenly distribute the replica. Map beCounterMap = Maps.newHashMap(); - for (int i = 0; i < 10000; ++i) { + for (int i = 0; i < 30000; ++i) { Pair>, TStorageMedium> ret = infoService.selectBackendIdsForReplicaCreation(replicaAlloc, Maps.newHashMap(), TStorageMedium.HDD, false, false); Map> res = ret.first; @@ -412,11 +413,15 @@ public void testSelectBackendIdsForReplicaCreation() throws Exception { beCounterMap.put(beId, beCounterMap.getOrDefault(beId, 0) + 1); } } + Set expectBackendIds = infoService.getMixBackends().stream() + .filter(be -> be.isAlive()).map(Backend::getId()) + .collect(Collectors.toSet()); + Assert.assertEquals(expectBackendIds, beCounterMap.keySet().stream().collect(Collectors.toSet())); List list = Lists.newArrayList(beCounterMap.values()); Collections.sort(list); int diff = list.get(list.size() - 1) - list.get(0); - // The max replica num and min replica num's diff is less than 5%. - Assert.assertTrue((diff * 1.0 / list.get(0)) < 0.05); + // The max replica num and min replica num's diff is less than 20%. + Assert.assertTrue((diff * 1.0 / list.get(0)) < 0.2); } private void addDisk(Backend be, String path, TStorageMedium medium, long totalB, long availB) { From 31f7e9ee7ff58ea3e79d07c13908164435bf37cf Mon Sep 17 00:00:00 2001 From: yujun777 Date: Thu, 27 Jun 2024 11:17:10 +0800 Subject: [PATCH 2/4] update --- .../java/org/apache/doris/system/SystemInfoServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java b/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java index c5e045622a250c..9a0e5c0fb03390 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java @@ -414,7 +414,7 @@ public void testSelectBackendIdsForReplicaCreation() throws Exception { } } Set expectBackendIds = infoService.getMixBackends().stream() - .filter(be -> be.isAlive()).map(Backend::getId()) + .filter(Backend::isAlive).map(Backend::getId) .collect(Collectors.toSet()); Assert.assertEquals(expectBackendIds, beCounterMap.keySet().stream().collect(Collectors.toSet())); List list = Lists.newArrayList(beCounterMap.values()); From 37dbab54fb815b30cb1194949b8421d82571fb53 Mon Sep 17 00:00:00 2001 From: yujun777 Date: Thu, 27 Jun 2024 12:38:37 +0800 Subject: [PATCH 3/4] update --- .../java/org/apache/doris/system/SystemInfoServiceTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java b/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java index 9a0e5c0fb03390..faf3777faaa989 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java @@ -46,6 +46,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; public class SystemInfoServiceTest { @@ -419,9 +420,10 @@ public void testSelectBackendIdsForReplicaCreation() throws Exception { Assert.assertEquals(expectBackendIds, beCounterMap.keySet().stream().collect(Collectors.toSet())); List list = Lists.newArrayList(beCounterMap.values()); Collections.sort(list); - int diff = list.get(list.size() - 1) - list.get(0); + int max = list.get(list.size() - 1); + int diff = max - list.get(0); // The max replica num and min replica num's diff is less than 20%. - Assert.assertTrue((diff * 1.0 / list.get(0)) < 0.2); + Assert.assertTrue((diff * 1.0 / max) < 0.2); } private void addDisk(Backend be, String path, TStorageMedium medium, long totalB, long availB) { From c0f632b01bf80504d986f605b6c4620f4d26b8ea Mon Sep 17 00:00:00 2001 From: yujun777 Date: Thu, 27 Jun 2024 14:05:05 +0800 Subject: [PATCH 4/4] update --- .../java/org/apache/doris/system/SystemInfoServiceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java b/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java index faf3777faaa989..b36f4b2a8156e9 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/system/SystemInfoServiceTest.java @@ -422,8 +422,8 @@ public void testSelectBackendIdsForReplicaCreation() throws Exception { Collections.sort(list); int max = list.get(list.size() - 1); int diff = max - list.get(0); - // The max replica num and min replica num's diff is less than 20%. - Assert.assertTrue((diff * 1.0 / max) < 0.2); + // The max replica num and min replica num's diff is less than 30%. + Assert.assertTrue((diff * 1.0 / max) < 0.3); } private void addDisk(Backend be, String path, TStorageMedium medium, long totalB, long availB) {