You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/11/10 05:46:28 UTC
[shardingsphere] branch master updated: update example generator (#21973)
This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 8678085b6c8 update example generator (#21973)
8678085b6c8 is described below
commit 8678085b6c8a592aba77e745fd85778180c220ad
Author: Guocheng Tang <to...@apache.org>
AuthorDate: Thu Nov 10 13:46:19 2022 +0800
update example generator (#21973)
* Remove the mixed examples and use the automatically generated examples.
* merger master
* fix example
* update code
* update shadow
* test
* add blank after `,`
---
.github/workflows/nightly-it-example-generator.yml | 7 ++---
.../template/jdbc/java/config/encrypt.ftl | 2 +-
.../resources/template/jdbc/java/config/shadow.ftl | 36 +++++++++++-----------
.../java/repository/jdbc/OrderItemRepository.ftl | 6 ++--
.../jdbc/java/repository/jdbc/OrderRepository.ftl | 6 ++--
.../jdbc/resources/mappers/OrderMapper.ftl | 6 ++--
.../template/jdbc/resources/xml/shadow.ftl | 10 +++---
7 files changed, 36 insertions(+), 37 deletions(-)
diff --git a/.github/workflows/nightly-it-example-generator.yml b/.github/workflows/nightly-it-example-generator.yml
index aee03bfab84..564899fadfc 100644
--- a/.github/workflows/nightly-it-example-generator.yml
+++ b/.github/workflows/nightly-it-example-generator.yml
@@ -20,7 +20,7 @@ name: Nightly - IT Example Generator
on:
schedule:
- cron: '0 19 */1 * *' # once a day. UTC time
-
+
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dcheckstyle.skip=true -Dspotless.apply.skip=true -Dmaven.javadoc.skip=true
@@ -29,6 +29,7 @@ jobs:
if: github.repository == 'apache/shardingsphere'
name: Example-${{ matrix.feature }}-${{ matrix.framework }}-${{ matrix.mode }}-${{ matrix.transaction }}
runs-on: ubuntu-latest
+ timeout-minutes: 90
strategy:
fail-fast: false
matrix:
@@ -65,11 +66,9 @@ jobs:
shardingsphere-maven-third-party-
- name: Maven resolve ranges
run: ./mvnw versions:resolve-ranges -ntp -Dincludes='org.springframework:*,org.springframework.boot:*'
- - name: Build with Maven
- run: ./mvnw -B -ntp clean install -DskipITs -DskipTests
- name: Prepare environments
run: sh .github/workflows/resources/sql/nightly-generator-init.sh
- name: Generate examples
- run: ./mvnw -B test -f examples/shardingsphere-example-generator/pom.xml -Pexample-generator -Dproducts=${{ matrix.product }} -Dmodes=${{ matrix.mode }} -Dtransactions=${{ matrix.transaction }} -Dfeatures=${{ matrix.feature }} -Dframeworks=${{ matrix.framework }}
+ run: ./mvnw -B clean install -f examples/shardingsphere-example-generator/pom.xml -Pexample-generator -Dproducts=${{ matrix.product }} -Dmodes=${{ matrix.mode }} -Dtransactions=${{ matrix.transaction }} -Dfeatures=${{ matrix.feature }} -Dframeworks=${{ matrix.framework }}
- name: Test examples
run : ./mvnw -B test -f examples/shardingsphere-example-generator/target/generated-sources/shardingsphere-jdbc-sample/${{ matrix.feature }}--${{ matrix.framework }}--${{ matrix.mode }}--${{ matrix.transaction }}/pom.xml -Pexample-generator -Dexec.cleanupDaemonThreads=false
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/encrypt.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/encrypt.ftl
index 49d5831c32e..22d5b8e330b 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/encrypt.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/encrypt.ftl
@@ -19,7 +19,7 @@
Properties props = new Properties();
props.setProperty("aes-key-value", "123456");
EncryptColumnRuleConfiguration columnConfigAes = new EncryptColumnRuleConfiguration("phone", "phone", "", "", "phone_plain", "phone_encryptor", null);
- EncryptColumnRuleConfiguration columnConfigTest = new EncryptColumnRuleConfiguration("status", "status", "assisted_query_status", "", "string_encryptor", "string_encryptor", null);
+ EncryptColumnRuleConfiguration columnConfigTest = new EncryptColumnRuleConfiguration("status", "status", "assisted_query_status", "", "", "string_encryptor", "string_encryptor", null, null);
EncryptTableRuleConfiguration orderItemRule = new EncryptTableRuleConfiguration("t_order_item", Collections.singleton(columnConfigAes), true);
EncryptTableRuleConfiguration orderRule = new EncryptTableRuleConfiguration("t_order", Collections.singleton(columnConfigTest), true);
Map<String, AlgorithmConfiguration> encryptAlgorithmConfigs = new LinkedHashMap<>();
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/shadow.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/shadow.ftl
index 79a50bcebd9..d459bc2966f 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/shadow.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/config/shadow.ftl
@@ -35,9 +35,9 @@
private Collection<String> createShadowAlgorithmNames() {
Collection<String> result = new LinkedList<>();
- result.add("user-id-insert-match-algorithm");
- result.add("user-id-delete-match-algorithm");
- result.add("user-id-select-match-algorithm");
+ result.add("order-type-insert-match-algorithm");
+ result.add("order-type-delete-match-algorithm");
+ result.add("order-type-select-match-algorithm");
result.add("simple-hint-algorithm");
return result;
}
@@ -56,21 +56,21 @@
private Map<String, AlgorithmConfiguration> createShadowAlgorithmConfigurations() {
Map<String, AlgorithmConfiguration> result = new LinkedHashMap<>();
- Properties userIdInsertProps = new Properties();
- userIdInsertProps.setProperty("operation", "insert");
- userIdInsertProps.setProperty("column", "order_type");
- userIdInsertProps.setProperty("value", "1");
- result.put("user-id-insert-match-algorithm", new AlgorithmConfiguration("VALUE_MATCH", userIdInsertProps));
- Properties userIdDeleteProps = new Properties();
- userIdDeleteProps.setProperty("operation", "delete");
- userIdDeleteProps.setProperty("column", "order_type");
- userIdDeleteProps.setProperty("value", "1");
- result.put("user-id-delete-match-algorithm", new AlgorithmConfiguration("VALUE_MATCH", userIdDeleteProps));
- Properties userIdSelectProps = new Properties();
- userIdSelectProps.setProperty("operation", "select");
- userIdSelectProps.setProperty("column", "order_type");
- userIdSelectProps.setProperty("value", "1");
- result.put("user-id-select-match-algorithm", new AlgorithmConfiguration("VALUE_MATCH", userIdSelectProps));
+ Properties orderTypeInsertProps = new Properties();
+ orderTypeInsertProps.setProperty("operation", "insert");
+ orderTypeInsertProps.setProperty("column", "order_type");
+ orderTypeInsertProps.setProperty("value", "1");
+ result.put("order-type-insert-match-algorithm", new AlgorithmConfiguration("VALUE_MATCH", orderTypeInsertProps));
+ Properties orderTypeDeleteProps = new Properties();
+ orderTypeDeleteProps.setProperty("operation", "delete");
+ orderTypeDeleteProps.setProperty("column", "order_type");
+ orderTypeDeleteProps.setProperty("value", "1");
+ result.put("order-type-delete-match-algorithm", new AlgorithmConfiguration("VALUE_MATCH", orderTypeDeleteProps));
+ Properties orderTypeSelectProps = new Properties();
+ orderTypeSelectProps.setProperty("operation", "select");
+ orderTypeSelectProps.setProperty("column", "order_type");
+ orderTypeSelectProps.setProperty("value", "1");
+ result.put("order-type-select-match-algorithm", new AlgorithmConfiguration("VALUE_MATCH", orderTypeSelectProps));
Properties noteAlgorithmProps = new Properties();
noteAlgorithmProps.setProperty("shadow", "true");
noteAlgorithmProps.setProperty("foo", "bar");
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jdbc/OrderItemRepository.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jdbc/OrderItemRepository.ftl
index c63a4dc81cf..bee69d62568 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jdbc/OrderItemRepository.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jdbc/OrderItemRepository.ftl
@@ -65,7 +65,7 @@ public final class OrderItemRepository {
public void createTableIfNotExistsShadow() throws SQLException {
String sql = "CREATE TABLE IF NOT EXISTS t_order_item "
- + "(order_item_id BIGINT NOT NULL AUTO_INCREMENT, order_id BIGINT NOT NULL, user_id INT NOT NULL, phone VARCHAR(50), status VARCHAR(50), PRIMARY KEY (order_item_id)) /*shadow:true,foo:bar*/";
+ + "(order_item_id BIGINT NOT NULL AUTO_INCREMENT, order_id BIGINT NOT NULL, user_id INT NOT NULL, phone VARCHAR(50), status VARCHAR(50), PRIMARY KEY (order_item_id)) /*SHARDINGSPHERE_HINT:shadow=true,foo=bar*/";
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
statement.executeUpdate(sql);
@@ -73,7 +73,7 @@ public final class OrderItemRepository {
}
public void dropTableShadow() throws SQLException {
- String sql = "DROP TABLE t_order_item /*shadow:true,foo:bar*/";
+ String sql = "DROP TABLE t_order_item /*SHARDINGSPHERE_HINT:shadow=true,foo=bar*/";
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
statement.executeUpdate(sql);
@@ -81,7 +81,7 @@ public final class OrderItemRepository {
}
public void truncateTableShadow() throws SQLException {
- String sql = "TRUNCATE TABLE t_order_item /*shadow:true,foo:bar*/";
+ String sql = "TRUNCATE TABLE t_order_item /*SHARDINGSPHERE_HINT:shadow=true,foo=bar*/";
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
statement.executeUpdate(sql);
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jdbc/OrderRepository.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jdbc/OrderRepository.ftl
index 125a0def2e7..c17ee5da980 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jdbc/OrderRepository.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/java/repository/jdbc/OrderRepository.ftl
@@ -68,7 +68,7 @@ public final class OrderRepository {
<#if feature?contains("shadow")>
public void createTableIfNotExistsShadow() throws SQLException {
- String sql = "CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT NOT NULL AUTO_INCREMENT, order_type INT(11), user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id)) /*shadow:true,foo:bar*/";
+ String sql = "CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT NOT NULL AUTO_INCREMENT, order_type INT(11), user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id)) /*SHARDINGSPHERE_HINT:shadow=true,foo=bar*/";
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
statement.executeUpdate(sql);
@@ -76,7 +76,7 @@ public final class OrderRepository {
}
public void dropTableShadow() throws SQLException {
- String sql = "DROP TABLE t_order /*shadow:true,foo:bar*/";
+ String sql = "DROP TABLE t_order /*SHARDINGSPHERE_HINT:shadow=true,foo=bar*/";
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
statement.executeUpdate(sql);
@@ -84,7 +84,7 @@ public final class OrderRepository {
}
public void truncateTableShadow() throws SQLException {
- String sql = "TRUNCATE TABLE t_order /*shadow:true,foo:bar*/";
+ String sql = "TRUNCATE TABLE t_order /*SHARDINGSPHERE_HINT:shadow=true,foo=bar*/";
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
statement.executeUpdate(sql);
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mappers/OrderMapper.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mappers/OrderMapper.ftl
index 81a256eca58..87adce84bf2 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mappers/OrderMapper.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/mappers/OrderMapper.ftl
@@ -41,15 +41,15 @@
<#if feature?contains("shadow")>
<update id="createTableIfNotExistsShadow">
- CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT AUTO_INCREMENT, order_type INT(11), user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id)); /*shadow:true,foo:bar*/
+ CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT AUTO_INCREMENT, order_type INT(11), user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id)); /*SHARDINGSPHERE_HINT:shadow=true,foo=bar*/
</update>
<update id="truncateTableShadow">
- TRUNCATE TABLE t_order; /*shadow:true,foo:bar*/
+ TRUNCATE TABLE t_order /*SHARDINGSPHERE_HINT:shadow=true,foo=bar*/;
</update>
<update id="dropTableShadow">
- DROP TABLE IF EXISTS t_order; /*shadow:true,foo:bar*/
+ DROP TABLE IF EXISTS t_order /*SHARDINGSPHERE_HINT:shadow=true,foo=bar*/;
</update>
<select id="selectShadowOrder" resultMap="baseResultMap">
diff --git a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/shadow.ftl b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/shadow.ftl
index 6c33d2e359e..fdc24ebde25 100644
--- a/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/shadow.ftl
+++ b/examples/shardingsphere-example-generator/src/main/resources/template/jdbc/resources/xml/shadow.ftl
@@ -23,7 +23,7 @@
</props>
</shadow:shadow-algorithm>
- <shadow:shadow-algorithm id="user-id-delete-match-algorithm" type="VALUE_MATCH">
+ <shadow:shadow-algorithm id="order-type-delete-match-algorithm" type="VALUE_MATCH">
<props>
<prop key="operation">delete</prop>
<prop key="column">order_type</prop>
@@ -31,7 +31,7 @@
</props>
</shadow:shadow-algorithm>
- <shadow:shadow-algorithm id="user-id-select-match-algorithm" type="VALUE_MATCH">
+ <shadow:shadow-algorithm id="order-type-select-match-algorithm" type="VALUE_MATCH">
<props>
<prop key="operation">select</prop>
<prop key="column">order_type</prop>
@@ -49,9 +49,9 @@
<shadow:rule id="shadowRule">
<shadow:data-source id="shadow-data-source" production-data-source-name="ds_0" shadow-data-source-name="ds_1"/>
<shadow:shadow-table name="t_order" data-sources="shadow-data-source">
- <shadow:algorithm shadow-algorithm-ref="user-id-insert-match-algorithm" />
- <shadow:algorithm shadow-algorithm-ref="user-id-delete-match-algorithm" />
- <shadow:algorithm shadow-algorithm-ref="user-id-select-match-algorithm" />
+ <shadow:algorithm shadow-algorithm-ref="order-type-insert-match-algorithm" />
+ <shadow:algorithm shadow-algorithm-ref="order-type-delete-match-algorithm" />
+ <shadow:algorithm shadow-algorithm-ref="order-type-select-match-algorithm" />
<shadow:algorithm shadow-algorithm-ref="simple-hint-algorithm" />
</shadow:shadow-table>
<shadow:default-shadow-algorithm-name name="simple-hint-algorithm"/>