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 2020/08/19 10:54:24 UTC

[GitHub] [shardingsphere] jacksparrow414 opened a new pull request #6941: fix issue 6909

jacksparrow414 opened a new pull request #6941:
URL: https://github.com/apache/shardingsphere/pull/6941


   Fixes #6909 .
   
   Changes proposed in this pull request:
   - Add more test cases for ShardingSpringNamespaceTest
   - assertSimpleRule
   - assertComplexRule
   - assertBindingRule
   - assertBroadcastRule
   - assertAutoRule
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on a change in pull request #6941: fix issue 6909

Posted by GitBox <gi...@apache.org>.
terrymanu commented on a change in pull request #6941:
URL: https://github.com/apache/shardingsphere/pull/6941#discussion_r473859078



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
##########
@@ -163,26 +185,70 @@ public void assertOrderKeyGenerator() {
     
     @Test
     public void assertSimpleRule() {
-        // TODO
+        Collection<ShardingTableRuleConfiguration> actualSimpleRuleConfigurations = simpleRule.getTables();
+        assertFalse(actualSimpleRuleConfigurations.isEmpty());
+        assertThat(actualSimpleRuleConfigurations.size(), is(1));
+        ShardingTableRuleConfiguration actualSimpleRuleConfiguration = actualSimpleRuleConfigurations.iterator().next();
+        assertThat(actualSimpleRuleConfiguration.getLogicTable(), is("t_order"));
     }
     
     @Test
     public void assertComplexRule() {
-        // TODO
+        Collection<ShardingTableRuleConfiguration> actualComplexRuleConfigurations = complexRule.getTables();
+        assertFalse(actualComplexRuleConfigurations.isEmpty());
+        assertThat(actualComplexRuleConfigurations.size(), is(1));
+        ShardingTableRuleConfiguration actualComplexRuleConfiguration = actualComplexRuleConfigurations.iterator().next();
+        assertThat(actualComplexRuleConfiguration.getLogicTable(), is("t_order"));
+        assertThat(actualComplexRuleConfiguration.getActualDataNodes(), is("ds_$->{0..1}.t_order_$->{0..3}"));
+        assertThat(actualComplexRuleConfiguration.getDatabaseShardingStrategy().getShardingAlgorithmName(), is("dataSourceShardingAlgorithm"));
+        assertThat(actualComplexRuleConfiguration.getTableShardingStrategy().getShardingAlgorithmName(), is("orderTableShardingAlgorithm"));
+        assertThat(actualComplexRuleConfiguration.getKeyGenerateStrategy().getKeyGeneratorName(), is("incrementAlgorithm"));
+        assertThat(complexRule.getDefaultKeyGenerateStrategy().getKeyGeneratorName(), is("incrementAlgorithm"));
+        
     }
     
     @Test
     public void assertBindingRule() {
-        // TODO
+        Collection<ShardingTableRuleConfiguration> actualBindingTableRuleConfigurations = bindingRule.getTables();
+        assertFalse(actualBindingTableRuleConfigurations.isEmpty());
+        assertThat(actualBindingTableRuleConfigurations.size(), is(4));
+        Iterator<ShardingTableRuleConfiguration> actualIterator = actualBindingTableRuleConfigurations.iterator();
+        assertThat(actualIterator.next().getLogicTable(), is("t_order"));
+        assertThat(actualIterator.next().getLogicTable(), is("t_order_item"));
+        assertThat(actualIterator.next().getLogicTable(), is("t_user"));
+        assertThat(actualIterator.next().getLogicTable(), is("t_user_detail"));
+        Collection<String> actualBindingTableGroups = bindingRule.getBindingTableGroups();
+        assertFalse(actualBindingTableGroups.isEmpty());
+        assertThat(actualBindingTableGroups.size(), is(2));
+        assertTrue(actualBindingTableGroups.containsAll(Arrays.asList("t_order, t_order_item", "t_order, t_order_item")));
     }
     
     @Test
     public void assertBroadcastRule() {
-        // TODO
+        Collection<ShardingTableRuleConfiguration> actualBroadcastTableConfigurations = broadcastRule.getTables();
+        assertFalse(actualBroadcastTableConfigurations.isEmpty());
+        assertThat(actualBroadcastTableConfigurations.size(), is(2));
+        Iterator<ShardingTableRuleConfiguration> actualIterator = actualBroadcastTableConfigurations.iterator();
+        assertThat(actualIterator.next().getLogicTable(), is("t_order"));
+        assertThat(actualIterator.next().getLogicTable(), is("t_order_item"));
+        Collection<String> broadcastTables = broadcastRule.getBroadcastTables();
+        assertFalse(broadcastTables.isEmpty());
+        assertThat(broadcastTables.size(), is(2));

Review comment:
       It is unnecessary for assert both `broadcastTables.isEmpty()` and assert `size is 2`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls commented on pull request #6941: fix issue 6909

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #6941:
URL: https://github.com/apache/shardingsphere/pull/6941#issuecomment-676249306


   ## Pull Request Test Coverage Report for [Build 13920](https://coveralls.io/builds/32857461)
   
   * **0** of **0**   changed or added relevant lines in **0** files are covered.
   * No unchanged relevant lines lost coverage.
   * Overall coverage remained the same at **60.301%**
   
   ---
   
   
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/32857461/badge)](https://coveralls.io/builds/32857461) |
   | :-- | --: |
   | Change from base [Build 13918](https://coveralls.io/builds/32856926): |  0.0% |
   | Covered Lines: | 13713 |
   | Relevant Lines: | 22741 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jacksparrow414 commented on a change in pull request #6941: fix issue 6909

Posted by GitBox <gi...@apache.org>.
jacksparrow414 commented on a change in pull request #6941:
URL: https://github.com/apache/shardingsphere/pull/6941#discussion_r473930851



##########
File path: shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
##########
@@ -163,26 +185,70 @@ public void assertOrderKeyGenerator() {
     
     @Test
     public void assertSimpleRule() {
-        // TODO
+        Collection<ShardingTableRuleConfiguration> actualSimpleRuleConfigurations = simpleRule.getTables();
+        assertFalse(actualSimpleRuleConfigurations.isEmpty());
+        assertThat(actualSimpleRuleConfigurations.size(), is(1));
+        ShardingTableRuleConfiguration actualSimpleRuleConfiguration = actualSimpleRuleConfigurations.iterator().next();
+        assertThat(actualSimpleRuleConfiguration.getLogicTable(), is("t_order"));
     }
     
     @Test
     public void assertComplexRule() {
-        // TODO
+        Collection<ShardingTableRuleConfiguration> actualComplexRuleConfigurations = complexRule.getTables();
+        assertFalse(actualComplexRuleConfigurations.isEmpty());
+        assertThat(actualComplexRuleConfigurations.size(), is(1));
+        ShardingTableRuleConfiguration actualComplexRuleConfiguration = actualComplexRuleConfigurations.iterator().next();
+        assertThat(actualComplexRuleConfiguration.getLogicTable(), is("t_order"));
+        assertThat(actualComplexRuleConfiguration.getActualDataNodes(), is("ds_$->{0..1}.t_order_$->{0..3}"));
+        assertThat(actualComplexRuleConfiguration.getDatabaseShardingStrategy().getShardingAlgorithmName(), is("dataSourceShardingAlgorithm"));
+        assertThat(actualComplexRuleConfiguration.getTableShardingStrategy().getShardingAlgorithmName(), is("orderTableShardingAlgorithm"));
+        assertThat(actualComplexRuleConfiguration.getKeyGenerateStrategy().getKeyGeneratorName(), is("incrementAlgorithm"));
+        assertThat(complexRule.getDefaultKeyGenerateStrategy().getKeyGeneratorName(), is("incrementAlgorithm"));
+        
     }
     
     @Test
     public void assertBindingRule() {
-        // TODO
+        Collection<ShardingTableRuleConfiguration> actualBindingTableRuleConfigurations = bindingRule.getTables();
+        assertFalse(actualBindingTableRuleConfigurations.isEmpty());
+        assertThat(actualBindingTableRuleConfigurations.size(), is(4));
+        Iterator<ShardingTableRuleConfiguration> actualIterator = actualBindingTableRuleConfigurations.iterator();
+        assertThat(actualIterator.next().getLogicTable(), is("t_order"));
+        assertThat(actualIterator.next().getLogicTable(), is("t_order_item"));
+        assertThat(actualIterator.next().getLogicTable(), is("t_user"));
+        assertThat(actualIterator.next().getLogicTable(), is("t_user_detail"));
+        Collection<String> actualBindingTableGroups = bindingRule.getBindingTableGroups();
+        assertFalse(actualBindingTableGroups.isEmpty());
+        assertThat(actualBindingTableGroups.size(), is(2));
+        assertTrue(actualBindingTableGroups.containsAll(Arrays.asList("t_order, t_order_item", "t_order, t_order_item")));
     }
     
     @Test
     public void assertBroadcastRule() {
-        // TODO
+        Collection<ShardingTableRuleConfiguration> actualBroadcastTableConfigurations = broadcastRule.getTables();
+        assertFalse(actualBroadcastTableConfigurations.isEmpty());
+        assertThat(actualBroadcastTableConfigurations.size(), is(2));
+        Iterator<ShardingTableRuleConfiguration> actualIterator = actualBroadcastTableConfigurations.iterator();
+        assertThat(actualIterator.next().getLogicTable(), is("t_order"));
+        assertThat(actualIterator.next().getLogicTable(), is("t_order_item"));
+        Collection<String> broadcastTables = broadcastRule.getBroadcastTables();
+        assertFalse(broadcastTables.isEmpty());
+        assertThat(broadcastTables.size(), is(2));

Review comment:
       fixed




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] coveralls edited a comment on pull request #6941: fix issue 6909

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #6941:
URL: https://github.com/apache/shardingsphere/pull/6941#issuecomment-676249306


   ## Pull Request Test Coverage Report for [Build 13933](https://coveralls.io/builds/32883024)
   
   * **38** of **78**   **(48.72%)**  changed or added relevant lines in **8** files are covered.
   * **1** unchanged line in **1** file lost coverage.
   * Overall coverage decreased (**-0.008%**) to **60.292%**
   
   ---
   
   |  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
   | :-----|--------------|--------|---: |
   | [shardingsphere-control-panel/shardingsphere-orchestration/shardingsphere-orchestration-core/shardingsphere-orchestration-core-config/src/main/java/org/apache/shardingsphere/orchestration/core/config/ConfigCenter.java](https://coveralls.io/builds/32883024/source?filename=shardingsphere-control-panel%2Fshardingsphere-orchestration%2Fshardingsphere-orchestration-core%2Fshardingsphere-orchestration-core-config%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Forchestration%2Fcore%2Fconfig%2FConfigCenter.java#L138) | 2 | 4 | 50.0%
   | [shardingsphere-jdbc/shardingsphere-jdbc-orchestration/src/main/java/org/apache/shardingsphere/driver/orchestration/api/OrchestrationShardingSphereDataSourceFactory.java](https://coveralls.io/builds/32883024/source?filename=shardingsphere-jdbc%2Fshardingsphere-jdbc-orchestration%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fdriver%2Forchestration%2Fapi%2FOrchestrationShardingSphereDataSourceFactory.java#L106) | 0 | 4 | 0.0%
   | [shardingsphere-rdl-parser/shardingsphere-rdl-parser-binder/src/main/java/org/apache/shardingsphere/rdl/parser/binder/util/ShardingAlgorithmPropertiesUtil.java](https://coveralls.io/builds/32883024/source?filename=shardingsphere-rdl-parser%2Fshardingsphere-rdl-parser-binder%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Frdl%2Fparser%2Fbinder%2Futil%2FShardingAlgorithmPropertiesUtil.java#L56) | 0 | 5 | 0.0%
   | [shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-orchestration-spring/shardingsphere-jdbc-orchestration-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/orchestration/OrchestrationSpringBootConfiguration.java](https://coveralls.io/builds/32883024/source?filename=shardingsphere-jdbc%2Fshardingsphere-jdbc-spring%2Fshardingsphere-jdbc-orchestration-spring%2Fshardingsphere-jdbc-orchestration-spring-boot-starter%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fspring%2Fboot%2Forchestration%2FOrchestrationSpringBootConfiguration.java#L130) | 6 | 12 | 50.0%
   | [shardingsphere-jdbc/shardingsphere-jdbc-orchestration/src/main/java/org/apache/shardingsphere/driver/orchestration/api/yaml/YamlOrchestrationShardingSphereDataSourceFactory.java](https://coveralls.io/builds/32883024/source?filename=shardingsphere-jdbc%2Fshardingsphere-jdbc-orchestration%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fdriver%2Forchestration%2Fapi%2Fyaml%2FYamlOrchestrationShardingSphereDataSourceFactory.java#L88) | 11 | 22 | 50.0%
   | [shardingsphere-jdbc/shardingsphere-jdbc-orchestration/src/main/java/org/apache/shardingsphere/driver/orchestration/internal/datasource/OrchestrationShardingSphereDataSource.java](https://coveralls.io/builds/32883024/source?filename=shardingsphere-jdbc%2Fshardingsphere-jdbc-orchestration%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fdriver%2Forchestration%2Finternal%2Fdatasource%2FOrchestrationShardingSphereDataSource.java#L102) | 12 | 24 | 50.0%
   <!-- | **Total:** | **38** | **78** | **48.72%** | -->
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-jdbc/shardingsphere-jdbc-orchestration/src/main/java/org/apache/shardingsphere/driver/orchestration/internal/datasource/OrchestrationShardingSphereDataSource.java](https://coveralls.io/builds/32883024/source?filename=shardingsphere-jdbc%2Fshardingsphere-jdbc-orchestration%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fdriver%2Forchestration%2Finternal%2Fdatasource%2FOrchestrationShardingSphereDataSource.java#L167) | 1 | 62.33% |
   <!-- | **Total:** | **1** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/32883024/badge)](https://coveralls.io/builds/32883024) |
   | :-- | --: |
   | Change from base [Build 13918](https://coveralls.io/builds/32856926): |  -0.008% |
   | Covered Lines: | 13731 |
   | Relevant Lines: | 22774 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu merged pull request #6941: fix issue 6909

Posted by GitBox <gi...@apache.org>.
terrymanu merged pull request #6941:
URL: https://github.com/apache/shardingsphere/pull/6941


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org