This is an automated email from the ASF dual-hosted git repository.

ckj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git


The following commit(s) were added to refs/heads/master by this push:
     new c8f8292c Fix flaky test QuotaManagerTest#testDetectUserResource (#421)
c8f8292c is described below

commit c8f8292ce03d4a0f481759d79e404a3324869612
Author: xianjingfeng <[email protected]>
AuthorDate: Thu Dec 15 13:05:24 2022 +0800

    Fix flaky test QuotaManagerTest#testDetectUserResource (#421)
    
    ### What changes were proposed in this pull request?
    
    Fix flaky test QuotaManagerTest#testDetectUserResource
    
    ### Why are the changes needed?
    
    The process of parsing quota file is asynchronous.
    
https://github.com/apache/incubator-uniffle/actions/runs/3695326069/jobs/6257565865
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    Manually, by pepeating 1000 times.
---
 .../java/org/apache/uniffle/coordinator/QuotaManagerTest.java | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git 
a/coordinator/src/test/java/org/apache/uniffle/coordinator/QuotaManagerTest.java
 
b/coordinator/src/test/java/org/apache/uniffle/coordinator/QuotaManagerTest.java
index 52679692..734e8d32 100644
--- 
a/coordinator/src/test/java/org/apache/uniffle/coordinator/QuotaManagerTest.java
+++ 
b/coordinator/src/test/java/org/apache/uniffle/coordinator/QuotaManagerTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import com.google.common.collect.Lists;
@@ -29,9 +30,11 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
+import org.awaitility.Awaitility;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.junit.jupiter.api.io.TempDir;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -59,7 +62,8 @@ public class QuotaManagerTest {
   public static void clear() {
     cluster.close();
   }
-
+  
+  @Timeout(value = 10)
   @Test
   public void testDetectUserResource() throws Exception {
     final String quotaFile =
@@ -80,8 +84,9 @@ public class QuotaManagerTest {
     conf.set(CoordinatorConf.COORDINATOR_QUOTA_DEFAULT_PATH,
         quotaFile);
     ApplicationManager applicationManager = new ApplicationManager(conf);
-    Thread.sleep(500);
-
+    Awaitility.await().timeout(5, TimeUnit.SECONDS).until(
+        () -> applicationManager.getDefaultUserApps().size() > 0);
+    
     Integer user1 = applicationManager.getDefaultUserApps().get("user1");
     Integer user2 = applicationManager.getDefaultUserApps().get("user2");
     Integer user3 = applicationManager.getDefaultUserApps().get("user3");

Reply via email to