You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/06/22 11:28:08 UTC
[GitHub] [shardingsphere] strongduanmu opened a new issue #10916: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE statement with shardingsphere-integration-test
strongduanmu opened a new issue #10916:
URL: https://github.com/apache/shardingsphere/issues/10916
Hi community,
This issue is for #10887.
# Background
Currently `FederateStatementTest` and `FederatePrepareStatementTest` use JUNIT to test SQL statements. In order to improve test coverage and code elegance, we need to migrate the test scenarios of FederateStatementTest and FederatePrepareStatementTest to `shardingsphere-integration-test`.
# Target
The goal of this issue is to migrate the `SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE` statement to the `shardingsphere-integration-test` module.
You can search for the `SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE` keyword, and then you will find the test cases in `FederateStatementTest` and `FederatePrepareStatementTest`.
FederateStatementTest:
```java
private static final String SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE =
"select t_order_federate.*, t_order_item_federate_sharding.* from "
+ "t_order_federate, t_order_item_federate_sharding "
+ "where t_order_federate.order_id = t_order_item_federate_sharding.item_id "
+ "AND t_order_item_federate_sharding.remarks = 't_order_item_federate_sharding'";
@Test
public void assertQueryWithFederateInSingleAndShardingTableRewriteByExecuteQuery() throws SQLException {
assertQueryWithFederateInSingleAndShardingTableRewrite(true);
}
@Test
public void assertQueryWithFederateInSingleAndShardingTableRewriteByExecute() throws SQLException {
assertQueryWithFederateInSingleAndShardingTableRewrite(false);
}
private void assertQueryWithFederateInSingleAndShardingTableRewrite(final boolean executeQuery) throws SQLException {
ShardingSphereStatement statement = (ShardingSphereStatement) getShardingSphereDataSource().getConnection().createStatement();
ResultSet resultSet = getResultSet(statement, SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE, executeQuery);
assertNotNull(resultSet);
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(1000));
assertThat(resultSet.getInt(2), is(10));
assertThat(resultSet.getString(3), is("init"));
assertThat(resultSet.getInt(4), is(1000));
assertThat(resultSet.getInt(5), is(10000));
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(1001));
assertThat(resultSet.getInt(2), is(11));
assertThat(resultSet.getString(3), is("init"));
assertThat(resultSet.getInt(4), is(1001));
assertThat(resultSet.getInt(5), is(10001));
assertFalse(resultSet.next());
}
```
FederatePrepareStatementTest:
```java
private static final String SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE =
"select t_order_federate.*, t_order_item_federate_sharding.* "
+ "from t_order_federate, t_order_item_federate_sharding "
+ "where t_order_federate.order_id = t_order_item_federate_sharding.item_id "
+ "AND t_order_item_federate_sharding.remarks = 't_order_item_federate_sharding' "
+ "AND t_order_item_federate_sharding.user_id = ?";
@Test
public void assertQueryWithFederateInSingleAndShardingTableRewriteByExecuteQuery() throws SQLException {
assertQueryWithFederateInSingleAndShardingTableRewrite(true);
}
@Test
public void assertQueryWithFederateInSingleAndShardingTableRewriteByExecute() throws SQLException {
assertQueryWithFederateInSingleAndShardingTableRewrite(false);
}
private void assertQueryWithFederateInSingleAndShardingTableRewrite(final boolean executeQuery) throws SQLException {
ShardingSpherePreparedStatement preparedStatement = (ShardingSpherePreparedStatement) getShardingSphereDataSource()
.getConnection().prepareStatement(SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE);
preparedStatement.setInt(1, 11);
ResultSet resultSet = getResultSet(preparedStatement, executeQuery);
assertNotNull(resultSet);
assertTrue(resultSet.next());
assertThat(resultSet.getInt(1), is(1001));
assertThat(resultSet.getInt(2), is(11));
assertThat(resultSet.getString(3), is("init"));
assertThat(resultSet.getInt(4), is(1001));
assertThat(resultSet.getInt(5), is(10001));
assertFalse(resultSet.next());
preparedStatement.setInt(1, 10);
ResultSet resultSet1 = getResultSet(preparedStatement, executeQuery);
assertNotNull(resultSet1);
assertTrue(resultSet1.next());
assertThat(resultSet1.getInt(1), is(1000));
assertThat(resultSet1.getInt(2), is(10));
assertThat(resultSet1.getString(3), is("init"));
assertThat(resultSet1.getInt(4), is(1000));
assertThat(resultSet1.getInt(5), is(10000));
assertFalse(resultSet1.next());
}
```
# How to
In order to finish this task, you need to understand the [documentation](https://shardingsphere.apache.org/document/current/en/features/test-engine/integration-test/) of the integration test first, and PR #10913 also provides an example, which you can refer to. BTW, if you have any questions, please leave a comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu commented on issue #10916: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE statement with shardingsphere-integration-test
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #10916:
URL: https://github.com/apache/shardingsphere/issues/10916#issuecomment-880324963
@tup916 Welcome, and you can refer this [doc](https://shardingsphere.apache.org/community/en/contribute/contributor/) for your first contribution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] tup916 commented on issue #10916: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE statement with shardingsphere-integration-test
Posted by GitBox <gi...@apache.org>.
tup916 commented on issue #10916:
URL: https://github.com/apache/shardingsphere/issues/10916#issuecomment-880324077
Hi, I can take a stab at this one. :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu commented on issue #10916: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE statement with shardingsphere-integration-test
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #10916:
URL: https://github.com/apache/shardingsphere/issues/10916#issuecomment-927404556
Hi @tup916, considering the exception of this test case on JDK11, we will invite @LeeGuoPing to complete this task as soon as possible. If you are interested in other tasks, you can continue to participate.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu commented on issue #10916: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE statement with shardingsphere-integration-test
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #10916:
URL: https://github.com/apache/shardingsphere/issues/10916#issuecomment-927411620
@LeeGuoPing Welcome.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] strongduanmu closed issue #10916: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE statement with shardingsphere-integration-test
Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #10916:
URL: https://github.com/apache/shardingsphere/issues/10916
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] LeeGuoPing commented on issue #10916: Refactor SELECT_SQL_BY_ID_ACROSS_SINGLE_AND_SHARDING_TABLES_REWRITE statement with shardingsphere-integration-test
Posted by GitBox <gi...@apache.org>.
LeeGuoPing commented on issue #10916:
URL: https://github.com/apache/shardingsphere/issues/10916#issuecomment-927408344
please assign it to me
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org