guluo created HBASE-29865:
-----------------------------

             Summary: Add a new `waitFor` method to the `Waiter` test class to 
support delayed condition check
                 Key: HBASE-29865
                 URL: https://issues.apache.org/jira/browse/HBASE-29865
             Project: HBase
          Issue Type: Improvement
          Components: test
            Reporter: guluo


The test class Waiter.waitFor method allows us to wait for a specific time for 
a given condition to be met. 
For example, after submitting a task, we can wait use the code:
TEST_UTIL.waitFor(5000, () -> proc.isSuccess() && proc.isBypass());

 
However, I notice that Waiter.waitFor method does not provide an overloaded 
method with an initial delay time before starting to check the condition,
which could be useful in some scenarios.
For example, after submitting a compact task, we would check if the compact 
task is complete, In the current version, we usually do this using the 
following code:
admin.majorCompact(tableName, CompactType.MOB);
try {
Thread.sleep(100);
} catch (InterruptedException e) {  
  // handle exception
}
TEST_UTIL.waitFor(TIMEOUT, () -> admin.getCompactionState(tableName, 
CompactType.MOB) == CompactionState.NONE);
assertEquals(CompactionState.NONE, admin.getCompactionState(tableName, 
CompactType.MOB));
 
If we introduce an overloaded method as described above, we could simplify the 
code to:
admin.majorCompact(tableName, CompactType.MOB);
TEST_UTIL.waitFor(TIMEOUT, DELAY_TIME, INTERVAL, () -> 
admin.getCompactionState(tableName, CompactType.MOB) == CompactionState.NONE);
assertEquals(CompactionState.NONE, admin.getCompactionState(tableName, 
CompactType.MOB));



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to