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 2025/11/13 13:31:21 UTC
(shardingsphere) branch master updated: Add ShardingPipelineYamlRuleConfigurationReviserTest (#37090)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 99be329727c Add ShardingPipelineYamlRuleConfigurationReviserTest (#37090)
99be329727c is described below
commit 99be329727c41347a148e400b076ee2a2955bab9
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Nov 13 21:31:15 2025 +0800
Add ShardingPipelineYamlRuleConfigurationReviserTest (#37090)
* Add ShardingPipelineYamlRuleConfigurationReviserTest
* Add ShardingPipelineYamlRuleConfigurationReviserTest
---
AGENTS.md | 2 +-
...ardingPipelineYamlRuleConfigurationReviser.java | 2 +-
...ngPipelineYamlRuleConfigurationReviserTest.java | 94 ++++++++++++++++++++++
3 files changed, 96 insertions(+), 2 deletions(-)
diff --git a/AGENTS.md b/AGENTS.md
index 4714b90b210..22b4612e731 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -46,7 +46,7 @@ Mention which topology you target, the registry used, and any compatibility cons
## AI Execution Workflow
1. **Intake & Clarify** — restate the ask, map affected modules, confirm sandbox/approval/network constraints.
-2. **Plan & Reason** — write a multi-step plan with checkpoints (analysis, edits, tests). Align scope with release tempo (prefer incremental fixes unless told otherwise).
+2. **Plan & Reason** — write a multi-step plan with checkpoints (analysis, edits, tests). Align scope with release tempo (prefer incremental fixes unless told otherwise). When the user demands precise branch coverage or “minimum test” constraints, first enumerate the target branches and map each to the single test case that will cover it before touching code.
3. **Implement** — touch only necessary files, reuse abstractions, keep ASF headers.
4. **Validate** — choose the smallest meaningful command, announce the intent before execution, summarize exit codes afterward; if blocked (sandbox, missing deps), explain what would have run and why it matters.
5. **Report** — lead with intent, list edited files with rationale and line references, state verification results, propose next actions.
diff --git a/kernel/data-pipeline/feature/sharding/src/main/java/org/apache/shardingsphere/data/pipeline/sharding/ShardingPipelineYamlRuleConfigurationReviser.java b/kernel/data-pipeline/feature/sharding/src/main/java/org/apache/shardingsphere/data/pipeline/sharding/ShardingPipelineYamlRuleConfigurationReviser.java
index a7645d7a7c1..535dd9cb16e 100644
--- a/kernel/data-pipeline/feature/sharding/src/main/java/org/apache/shardingsphere/data/pipeline/sharding/ShardingPipelineYamlRuleConfigurationReviser.java
+++ b/kernel/data-pipeline/feature/sharding/src/main/java/org/apache/shardingsphere/data/pipeline/sharding/ShardingPipelineYamlRuleConfigurationReviser.java
@@ -36,7 +36,7 @@ public final class ShardingPipelineYamlRuleConfigurationReviser implements Pipel
private void enableRangeQueryForInline(final YamlShardingRuleConfiguration yamlRuleConfig) {
for (YamlAlgorithmConfiguration each : yamlRuleConfig.getShardingAlgorithms().values()) {
if ("INLINE".equalsIgnoreCase(each.getType()) || "COMPLEX_INLINE".equalsIgnoreCase(each.getType())) {
- each.getProps().put("allow-range-query-with-inline-sharding", Boolean.TRUE.toString());
+ each.getProps().setProperty("allow-range-query-with-inline-sharding", Boolean.TRUE.toString());
}
}
}
diff --git a/kernel/data-pipeline/feature/sharding/src/test/java/org/apache/shardingsphere/data/pipeline/sharding/ShardingPipelineYamlRuleConfigurationReviserTest.java b/kernel/data-pipeline/feature/sharding/src/test/java/org/apache/shardingsphere/data/pipeline/sharding/ShardingPipelineYamlRuleConfigurationReviserTest.java
new file mode 100644
index 00000000000..86e26cfa974
--- /dev/null
+++ b/kernel/data-pipeline/feature/sharding/src/test/java/org/apache/shardingsphere/data/pipeline/sharding/ShardingPipelineYamlRuleConfigurationReviserTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.data.pipeline.sharding;
+
+import org.apache.shardingsphere.data.pipeline.core.datasource.yaml.PipelineYamlRuleConfigurationReviser;
+import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
+import org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
+import org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
+import org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class ShardingPipelineYamlRuleConfigurationReviserTest {
+
+ @SuppressWarnings("unchecked")
+ private final PipelineYamlRuleConfigurationReviser<YamlShardingRuleConfiguration> reviser = (PipelineYamlRuleConfigurationReviser<YamlShardingRuleConfiguration>) OrderedSPILoader
+ .getServicesByClass(PipelineYamlRuleConfigurationReviser.class, Collections.singleton(YamlShardingRuleConfiguration.class)).get(YamlShardingRuleConfiguration.class);
+
+ @Test
+ void assertReviseInlineAlgorithmsAndAuditStrategies() {
+ YamlShardingRuleConfiguration yamlConfig = new YamlShardingRuleConfiguration();
+ yamlConfig.getShardingAlgorithms().put("inline", createAlgorithm("INLINE"));
+ yamlConfig.getShardingAlgorithms().put("complex_inline", createAlgorithm("complex_inline"));
+ yamlConfig.getShardingAlgorithms().put("hash_mod", createAlgorithm("HASH_MOD"));
+ yamlConfig.setDefaultAuditStrategy(new YamlShardingAuditStrategyConfiguration());
+ yamlConfig.getAuditors().put("fixture_auditor", createAlgorithm("SQL_HINT"));
+ yamlConfig.getTables().put("t_order", createTableRuleWithAudit());
+ yamlConfig.getAutoTables().put("t_auto", createAutoTableRuleWithAudit());
+ reviser.revise(yamlConfig);
+ assertThat(yamlConfig.getShardingAlgorithms().get("inline").getProps().getProperty("allow-range-query-with-inline-sharding"), is(Boolean.TRUE.toString()));
+ assertThat(yamlConfig.getShardingAlgorithms().get("complex_inline").getProps().getProperty("allow-range-query-with-inline-sharding"), is(Boolean.TRUE.toString()));
+ assertNull(yamlConfig.getShardingAlgorithms().get("hash_mod").getProps().getProperty("allow-range-query-with-inline-sharding"));
+ assertNull(yamlConfig.getDefaultAuditStrategy());
+ assertNull(yamlConfig.getAuditors());
+ assertNull(yamlConfig.getTables().get("t_order").getAuditStrategy());
+ assertNull(yamlConfig.getAutoTables().get("t_auto").getAuditStrategy());
+ }
+
+ @Test
+ void assertReviseWhenTablesAbsent() {
+ YamlShardingRuleConfiguration yamlConfig = new YamlShardingRuleConfiguration();
+ yamlConfig.setTables(null);
+ yamlConfig.setAutoTables(null);
+ yamlConfig.setDefaultAuditStrategy(new YamlShardingAuditStrategyConfiguration());
+ yamlConfig.setAuditors(Collections.singletonMap("auditor", createAlgorithm("SQL_HINT")));
+ reviser.revise(yamlConfig);
+ assertNull(yamlConfig.getTables());
+ assertNull(yamlConfig.getAutoTables());
+ assertNull(yamlConfig.getDefaultAuditStrategy());
+ assertNull(yamlConfig.getAuditors());
+ }
+
+ private YamlAlgorithmConfiguration createAlgorithm(final String type) {
+ YamlAlgorithmConfiguration result = new YamlAlgorithmConfiguration();
+ result.setType(type);
+ return result;
+ }
+
+ private YamlTableRuleConfiguration createTableRuleWithAudit() {
+ YamlTableRuleConfiguration result = new YamlTableRuleConfiguration();
+ result.setLogicTable("t_order");
+ result.setAuditStrategy(new YamlShardingAuditStrategyConfiguration());
+ return result;
+ }
+
+ private YamlShardingAutoTableRuleConfiguration createAutoTableRuleWithAudit() {
+ YamlShardingAutoTableRuleConfiguration result = new YamlShardingAutoTableRuleConfiguration();
+ result.setLogicTable("t_auto");
+ result.setAuditStrategy(new YamlShardingAuditStrategyConfiguration());
+ return result;
+ }
+}