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/06/15 10:26:42 UTC

[GitHub] [shardingsphere] soulasuna opened a new pull request, #18377: Add assert of stop writing in scaling integration test

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

   Add assert of stop writing in scaling integration test
   
   Related #18374.
   
   Changes proposed in this pull request:
   - Add assert of stop writing in scaling integration 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] soulasuna commented on a diff in pull request #18377: Add assert of stop writing in scaling integration test

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


##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java:
##########
@@ -317,5 +318,44 @@ protected void assertCheckMatchConsistencySuccess() throws InterruptedException
         assertThat(previewResults.stream().map(each -> each.get("data_source_name")).collect(Collectors.toSet()), is(new HashSet<>(Arrays.asList("ds_2", "ds_3", "ds_4"))));
         assertThat(targetSources, is(new HashSet<>(Arrays.asList("SELECT COUNT(1) FROM t_order_0 UNION ALL SELECT COUNT(1) FROM t_order_3",
                 "SELECT COUNT(1) FROM t_order_1 UNION ALL SELECT COUNT(1) FROM t_order_4", "SELECT COUNT(1) FROM t_order_2 UNION ALL SELECT COUNT(1) FROM t_order_5"))));
+        restoreScalingSourceWriting(jobId);
+    }
+    
+    protected void restoreScalingSourceWriting(final String jobId) {
+        executeWithLog(String.format("RESTORE SCALING SOURCE WRITING %s", jobId));
+    }
+    
+    protected abstract void assertStopScalingSourceWriting();
+    
+    protected abstract void assertRestoreScalingSourceWriting();
+    
+    protected boolean executeUpdate(final String sql) {
+        log.info("jdbcTemplate execute:{}", sql);
+        try {
+            jdbcTemplate.update(sql);
+            return true;
+            // CHECKSTYLE:OFF
+        } catch (final Exception ex) {
+            // CHECKSTYLE:ON
+            assertSQLException((SQLException) ex.getCause());
+            return false;
+        }
+    }
+    
+    protected boolean executeDDL(final String sql) {
+        log.info("jdbcTemplate execute:{}", sql);
+        try {
+            jdbcTemplate.execute(sql);
+            return true;
+            // CHECKSTYLE:OFF
+        } catch (final Exception ex) {
+            // CHECKSTYLE:ON
+            assertSQLException((SQLException) ex.getCause());
+            return false;
+        }
+    }
+    
+    private void assertSQLException(final SQLException exception) {
+        assertTrue(exception.getMessage().endsWith("The database sharding_db is read-only"));
     }

Review Comment:
   Fixed



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java:
##########
@@ -317,5 +318,44 @@ protected void assertCheckMatchConsistencySuccess() throws InterruptedException
         assertThat(previewResults.stream().map(each -> each.get("data_source_name")).collect(Collectors.toSet()), is(new HashSet<>(Arrays.asList("ds_2", "ds_3", "ds_4"))));
         assertThat(targetSources, is(new HashSet<>(Arrays.asList("SELECT COUNT(1) FROM t_order_0 UNION ALL SELECT COUNT(1) FROM t_order_3",
                 "SELECT COUNT(1) FROM t_order_1 UNION ALL SELECT COUNT(1) FROM t_order_4", "SELECT COUNT(1) FROM t_order_2 UNION ALL SELECT COUNT(1) FROM t_order_5"))));
+        restoreScalingSourceWriting(jobId);
+    }
+    
+    protected void restoreScalingSourceWriting(final String jobId) {
+        executeWithLog(String.format("RESTORE SCALING SOURCE WRITING %s", jobId));
+    }
+    
+    protected abstract void assertStopScalingSourceWriting();
+    
+    protected abstract void assertRestoreScalingSourceWriting();

Review Comment:
   Fixed



-- 
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] soulasuna commented on a diff in pull request #18377: Add assert of stop writing in scaling integration test

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


##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java:
##########
@@ -317,5 +318,44 @@ protected void assertCheckMatchConsistencySuccess() throws InterruptedException
         assertThat(previewResults.stream().map(each -> each.get("data_source_name")).collect(Collectors.toSet()), is(new HashSet<>(Arrays.asList("ds_2", "ds_3", "ds_4"))));
         assertThat(targetSources, is(new HashSet<>(Arrays.asList("SELECT COUNT(1) FROM t_order_0 UNION ALL SELECT COUNT(1) FROM t_order_3",
                 "SELECT COUNT(1) FROM t_order_1 UNION ALL SELECT COUNT(1) FROM t_order_4", "SELECT COUNT(1) FROM t_order_2 UNION ALL SELECT COUNT(1) FROM t_order_5"))));
