From 0499e98d865d6437a8deced5e8dd8e023d7ecbc4 Mon Sep 17 00:00:00 2001 From: Felix GV Date: Wed, 18 Dec 2024 11:31:02 -0800 Subject: [PATCH] Flaky unit test tweaks (unrelated to this change). --- .../venice/router/api/TestVeniceDelegateMode.java | 11 ++++++++--- .../stats/AggServerReadQuotaUsageStatsTest.java | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/services/venice-router/src/test/java/com/linkedin/venice/router/api/TestVeniceDelegateMode.java b/services/venice-router/src/test/java/com/linkedin/venice/router/api/TestVeniceDelegateMode.java index 3669622691..481d493cdc 100644 --- a/services/venice-router/src/test/java/com/linkedin/venice/router/api/TestVeniceDelegateMode.java +++ b/services/venice-router/src/test/java/com/linkedin/venice/router/api/TestVeniceDelegateMode.java @@ -2,7 +2,7 @@ import static com.linkedin.venice.router.api.VeniceMultiKeyRoutingStrategy.HELIX_ASSISTED_ROUTING; import static com.linkedin.venice.router.api.VeniceMultiKeyRoutingStrategy.LEAST_LOADED_ROUTING; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.atLeastOnce; @@ -14,6 +14,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.testng.Assert.assertEquals; import com.linkedin.alpini.base.concurrency.TimeoutProcessor; import com.linkedin.alpini.router.api.HostFinder; @@ -723,7 +724,9 @@ public void testScatterForMultiGetWithHelixAssistedRouting() throws RouterExcept .assertEquals(request.getHosts().size(), 1, "There should be only one host for each request")); Set instanceSet = new HashSet<>(); requests.stream().forEach(request -> instanceSet.add(request.getHosts().get(0))); - Assert.assertTrue(instanceSet.contains(instance1) && instanceSet.contains(instance2)); + assertEquals(instanceSet.size(), 2, "The instanceSet does not have two entries: " + instanceSet); + Assert.assertTrue(instanceSet.contains(instance1), "instance1 is missing from the instanceSet: " + instanceSet); + Assert.assertTrue(instanceSet.contains(instance2), "instance2 is missing from the instanceSet: " + instanceSet); // The second request should pick up another group scatter = new Scatter(path, getPathParser(), VeniceRole.REPLICA); @@ -740,7 +743,9 @@ public void testScatterForMultiGetWithHelixAssistedRouting() throws RouterExcept .assertEquals(request.getHosts().size(), 1, "There should be only one host for each request")); instanceSet.clear(); requests.stream().forEach(request -> instanceSet.add(request.getHosts().get(0))); - Assert.assertTrue(instanceSet.contains(instance1) && instanceSet.contains(instance2)); + assertEquals(instanceSet.size(), 2, "The instanceSet does not have two entries: " + instanceSet); + Assert.assertTrue(instanceSet.contains(instance1), "instance1 is missing from the instanceSet: " + instanceSet); + Assert.assertTrue(instanceSet.contains(instance2), "instance2 is missing from the instanceSet: " + instanceSet); // Test the scenario that all the replicas for a given partition are slow // for partition 1, both instance1 and instance3 are slow diff --git a/services/venice-server/src/test/java/com/linkedin/venice/stats/AggServerReadQuotaUsageStatsTest.java b/services/venice-server/src/test/java/com/linkedin/venice/stats/AggServerReadQuotaUsageStatsTest.java index 3745e200eb..d14f07413f 100644 --- a/services/venice-server/src/test/java/com/linkedin/venice/stats/AggServerReadQuotaUsageStatsTest.java +++ b/services/venice-server/src/test/java/com/linkedin/venice/stats/AggServerReadQuotaUsageStatsTest.java @@ -50,7 +50,7 @@ public void testAggServerQuotaUsageStats() { double totalQPS = 4d / 30d; double totalKPS = (batchSize2 + batchSize * 3) / 30d; Assert.assertEquals(metricsRepository.getMetric(totalReadQuotaRequestedQPSString).value(), totalQPS, 0.05); - Assert.assertEquals(metricsRepository.getMetric(totalReadQuotaRequestedKPSString).value(), totalKPS, 0.05); + Assert.assertEquals(metricsRepository.getMetric(totalReadQuotaRequestedKPSString).value(), totalKPS, 0.1); Assert.assertEquals(metricsRepository.getMetric(quotaUsageRatio).value(), (200d / 30d) / 200d, 0.01); String readQuotaRejectedQPSString = "." + storeName + "--quota_rejected_request.Rate";