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 11:29:31 UTC

[GitHub] [shardingsphere] soulasuna commented on a diff in pull request #18377: Add assert of stop writing in scaling integration test

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