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 2022/09/01 13:06:10 UTC

[GitHub] [shardingsphere] FlyingZC opened a new pull request, #20716: Add broadcast table transaction test

FlyingZC opened a new pull request, #20716:
URL: https://github.com/apache/shardingsphere/pull/20716

   Changes proposed in this pull request:
   - Add broadcast table transaction test


-- 
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 a diff in pull request #20716: Add broadcast table transaction test

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on code in PR #20716:
URL: https://github.com/apache/shardingsphere/pull/20716#discussion_r961198514


##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/BroadcastTableTransactionTestCase.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.integration.transaction.cases.commitrollback;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Broadcast table transaction integration test.
+ */
+@Slf4j
+@TransactionTestCase
+public class BroadcastTableTransactionTestCase extends BaseTransactionTestCase {
+    
+    private static final String T_ADDRESS = "t_address";
+    
+    public BroadcastTableTransactionTestCase(final BaseTransactionITCase baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
+    }
+    
+    @Override
+    @SneakyThrows(SQLException.class)
+    protected void beforeTest() {
+        super.beforeTest();
+        init();
+    }
+    
+    @Override
+    @SneakyThrows(SQLException.class)
+    protected void afterTest() {
+        super.afterTest();
+        init();
+    }
+    
+    @Override
+    @SneakyThrows(SQLException.class)
+    protected void executeTest() {
+        rollback();
+        commit();
+    }
+    
+    private void init() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        executeWithLog(conn, "delete from t_address;");
+        assertTableRowCount(conn, T_ADDRESS, 0);
+    }
+    
+    private void commit() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        conn.setAutoCommit(false);
+        executeWithLog(conn, "delete from t_address;");
+        assertTableRowCount(conn, T_ADDRESS, 0);
+        executeWithLog(conn, "INSERT INTO t_address (id, code, address) VALUES (1, '1', 'nanjing');");

Review Comment:
   Can we move this sql to xml test case?



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/BroadcastTableTransactionTestCase.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.integration.transaction.cases.commitrollback;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Broadcast table transaction integration test.
+ */
+@Slf4j
+@TransactionTestCase
+public class BroadcastTableTransactionTestCase extends BaseTransactionTestCase {

Review Comment:
   Please add final for BroadcastTableTransactionTestCase.



-- 
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 merged pull request #20716: Add broadcast table transaction test

Posted by GitBox <gi...@apache.org>.
strongduanmu merged PR #20716:
URL: https://github.com/apache/shardingsphere/pull/20716


-- 
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] FlyingZC commented on a diff in pull request #20716: Add broadcast table transaction test

Posted by GitBox <gi...@apache.org>.
FlyingZC commented on code in PR #20716:
URL: https://github.com/apache/shardingsphere/pull/20716#discussion_r961211599


##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/BroadcastTableTransactionTestCase.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.integration.transaction.cases.commitrollback;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Broadcast table transaction integration test.
+ */
+@Slf4j
+@TransactionTestCase
+public class BroadcastTableTransactionTestCase extends BaseTransactionTestCase {
+    
+    private static final String T_ADDRESS = "t_address";
+    
+    public BroadcastTableTransactionTestCase(final BaseTransactionITCase baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
+    }
+    
+    @Override
+    @SneakyThrows(SQLException.class)
+    protected void beforeTest() {
+        super.beforeTest();
+        init();
+    }
+    
+    @Override
+    @SneakyThrows(SQLException.class)
+    protected void afterTest() {
+        super.afterTest();
+        init();
+    }
+    
+    @Override
+    @SneakyThrows(SQLException.class)
+    protected void executeTest() {
+        rollback();
+        commit();
+    }
+    
+    private void init() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        executeWithLog(conn, "delete from t_address;");
+        assertTableRowCount(conn, T_ADDRESS, 0);
+    }
+    
+    private void commit() throws SQLException {
+        Connection conn = getDataSource().getConnection();
+        conn.setAutoCommit(false);
+        executeWithLog(conn, "delete from t_address;");
+        assertTableRowCount(conn, T_ADDRESS, 0);
+        executeWithLog(conn, "INSERT INTO t_address (id, code, address) VALUES (1, '1', 'nanjing');");

Review Comment:
   I need to think about how to adapt this feature.



-- 
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] FlyingZC commented on a diff in pull request #20716: Add broadcast table transaction test

Posted by GitBox <gi...@apache.org>.
FlyingZC commented on code in PR #20716:
URL: https://github.com/apache/shardingsphere/pull/20716#discussion_r961210094


##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/BroadcastTableTransactionTestCase.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.integration.transaction.cases.commitrollback;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Broadcast table transaction integration test.
+ */
+@Slf4j
+@TransactionTestCase
+public class BroadcastTableTransactionTestCase extends BaseTransactionTestCase {

Review Comment:
   You are right.



-- 
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