[
https://issues.apache.org/jira/browse/HBASE-29865?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18055926#comment-18055926
]
Xiao Liu edited comment on HBASE-29865 at 2/2/26 1:44 PM:
----------------------------------------------------------
Hi, [~guluo], thanks for your reply, some new UTs in our codebase seems to
start use Awaitility now.
was (Author: JIRAUSER299414):
Hi, [~guluo], thanks for your reply, some new UTs in our codebase seems to
start Awaitility now.
> 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
> Priority: Major
>
> 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)