未验证 提交 343dd80c 编写于 作者: Z zhaojun 提交者: GitHub

add wait for proxy logic before running integration case. (#5980)

* disable delete multiple tables case

* add wait for proxy logic before running integration case.

* add validate sql for proxy available check
上级 3d87fdbf
......@@ -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;
}
}
......@@ -15,9 +15,9 @@
~ limitations under the License.
-->
<integrate-test-cases>
<dcl-test-case sql="CREATE USER 'user_dev_new'@'localhost' default role role1" db-types="MySQL" />
<dcl-test-case sql="CREATE USER 'user_dev_new'@'localhost'" db-types="MySQL" />
<dcl-test-case value="CREATE USER user_dev_new" db-types="PostgreSQL" />
<dcl-test-case sql="CREATE USER 'user_dev_new'@'localhost' identified by 'passwd_dev' default role role1" db-types="MySQL"/>
<dcl-test-case sql="CREATE USER 'user_dev_new'@'localhost' identified by 'passwd_dev'" db-types="MySQL"/>
<dcl-test-case sql="CREATE USER user_dev_new identified by passwd_dev" db-types="Oracle" />
<dcl-test-case sql="CREATE USER user_dev_new FOR LOGIN login_dev" db-types="SQLServer"/>
<dcl-test-case sql="CREATE USER user_dev_new PASSWORD 'passwd_dev'" db-types="PostgreSQL"/>
......
......@@ -181,7 +181,8 @@
<assertion expected-data-file="delete_with_special_comments_returning_without_sharding_value.xml" />
</dml-test-case>
<dml-test-case sql="DELETE o FROM t_order AS o WHERE status=?" db-types="MySQL,Oracle,SQLServer">
<assertion parameters="init:String" expected-data-file="delete_with_alias.xml" />
</dml-test-case>
<!-- Can't support delete multiple tables-->
<!--<dml-test-case sql="DELETE o FROM t_order AS o WHERE status=?" db-types="MySQL,Oracle,SQLServer">-->
<!--<assertion parameters="init:String" expected-data-file="delete_with_alias.xml" />-->
<!--</dml-test-case>-->
</integrate-test-cases>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册