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 e878d615ceb Add more test cases on VolumeBasedRangeShardingAlgorithm
(#33706)
e878d615ceb is described below
commit e878d615ceb426b9c7aa9316ca9ecc83152b0242
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Nov 18 16:10:56 2024 +0800
Add more test cases on VolumeBasedRangeShardingAlgorithm (#33706)
---
.../sharding/range/VolumeBasedRangeShardingAlgorithmTest.java | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithmTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithmTest.java
index e4d22337223..ee2e5f290eb 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithmTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/range/VolumeBasedRangeShardingAlgorithmTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.sharding.algorithm.sharding.range;
import com.google.common.collect.Range;
+import
org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
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;
@@ -35,6 +36,7 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
class VolumeBasedRangeShardingAlgorithmTest {
@@ -52,6 +54,12 @@ class VolumeBasedRangeShardingAlgorithmTest {
return PropertiesBuilder.build(new Property("range-lower", "10"), new
Property("range-upper", "45"), new Property("sharding-volume", "10"));
}
+ @Test
+ void assertInitFailedWithInvalidRange() {
+ assertThrows(AlgorithmInitializationException.class, () ->
TypedSPILoader.getService(ShardingAlgorithm.class, "VOLUME_RANGE",
+ PropertiesBuilder.build(new Property("range-lower", "20"), new
Property("range-upper", "15"), new Property("sharding-volume", "10"))));
+ }
+
@Test
void assertPreciseDoSharding() {
assertPreciseDoSharding(new PreciseShardingValue<>("t_order",
"order_id", DATA_NODE_INFO, 0L));