diff --git a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/BaseIT.java b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/BaseIT.java index cd06d244b992c6bab2c4b8bb3fb4419ca8a95156..4fd52003b8c69cf64062a57d3b32df9a06d698f9 100644 --- a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/BaseIT.java +++ b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/BaseIT.java @@ -36,7 +36,10 @@ import javax.sql.DataSource; import javax.xml.bind.JAXBException; import java.io.File; import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; import java.sql.SQLException; +import java.sql.Statement; import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -58,9 +61,12 @@ public abstract class BaseIT { static { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + if (IntegrateTestEnvironment.getInstance().isProxyEnvironment()) { + waitForProxy(); + } } - public BaseIT(final String ruleType, final DatabaseType databaseType) throws IOException, JAXBException, SQLException { + BaseIT(final String ruleType, final DatabaseType databaseType) throws IOException, JAXBException, SQLException { this.ruleType = ruleType; this.databaseType = databaseType; dataSourceMap = createDataSourceMap(); @@ -152,5 +158,27 @@ public abstract class BaseIT { ((ShardingSphereDataSource) dataSource).getSchemaContexts().getDefaultSchemaContext().getRuntimeContext().getExecutorKernel().close(); } } + + private static void waitForProxy() { + int retryCount = 1; + while (!isProxyAvailable() && retryCount < 30) { + try { + Thread.sleep(1000); + } catch (final InterruptedException ignore) { + } + retryCount++; + } + } + + private static boolean isProxyAvailable() { + try (Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:33070/proxy_db/?serverTimezone=UTC&useSSL=false&useLocalSessionState=true"); + Statement statement = connection.createStatement()) { + statement.execute("SELECT 1"); + + } catch (final SQLException ignore) { + return false; + } + return true; + } } diff --git a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/cases/dcl/dcl-integrate-test-cases.xml b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/cases/dcl/dcl-integrate-test-cases.xml index ebbb2ae33c1914e7216d739aba84c9bd080d6083..4dc2132d137bac98c3ccf38f26a870e03b030f1c 100644 --- a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/cases/dcl/dcl-integrate-test-cases.xml +++ b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/cases/dcl/dcl-integrate-test-cases.xml @@ -15,9 +15,9 @@ ~ limitations under the License. --> - + - + diff --git a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml index 25e667d0c925e72d11fc9b61e0ce2f0e5ae96af6..75daf7d87b2cc27ff0803f1bce316a2befd84530 100644 --- a/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml +++ b/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/cases/dml/dml-integrate-test-cases.xml @@ -181,7 +181,8 @@ - - - + + + +