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 2024/11/18 08:04:31 UTC
(shardingsphere) branch master updated: Add more test cases on ModShardingAlgorithm (#33705)
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 cd621cd2355 Add more test cases on ModShardingAlgorithm (#33705)
cd621cd2355 is described below
commit cd621cd235538dba95f5f3df6f9b45b1dfed0b6a
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Nov 18 16:04:24 2024 +0800
Add more test cases on ModShardingAlgorithm (#33705)
---
.../sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
index dea9216ecb9..5961081aaee 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/mod/ModShardingAlgorithmTest.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
+import org.apache.shardingsphere.sharding.exception.data.ShardingValueOffsetException;
import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
@@ -53,6 +54,13 @@ class ModShardingAlgorithmTest {
assertThat(algorithm.doSharding(createAvailableTargetNames(), new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, "12345678910111213141516")), is("t_order_12"));
}
+ @Test
+ void assertPreciseDoShardingWhenOffsetOverload() {
+ ModShardingAlgorithm algorithm = (ModShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "MOD", PropertiesBuilder.build(
+ new Property("sharding-count", "16"), new Property("start-offset", "10"), new Property("stop-offset", "1")));
+ assertThrows(ShardingValueOffsetException.class, () -> algorithm.doSharding(createAvailableTargetNames(), new PreciseShardingValue<>("t_order", "order_id", DATA_NODE_INFO, "1")));
+ }
+
@Test
void assertRangeDoShardingWithAllTargets() {
ModShardingAlgorithm algorithm = (ModShardingAlgorithm) TypedSPILoader.getService(ShardingAlgorithm.class, "MOD", PropertiesBuilder.build(new Property("sharding-count", "16")));