+        restoreScalingSourceWriting(jobId);
+    }
+    
+    protected void restoreScalingSourceWriting(final String jobId) {
+        executeWithLog(String.format("RESTORE SCALING SOURCE WRITING %s", jobId));
+    }
+    
+    protected abstract void assertStopScalingSourceWriting();
+    
+    protected abstract void assertRestoreScalingSourceWriting();
+    
+    protected boolean executeUpdate(final String sql) {
+        log.info("jdbcTemplate execute:{}", sql);
+        try {
+            jdbcTemplate.update(sql);
+            return true;
+            // CHECKSTYLE:OFF
+        } catch (final Exception ex) {
+            // CHECKSTYLE:ON
+            assertSQLException((SQLException) ex.getCause());
+            return false;
+        }
+    }
+    
+    protected boolean executeDDL(final String sql) {
+        log.info("jdbcTemplate execute:{}", sql);
+        try {
+            jdbcTemplate.execute(sql);
+            return true;
+            // CHECKSTYLE:OFF
+        } catch (final Exception ex) {
+            // CHECKSTYLE:ON
+            assertSQLException((SQLException) ex.getCause());
+            return false;
+        }
+    }
+    
+    private void assertSQLException(final SQLException exception) {
+        assertTrue(exception.getMessage().endsWith("The database sharding_db is read-only"));
     }

Review Comment:
   OK, I will try



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java:
##########
@@ -317,5 +318,44 @@ protected void assertCheckMatchConsistencySuccess() throws InterruptedException
         assertThat(previewResults.stream().map(each -> each.get("data_source_name")).collect(Collectors.toSet()), is(new HashSet<>(Arrays.asList("ds_2", "ds_3", "ds_4"))));
         assertThat(targetSources, is(new HashSet<>(Arrays.asList("SELECT COUNT(1) FROM t_order_0 UNION ALL SELECT COUNT(1) FROM t_order_3",
                 "SELECT COUNT(1) FROM t_order_1 UNION ALL SELECT COUNT(1) FROM t_order_4", "SELECT COUNT(1) FROM t_order_2 UNION ALL SELECT COUNT(1) FROM t_order_5"))));
+        restoreScalingSourceWriting(jobId);
+    }
+    
+    protected void restoreScalingSourceWriting(final String jobId) {
+        executeWithLog(String.format("RESTORE SCALING SOURCE WRITING %s", jobId));
+    }
+    
+    protected abstract void assertStopScalingSourceWriting();
+    
+    protected abstract void assertRestoreScalingSourceWriting();

Review Comment:
   OK, I will try



-- 
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] soulasuna commented on a diff in pull request #18377: Add assert of stop writing in scaling integration test

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


##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseExtraSQLITCase.java:
##########
@@ -53,4 +56,16 @@ protected void createTableIndexList() {
     protected void createOrderItemTable() {
         executeWithLog(extraSQLCommand.getCreateTableOrderItem());
     }
+    
+    @Override
+    protected void assertStopScalingSourceWriting() {
+        assertFalse(executeUpdate(extraSQLCommand.getUpdateTableOrderStatus()));
+        assertFalse(executeDDL(extraSQLCommand.getCreateIndexStatus()));
+    }
+    
+    @Override
+    protected void assertRestoreScalingSourceWriting() {
+        assertTrue(executeUpdate(extraSQLCommand.getUpdateTableOrderStatus()));
+        assertTrue(executeDDL(extraSQLCommand.getCreateIndexStatus()));
+    }

Review Comment:
   Update SQL and Index SQL are slightly different in different databases, can not combine them. 
   Take update SQL as an example:
   MySQL: ` UPDATE t_order SET status= 'unlock' `
   PostgreSQL: ` UPDATE test.t_order SET status= 'unlock' `



-- 
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] sandynz merged pull request #18377: Add assert of stop writing in scaling integration test

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


-- 
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] sandynz commented on a diff in pull request #18377: Add assert of stop writing in scaling integration test

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


