You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2023/05/26 07:03:06 UTC
[shardingsphere] branch master updated: Refactor : refactor the sleep to awaitility (#25907)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 4b40617fb2b Refactor : refactor the sleep to awaitility (#25907)
4b40617fb2b is described below
commit 4b40617fb2b6411efd251aaa0f370f0907e11165
Author: 孙念君 Nianjun Sun <su...@apache.org>
AuthorDate: Fri May 26 15:02:51 2023 +0800
Refactor : refactor the sleep to awaitility (#25907)
* Refactor : refactor the sleep to awaitility
* Refactor : remove useless throwable Exception
* Add : add greatertimeout than poll delay
---
.../test/e2e/agent/common/AgentTestActionExtension.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/AgentTestActionExtension.java b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/AgentTestActionExtension.java
index e8cdb037406..ee661ef48f8 100644
--- a/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/AgentTestActionExtension.java
+++ b/test/e2e/agent/plugins/common/src/test/java/org/apache/shardingsphere/test/e2e/agent/common/AgentTestActionExtension.java
@@ -25,9 +25,11 @@ import org.apache.shardingsphere.test.e2e.agent.common.util.JDBCAgentTestUtils;
import org.apache.shardingsphere.test.e2e.agent.common.util.OkHttpUtils;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
import javax.sql.DataSource;
import java.io.IOException;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -95,12 +97,11 @@ public final class AgentTestActionExtension implements BeforeEachCallback {
OkHttpUtils.getInstance().get(String.join("", baseUrl, dropTableUrl));
}
- @SneakyThrows(InterruptedException.class)
private void sleep() {
if (!hasSleep) {
log.info("Waiting to collect data ...");
hasSleep = true;
- TimeUnit.MILLISECONDS.sleep(getSleepMilliseconds());
+ Awaitility.waitAtMost(Duration.ofMinutes(1)).await().pollDelay(getSleepMilliseconds(), TimeUnit.MILLISECONDS).until(() -> true);
}
}