You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2023/05/21 06:20:58 UTC

[shardingsphere] branch master updated: Fix sonar issues on Remove this use of "Thread.sleep()". (#25816)

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

panjuan 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 80a7e2a86e8 Fix sonar issues on Remove this use of "Thread.sleep()". (#25816)
80a7e2a86e8 is described below

commit 80a7e2a86e88aa0d31da291fc6d67aa4b4548970
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun May 21 14:20:50 2023 +0800

    Fix sonar issues on Remove this use of "Thread.sleep()". (#25816)
---
 .../e2e/env/container/atomic/ITContainers.java     |  8 +++-----
 .../pipeline/cases/PipelineContainerComposer.java  | 23 ++++++++--------------
 .../classictransfer/ClassicTransferTestCase.java   |  8 +++++---
 .../engine/base/TransactionBaseE2EIT.java          | 17 +++++++---------
 .../test/e2e/engine/type/DDLE2EIT.java             |  6 +++---
 .../test/e2e/engine/type/RALE2EIT.java             | 14 +++++--------
 .../test/e2e/engine/type/RDLE2EIT.java             | 16 ++++++---------
 7 files changed, 37 insertions(+), 55 deletions(-)

diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java
index 7371e609bb2..ed641442ffd 100644
--- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java
+++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java
@@ -24,10 +24,12 @@ import org.slf4j.LoggerFactory;
 import org.testcontainers.containers.Network;
 import org.testcontainers.containers.output.Slf4jLogConsumer;
 import org.testcontainers.lifecycle.Startable;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
+import java.util.concurrent.TimeUnit;
 
 /**
  * IT containers.
@@ -99,11 +101,7 @@ public final class ITContainers implements Startable {
                 })
                 .forEach(each -> {
                     while (!(each.isRunning() && each.isHealthy())) {
-                        try {
-                            Thread.sleep(500L);
-                        } catch (final InterruptedException ignored) {
-                            Thread.currentThread().interrupt();
-                        }
+                        Awaitility.await().pollDelay(500L, TimeUnit.MILLISECONDS).until(() -> true);
                     }
                 });
     }
diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java
index 8e1487972cc..83bc0b6f8fa 100644
--- a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java
@@ -166,25 +166,23 @@ public final class PipelineContainerComposer implements AutoCloseable {
         }
     }
     
-    @SneakyThrows(InterruptedException.class)
     private void cleanUpProxyDatabase(final Connection connection) {
         if (PipelineEnvTypeEnum.NATIVE != PipelineE2EEnvironment.getInstance().getItEnvType()) {
             return;
         }
         try {
             connection.createStatement().execute(String.format("DROP DATABASE IF EXISTS %s", PROXY_DATABASE));
-            Thread.sleep(2000L);
+            Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
         } catch (final SQLException ex) {
             log.warn("Drop proxy database failed, error={}", ex.getMessage());
         }
     }
     
-    @SneakyThrows(InterruptedException.class)
     private void createProxyDatabase(final Connection connection) throws SQLException {
         String sql = String.format("CREATE DATABASE %s", PROXY_DATABASE);
         log.info("Create proxy database {}", PROXY_DATABASE);
         connection.createStatement().execute(sql);
-        Thread.sleep(2000L);
+        Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
     }
     
     private void cleanUpDataSource() {
@@ -273,14 +271,13 @@ public final class PipelineContainerComposer implements AutoCloseable {
      * @param sleepSeconds sleep seconds
      * @throws SQLException SQL exception
      */
-    @SneakyThrows(InterruptedException.class)
     public void createSchema(final Connection connection, final int sleepSeconds) throws SQLException {
         if (!getDatabaseType().isSchemaAvailable()) {
             return;
         }
         connection.createStatement().execute(String.format("CREATE SCHEMA %s", SCHEMA_NAME));
         if (sleepSeconds > 0) {
-            Thread.sleep(sleepSeconds * 1000L);
+            Awaitility.await().pollDelay(sleepSeconds, TimeUnit.SECONDS).until(() -> true);
         }
     }
     
@@ -349,13 +346,12 @@ public final class PipelineContainerComposer implements AutoCloseable {
      * @param sleepSeconds sleep seconds
      * @throws SQLException SQL exception
      */
-    @SneakyThrows(InterruptedException.class)
     public void proxyExecuteWithLog(final String sql, final int sleepSeconds) throws SQLException {
         log.info("proxy execute :{}", sql);
         try (Connection connection = proxyDataSource.getConnection()) {
             connection.createStatement().execute(sql);
         }
-        Thread.sleep(Math.max(sleepSeconds * 1000L, 0L));
+        Awaitility.await().pollDelay(Math.max(sleepSeconds, 0L), TimeUnit.SECONDS).until(() -> true);
     }
     
     /**
@@ -363,13 +359,12 @@ public final class PipelineContainerComposer implements AutoCloseable {
      *
      * @param distSQL dist SQL
      */
-    @SneakyThrows(InterruptedException.class)
     public void waitJobPrepareSuccess(final String distSQL) {
         for (int i = 0; i < 5; i++) {
             List<Map<String, Object>> jobStatus = queryForListWithLog(distSQL);
             Set<String> statusSet = jobStatus.stream().map(each -> String.valueOf(each.get("status"))).collect(Collectors.toSet());
             if (statusSet.contains(JobStatus.PREPARING.name()) || statusSet.contains(JobStatus.RUNNING.name())) {
-                Thread.sleep(2000L);
+                Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
             }
         }
     }
@@ -381,7 +376,6 @@ public final class PipelineContainerComposer implements AutoCloseable {
      * @return query result
      * @throws RuntimeException runtime exception
      */
-    @SneakyThrows(InterruptedException.class)
     public List<Map<String, Object>> queryForListWithLog(final String sql) {
         int retryNumber = 0;
         while (retryNumber <= 3) {
@@ -391,7 +385,7 @@ public final class PipelineContainerComposer implements AutoCloseable {
             } catch (final SQLException ex) {
                 log.error("Data access error.", ex);
             }
-            Thread.sleep(3000L);
+            Awaitility.await().pollDelay(3L, TimeUnit.SECONDS).until(() -> true);
             retryNumber++;
         }
         throw new RuntimeException("Can not get result from proxy.");
@@ -452,7 +446,7 @@ public final class PipelineContainerComposer implements AutoCloseable {
                 incrementalIdleSecondsList.add(Strings.isNullOrEmpty(incrementalIdleSeconds) ? 0 : Integer.parseInt(incrementalIdleSeconds));
             }
             if (Collections.min(incrementalIdleSecondsList) <= 5) {
-                Thread.sleep(3000L);
+                Awaitility.await().pollDelay(3L, TimeUnit.SECONDS).until(() -> true);
                 continue;
             }
             if (actualStatus.size() == 1 && actualStatus.contains(JobStatus.EXECUTE_INCREMENTAL_TASK.name())) {
@@ -483,7 +477,6 @@ public final class PipelineContainerComposer implements AutoCloseable {
      *
      * @param sql SQL
      */
-    @SneakyThrows(InterruptedException.class)
     public void assertProxyOrderRecordExist(final String sql) {
         boolean recordExist = false;
         for (int i = 0; i < 5; i++) {
@@ -492,7 +485,7 @@ public final class PipelineContainerComposer implements AutoCloseable {
             if (recordExist) {
                 break;
             }
-            Thread.sleep(2000L);
+            Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
         }
         assertTrue(recordExist, "The insert record must exist after the stop");
     }
diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/classictransfer/ClassicTransferTestCase.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/classictransfer/ClassicTransferTestCase.java
index dff24211760..8567c99996f 100644
--- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/classictransfer/ClassicTransferTestCase.java
+++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/classictransfer/ClassicTransferTestCase.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.test.e2e.transaction.cases.base.BaseTransaction
 import org.apache.shardingsphere.test.e2e.transaction.engine.base.TransactionBaseE2EIT;
 import org.apache.shardingsphere.test.e2e.transaction.engine.base.TransactionContainerComposer;
 import org.apache.shardingsphere.test.e2e.transaction.engine.base.TransactionTestCase;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 import javax.sql.DataSource;
 import java.sql.Connection;
@@ -32,6 +33,7 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -64,7 +66,7 @@ public final class ClassicTransferTestCase extends BaseTransactionTestCase {
             int sum = getBalanceSum();
             assertThat(String.format("Balance sum is %s, should be 100.", sum), sum, is(100));
         }
-        Thread.sleep(3000L);
+        Awaitility.await().pollDelay(3L, TimeUnit.SECONDS).until(() -> true);
         int sum = getBalanceSum();
         assertThat(String.format("Balance sum is %s, should be 100.", sum), sum, is(100));
         for (Thread task : tasks) {
@@ -97,10 +99,10 @@ public final class ClassicTransferTestCase extends BaseTransactionTestCase {
                 Statement statement1 = connection.createStatement();
                 statement1.execute("UPDATE account SET balance = balance - 1 WHERE transaction_id = 2;");
                 Statement statement2 = connection.createStatement();
-                Thread.sleep(1000L);
+                Awaitility.await().pollDelay(1L, TimeUnit.SECONDS).until(() -> true);
                 statement2.execute("UPDATE account SET balance = balance + 1 WHERE transaction_id = 1;");
                 connection.commit();
-            } catch (final SQLException | InterruptedException ignored) {
+            } catch (final SQLException ignored) {
             }
         }
     }
diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionBaseE2EIT.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionBaseE2EIT.java
index dc6c0448993..d100d862537 100644
--- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionBaseE2EIT.java
+++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionBaseE2EIT.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.test.e2e.transaction.engine.base;
 
 import com.google.common.base.Preconditions;
 import lombok.Getter;
-import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
@@ -44,6 +43,7 @@ import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
 import org.junit.jupiter.params.provider.ArgumentsProvider;
 import org.junit.jupiter.params.provider.ArgumentsSource;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 import javax.sql.DataSource;
 import javax.xml.bind.JAXB;
@@ -62,6 +62,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -222,16 +223,15 @@ public abstract class TransactionBaseE2EIT {
                 && Objects.equals(transactionRuleMap.get(TransactionTestConstants.PROVIDER_TYPE), expectedProviderType);
     }
     
-    @SneakyThrows(InterruptedException.class)
     private boolean waitExpectedTransactionRule(final TransactionType expectedTransType, final String expectedProviderType, final TransactionContainerComposer containerComposer) throws SQLException {
-        Thread.sleep(5000L);
+        Awaitility.await().pollDelay(5L, TimeUnit.SECONDS).until(() -> true);
         try (Connection connection = containerComposer.getDataSource().getConnection()) {
             int waitTimes = 0;
             do {
                 if (isExpectedTransactionRule(connection, expectedTransType, expectedProviderType)) {
                     return true;
                 }
-                Thread.sleep(2000L);
+                Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
                 waitTimes++;
             } while (waitTimes <= 3);
             return false;
@@ -260,7 +260,6 @@ public abstract class TransactionBaseE2EIT {
      * @param containerComposer container composer
      * @throws SQLException SQL exception
      */
-    @SneakyThrows(InterruptedException.class)
     public void addResource(final Connection connection, final String databaseName, final TransactionContainerComposer containerComposer) throws SQLException {
         String addSourceResource = commonSQL.getSourceAddNewResourceTemplate()
                 .replace("${user}", ENV.getActualDataSourceUsername(containerComposer.getDatabaseType()))
@@ -268,7 +267,7 @@ public abstract class TransactionBaseE2EIT {
                 .replace("${ds2}", getActualJdbcUrlTemplate(databaseName, containerComposer));
         executeWithLog(connection, addSourceResource);
         int resourceCount = countWithLog("SHOW STORAGE UNITS FROM sharding_db", containerComposer);
-        Thread.sleep(5000L);
+        Awaitility.await().pollDelay(5L, TimeUnit.SECONDS).until(() -> true);
         assertThat(resourceCount, is(3));
     }
     
@@ -294,14 +293,12 @@ public abstract class TransactionBaseE2EIT {
         assertThat(countWithLog("SHOW SHARDING TABLE RULES FROM sharding_db;", containerComposer), is(3));
     }
     
-    @SneakyThrows(InterruptedException.class)
     private void executeWithLog(final Connection connection, final String sql) throws SQLException {
         log.info("Connection execute:{}.", sql);
         connection.createStatement().execute(sql);
-        Thread.sleep(1000L);
+        Awaitility.await().pollDelay(1L, TimeUnit.SECONDS).until(() -> true);
     }
     
-    @SneakyThrows(InterruptedException.class)
     private int countWithLog(final String sql, final TransactionContainerComposer containerComposer) throws SQLException {
         try (Connection connection = containerComposer.getDataSource().getConnection()) {
             int retryNumber = 0;
@@ -317,7 +314,7 @@ public abstract class TransactionBaseE2EIT {
                 } catch (final SQLException ex) {
                     log.error("Data access error.", ex);
                 }
-                Thread.sleep(2000L);
+                Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
                 retryNumber++;
             }
         }
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java
index 00fbdd8d9d6..5b463448751 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.test.e2e.engine.type;
 
 import com.google.common.base.Splitter;
-import lombok.SneakyThrows;
 import org.apache.shardingsphere.infra.datanode.DataNode;
 import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
 import org.apache.shardingsphere.test.e2e.cases.SQLCommandType;
@@ -34,6 +33,7 @@ import org.apache.shardingsphere.test.e2e.framework.param.model.AssertionTestPar
 import org.junit.jupiter.api.condition.EnabledIf;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.ArgumentsSource;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
@@ -46,6 +46,7 @@ import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -280,9 +281,8 @@ class DDLE2EIT {
         }
     }
     
-    @SneakyThrows(InterruptedException.class)
     private void waitCompleted() {
-        Thread.sleep(1500L);
+        Awaitility.await().pollDelay(1500L, TimeUnit.MILLISECONDS).until(() -> true);
     }
     
     private static boolean isEnabled() {
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java
index c043f72c673..326174c6fca 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.test.e2e.engine.type;
 
 import com.google.common.base.Splitter;
-import lombok.SneakyThrows;
 import org.apache.shardingsphere.test.e2e.cases.SQLCommandType;
 import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetColumn;
 import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetMetaData;
@@ -31,6 +30,7 @@ import org.apache.shardingsphere.test.e2e.framework.param.model.AssertionTestPar
 import org.junit.jupiter.api.condition.EnabledIf;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.ArgumentsSource;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 import java.sql.Connection;
 import java.sql.PreparedStatement;
@@ -41,6 +41,7 @@ import java.sql.Statement;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -90,7 +91,7 @@ class RALE2EIT {
                 preparedStatement.executeUpdate();
             }
         }
-        waitCompleted(1000L);
+        Awaitility.await().pollDelay(1L, TimeUnit.SECONDS).until(() -> true);
     }
     
     private void tearDown(final SingleE2EContainerComposer containerComposer) throws SQLException {
@@ -110,7 +111,7 @@ class RALE2EIT {
                 preparedStatement.executeUpdate();
             }
         }
-        waitCompleted(1000L);
+        Awaitility.await().pollDelay(1L, TimeUnit.SECONDS).until(() -> true);
     }
     
     private void assertResultSet(final SingleE2EContainerComposer containerComposer, final Statement statement) throws SQLException {
@@ -118,7 +119,7 @@ class RALE2EIT {
             assertResultSet(containerComposer, statement, containerComposer.getSQL());
         } else {
             statement.execute(containerComposer.getSQL());
-            waitCompleted(2000L);
+            Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
             assertResultSet(containerComposer, statement, containerComposer.getAssertion().getAssertionSQL().getSql());
         }
     }
@@ -185,11 +186,6 @@ class RALE2EIT {
         assertThat(String.valueOf(actual.getObject(columnLabel)).trim(), is(expected));
     }
     
-    @SneakyThrows(InterruptedException.class)
-    private void waitCompleted(final long timeoutMillis) {
-        Thread.sleep(timeoutMillis);
-    }
-    
     private static boolean isEnabled() {
         return E2ETestParameterFactory.containsTestParameter() && !E2ETestParameterFactory.getAssertionTestParameters(SQLCommandType.RAL).isEmpty();
     }
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java
index 9b3e0914c4f..02f4d243696 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.test.e2e.engine.type;
 
 import com.google.common.base.Splitter;
-import lombok.SneakyThrows;
 import org.apache.shardingsphere.test.e2e.cases.SQLCommandType;
 import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetColumn;
 import org.apache.shardingsphere.test.e2e.cases.dataset.metadata.DataSetMetaData;
@@ -31,6 +30,7 @@ import org.apache.shardingsphere.test.e2e.framework.param.model.AssertionTestPar
 import org.junit.jupiter.api.condition.EnabledIf;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.ArgumentsSource;
+import org.testcontainers.shaded.org.awaitility.Awaitility;
 
 import java.sql.Connection;
 import java.sql.PreparedStatement;
@@ -41,6 +41,7 @@ import java.sql.Statement;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -70,7 +71,7 @@ class RDLE2EIT {
         try (Connection connection = containerComposer.getTargetDataSource().getConnection()) {
             try (Statement statement = connection.createStatement()) {
                 executeSQLCase(containerComposer, statement);
-                waitCompleted();
+                Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
                 assertResultSet(containerComposer, statement);
             }
         }
@@ -92,7 +93,7 @@ class RDLE2EIT {
                 executeDestroySQLs(containerComposer, connection);
             }
         }
-        waitCompleted();
+        Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
     }
     
     private void executeInitSQLs(final SingleE2EContainerComposer containerComposer, final Connection connection) throws SQLException {
@@ -102,7 +103,7 @@ class RDLE2EIT {
         for (String each : Splitter.on(";").trimResults().splitToList(containerComposer.getAssertion().getInitialSQL().getSql())) {
             try (PreparedStatement preparedStatement = connection.prepareStatement(each)) {
                 preparedStatement.executeUpdate();
-                waitCompleted();
+                Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
             }
         }
     }
@@ -114,7 +115,7 @@ class RDLE2EIT {
         for (String each : Splitter.on(";").trimResults().splitToList(containerComposer.getAssertion().getDestroySQL().getSql())) {
             try (PreparedStatement preparedStatement = connection.prepareStatement(each)) {
                 preparedStatement.executeUpdate();
-                waitCompleted();
+                Awaitility.await().pollDelay(2L, TimeUnit.SECONDS).until(() -> true);
             }
         }
     }
@@ -171,11 +172,6 @@ class RDLE2EIT {
         assertThat(String.valueOf(actual.getObject(columnLabel)), is(expected));
     }
     
-    @SneakyThrows(InterruptedException.class)
-    private void waitCompleted() {
-        Thread.sleep(2000L);
-    }
-    
     private static boolean isEnabled() {
         return E2ETestParameterFactory.containsTestParameter() && !E2ETestParameterFactory.getAssertionTestParameters(SQLCommandType.RDL).isEmpty();
     }