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

smengcl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 756f714588f HDDS-15648. Improve 
TestSnapshotDiffManager#testThreadPoolIsFull drain scenario (#10632)
756f714588f is described below

commit 756f714588f61efc03954e198d7dbfa41ee21fed
Author: Neo Chien <[email protected]>
AuthorDate: Fri Jul 10 10:50:21 2026 +0800

    HDDS-15648. Improve TestSnapshotDiffManager#testThreadPoolIsFull drain 
scenario (#10632)
---
 .../ozone/om/snapshot/TestSnapshotDiffManager.java | 33 +++++++++++++---------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotDiffManager.java
 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotDiffManager.java
index 5b1039b165d..11a9a14446f 100644
--- 
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotDiffManager.java
+++ 
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestSnapshotDiffManager.java
@@ -1195,29 +1195,36 @@ public void testThreadPoolIsFull(String description,
         eq(VOLUME_NAME), eq(BUCKET_NAME), anyString(), anyString(),
         eq(false), eq(false));
 
-    if (drainBetweenBatches) {
-      blockWorkers.countDown();
-    }
-
     try {
       List<SnapshotDiffResponse> responses = new ArrayList<>();
       int totalSubmitted = 0;
+      int fullThreadPoolSize = 2 * 
OZONE_OM_SNAPSHOT_DIFF_THREAD_POOL_SIZE_DEFAULT;
+      boolean latchOpened = false;
+
       for (int i = 0; i < snapshotInfos.size(); i++) {
         for (int j = i + 1; j < snapshotInfos.size(); j++) {
           String fromSnapshotName = snapshotInfos.get(i).getName();
           String toSnapshotName = snapshotInfos.get(j).getName();
+
+          if (drainBetweenBatches && !latchOpened &&
+              totalSubmitted >= fullThreadPoolSize) {
+            blockWorkers.countDown();
+            latchOpened = true;
+          }
+
+          if (drainBetweenBatches && latchOpened) {
+            final int currentlySubmitted = totalSubmitted;
+            attempt(() -> {
+              if (currentlySubmitted - completedJobs.get() >= 
fullThreadPoolSize) {
+                throw new RuntimeException("Thread pool is still full");
+              }
+              return null;
+            }, 10000, TimeDuration.valueOf(1, TimeUnit.MILLISECONDS), null, 
null);
+          }
+
           responses.add(submitJob(spy, fromSnapshotName, toSnapshotName));
           totalSubmitted++;
         }
-        if (drainBetweenBatches) {
-          final int expected = totalSubmitted;
-          attempt(() -> {
-            if (completedJobs.get() < expected) {
-              throw new IllegalStateException("Waiting for jobs to complete");
-            }
-            return null;
-          }, 50, TimeDuration.valueOf(100, TimeUnit.MILLISECONDS), null, null);
-        }
       }
 
       int inProgressJobsCount = 0;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to