##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseExtraSQLITCase.java:
##########
@@ -53,4 +56,16 @@ protected void createTableIndexList() {
     protected void createOrderItemTable() {
         executeWithLog(extraSQLCommand.getCreateTableOrderItem());
     }
+    
+    @Override
+    protected void assertStopScalingSourceWriting() {
+        assertFalse(executeUpdate(extraSQLCommand.getUpdateTableOrderStatus()));
+        assertFalse(executeDDL(extraSQLCommand.getCreateIndexStatus()));
+    }
+    
+    @Override
+    protected void assertRestoreScalingSourceWriting() {
+        assertTrue(executeUpdate(extraSQLCommand.getUpdateTableOrderStatus()));
+        assertTrue(executeDDL(extraSQLCommand.getCreateIndexStatus()));
+    }

Review Comment:
   Looks update SQL and index SQL are the same in different databases, these methods could be put in BaseITCase and remove the related SQL configuration to simplify code.



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java:
##########
@@ -317,5 +318,44 @@ protected void assertCheckMatchConsistencySuccess() throws InterruptedException
         assertThat(previewResults.stream().map(each -> each.get("data_source_name")).collect(Collectors.toSet()), is(new HashSet<>(Arrays.asList("ds_2", "ds_3", "ds_4"))));
         assertThat(targetSources, is(new HashSet<>(Arrays.asList("SELECT COUNT(1) FROM t_order_0 UNION ALL SELECT COUNT(1) FROM t_order_3",
                 "SELECT COUNT(1) FROM t_order_1 UNION ALL SELECT COUNT(1) FROM t_order_4", "SELECT COUNT(1) FROM t_order_2 UNION ALL SELECT COUNT(1) FROM t_order_5"))));
+        restoreScalingSourceWriting(jobId);
+    }
+    
+    protected void restoreScalingSourceWriting(final String jobId) {
+        executeWithLog(String.format("RESTORE SCALING SOURCE WRITING %s", jobId));
+    }
+    
+    protected abstract void assertStopScalingSourceWriting();
+    
+    protected abstract void assertRestoreScalingSourceWriting();
+    
+    protected boolean executeUpdate(final String sql) {
+        log.info("jdbcTemplate execute:{}", sql);
+        try {
+            jdbcTemplate.update(sql);
+            return true;
+            // CHECKSTYLE:OFF
+        } catch (final Exception ex) {
+            // CHECKSTYLE:ON
+            assertSQLException((SQLException) ex.getCause());
+            return false;
+        }
+    }
+    
+    protected boolean executeDDL(final String sql) {
+        log.info("jdbcTemplate execute:{}", sql);
+        try {
+            jdbcTemplate.execute(sql);
+            return true;
+            // CHECKSTYLE:OFF
+        } catch (final Exception ex) {
+            // CHECKSTYLE:ON
+            assertSQLException((SQLException) ex.getCause());
+            return false;
+        }
+    }
+    
+    private void assertSQLException(final SQLException exception) {
+        assertTrue(exception.getMessage().endsWith("The database sharding_db is read-only"));
     }

Review Comment:
   executeUpdate / executeDDL / assertSQLException is not common enough, it could be merged into assertRestoreScalingSourceWriting.
   



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java:
##########
@@ -317,5 +318,44 @@ protected void assertCheckMatchConsistencySuccess() throws InterruptedException
         assertThat(previewResults.stream().map(each -> each.get("data_source_name")).collect(Collectors.toSet()), is(new HashSet<>(Arrays.asList("ds_2", "ds_3", "ds_4"))));
         assertThat(targetSources, is(new HashSet<>(Arrays.asList("SELECT COUNT(1) FROM t_order_0 UNION ALL SELECT COUNT(1) FROM t_order_3",
                 "SELECT COUNT(1) FROM t_order_1 UNION ALL SELECT COUNT(1) FROM t_order_4", "SELECT COUNT(1) FROM t_order_2 UNION ALL SELECT COUNT(1) FROM t_order_5"))));
+        restoreScalingSourceWriting(jobId);
+    }
+    
+    protected void restoreScalingSourceWriting(final String jobId) {
+        executeWithLog(String.format("RESTORE SCALING SOURCE WRITING %s", jobId));
+    }
+    
+    protected abstract void assertStopScalingSourceWriting();
+    
+    protected abstract void assertRestoreScalingSourceWriting();

Review Comment:
   assertStopScalingSourceWriting and assertRestoreScalingSourceWriting could be private.



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