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/11/12 01:45:51 UTC

[GitHub] [shardingsphere] wenweibin opened a new pull request #8141: 8067

wenweibin opened a new pull request #8141:
URL: https://github.com/apache/shardingsphere/pull/8141


   Fixes #8067.
   
   Changes proposed in this pull request:
   - Use mock to instead of TestShardingRule and TestTableRule in DataNodesTest class.
   -
   -
   


----------------------------------------------------------------
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] kimmking merged pull request #8141: Use mock to instead of TestShardingRule and TestTableRule in DataNodesTest class

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


   


----------------------------------------------------------------
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] wenweibin commented on a change in pull request #8141: Use mock to instead of TestShardingRule and TestTableRule in DataNodesTest class

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



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/DataNodesTest.java
##########
@@ -79,18 +77,19 @@ public void assertGetDataNodeGroups() {
     }
     
     private DataNodes getRoutedRuleDataNodes() {
-        TestTableRule tableRule1 = new TestTableRule(dataSourceNames1, logicTableName1);
-        TestTableRule tableRule2 = new TestTableRule(dataSourceNames2, logicTableName2);
-        List<TestTableRule> tableRules = Arrays.asList(tableRule1, tableRule2);
-        ShardingSphereRule rule1 = new TestShardingRule(tableRules);
+        Map<String, Collection<DataNode>> nodeMap = new HashMap<>();
+        nodeMap.put(logicTableName1, getExpectedDataNodes(dataSourceNames1, logicTableName1));
+        nodeMap.put(logicTableName2, getExpectedDataNodes(dataSourceNames2, logicTableName2));
+        DataNodeContainedRule rule1 = mock(DataNodeContainedRule.class);
+        when(rule1.getAllDataNodes()).thenReturn(nodeMap);
         Map<String, Collection<String>> dataSourceMapper = Collections.singletonMap(logicDataSourceName, replicaDataSourceNames);
         DataSourceContainedRule rule2 = mock(DataSourceContainedRule.class);
         when(rule2.getDataSourceMapper()).thenReturn(dataSourceMapper);
         return new DataNodes(Arrays.asList(rule1, rule2));
     }
     
     private DataNodes getNonRoutedRuleDataNodes() {
-        return new DataNodes(Collections.singleton(new TestShardingSphereRule()));

Review comment:
       Yes.I will delete them.




----------------------------------------------------------------
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] tristaZero commented on a change in pull request #8141: Use mock to instead of TestShardingRule and TestTableRule in DataNodesTest class

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



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/DataNodesTest.java
##########
@@ -79,18 +77,19 @@ public void assertGetDataNodeGroups() {
     }
     
     private DataNodes getRoutedRuleDataNodes() {
-        TestTableRule tableRule1 = new TestTableRule(dataSourceNames1, logicTableName1);
-        TestTableRule tableRule2 = new TestTableRule(dataSourceNames2, logicTableName2);
-        List<TestTableRule> tableRules = Arrays.asList(tableRule1, tableRule2);
-        ShardingSphereRule rule1 = new TestShardingRule(tableRules);
+        Map<String, Collection<DataNode>> nodeMap = new HashMap<>();
+        nodeMap.put(logicTableName1, getExpectedDataNodes(dataSourceNames1, logicTableName1));
+        nodeMap.put(logicTableName2, getExpectedDataNodes(dataSourceNames2, logicTableName2));
+        DataNodeContainedRule rule1 = mock(DataNodeContainedRule.class);
+        when(rule1.getAllDataNodes()).thenReturn(nodeMap);
         Map<String, Collection<String>> dataSourceMapper = Collections.singletonMap(logicDataSourceName, replicaDataSourceNames);
         DataSourceContainedRule rule2 = mock(DataSourceContainedRule.class);
         when(rule2.getDataSourceMapper()).thenReturn(dataSourceMapper);
         return new DataNodes(Arrays.asList(rule1, rule2));
     }
     
     private DataNodes getNonRoutedRuleDataNodes() {
-        return new DataNodes(Collections.singleton(new TestShardingSphereRule()));

Review comment:
       Hi @wenweibin 
   Do you think `TestShardingSphereRule` is no longer needed? If so, please delete them. Thanks.




----------------------------------------------------------------
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] kimmking commented on a change in pull request #8141: Use mock to instead of TestShardingRule and TestTableRule in DataNodesTest class

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



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/DataNodesTest.java
##########
@@ -40,59 +39,60 @@
 import static org.mockito.Mockito.when;
 
 public final class DataNodesTest {
-    

Review comment:
       keep four blank.




----------------------------------------------------------------
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] tristaZero commented on a change in pull request #8141: Use mock to instead of TestShardingRule and TestTableRule in DataNodesTest class

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



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/DataNodesTest.java
##########
@@ -79,18 +77,19 @@ public void assertGetDataNodeGroups() {
     }
     
     private DataNodes getRoutedRuleDataNodes() {
-        TestTableRule tableRule1 = new TestTableRule(dataSourceNames1, logicTableName1);
-        TestTableRule tableRule2 = new TestTableRule(dataSourceNames2, logicTableName2);
-        List<TestTableRule> tableRules = Arrays.asList(tableRule1, tableRule2);
-        ShardingSphereRule rule1 = new TestShardingRule(tableRules);
+        Map<String, Collection<DataNode>> nodeMap = new HashMap<>();
+        nodeMap.put(logicTableName1, getExpectedDataNodes(dataSourceNames1, logicTableName1));
+        nodeMap.put(logicTableName2, getExpectedDataNodes(dataSourceNames2, logicTableName2));
+        DataNodeContainedRule rule1 = mock(DataNodeContainedRule.class);
+        when(rule1.getAllDataNodes()).thenReturn(nodeMap);
         Map<String, Collection<String>> dataSourceMapper = Collections.singletonMap(logicDataSourceName, replicaDataSourceNames);
         DataSourceContainedRule rule2 = mock(DataSourceContainedRule.class);
         when(rule2.getDataSourceMapper()).thenReturn(dataSourceMapper);
         return new DataNodes(Arrays.asList(rule1, rule2));
     }
     
     private DataNodes getNonRoutedRuleDataNodes() {
-        return new DataNodes(Collections.singleton(new TestShardingSphereRule()));

Review comment:
       You will remove them in the next PR, won't you?




----------------------------------------------------------------
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] codecov-io commented on pull request #8141: Use mock to instead of TestShardingRule and TestTableRule in DataNodesTest class

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #8141:
URL: https://github.com/apache/shardingsphere/pull/8141#issuecomment-729631257


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8141?src=pr&el=h1) Report
   > Merging [#8141](https://codecov.io/gh/apache/shardingsphere/pull/8141?src=pr&el=desc) (ce49f0b) into [master](https://codecov.io/gh/apache/shardingsphere/commit/91992382630be957694eb268f219e1ac2f49e568?el=desc) (9199238) will **decrease** coverage by `0.03%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/8141/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/8141?src=pr&el=tree)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #8141      +/-   ##
   ============================================
   - Coverage     75.25%   75.22%   -0.04%     
     Complexity      579      579              
   ============================================
     Files          1466     1466              
     Lines         23219    23219              
     Branches       4154     4154              
   ============================================
   - Hits          17473    17466       -7     
   - Misses         4607     4612       +5     
   - Partials       1139     1141       +2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/8141?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...pache/shardingsphere/infra/datanode/DataNodes.java](https://codecov.io/gh/apache/shardingsphere/pull/8141/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kYXRhbm9kZS9EYXRhTm9kZXMuamF2YQ==) | `68.00% <0.00%> (-32.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...osition/resume/ResumeBreakPointManagerFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/8141/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2IvcG9zaXRpb24vcmVzdW1lL1Jlc3VtZUJyZWFrUG9pbnRNYW5hZ2VyRmFjdG9yeS5qYXZh) | `75.00% <0.00%> (-12.50%)` | `0.00% <0.00%> (ø%)` | |
   | [...ext/transaction/GovernanceTransactionContexts.java](https://codecov.io/gh/apache/shardingsphere/pull/8141/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS9zaGFyZGluZ3NwaGVyZS1nb3Zlcm5hbmNlLWNvcmUvc2hhcmRpbmdzcGhlcmUtZ292ZXJuYW5jZS1jb3JlLWNvbnRleHQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2dvdmVybmFuY2UvY29udGV4dC90cmFuc2FjdGlvbi9Hb3Zlcm5hbmNlVHJhbnNhY3Rpb25Db250ZXh0cy5qYXZh) | `93.33% <0.00%> (-6.67%)` | `0.00% <0.00%> (ø%)` | |
   | [...b/preparer/splitter/InventoryDataTaskSplitter.java](https://codecov.io/gh/apache/shardingsphere/pull/8141/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9qb2IvcHJlcGFyZXIvc3BsaXR0ZXIvSW52ZW50b3J5RGF0YVRhc2tTcGxpdHRlci5qYXZh) | `88.05% <0.00%> (-4.48%)` | `0.00% <0.00%> (ø%)` | |
   | [...re/scaling/core/schedule/ScalingTaskScheduler.java](https://codecov.io/gh/apache/shardingsphere/pull/8141/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9zY2hlZHVsZS9TY2FsaW5nVGFza1NjaGVkdWxlci5qYXZh) | `83.01% <0.00%> (+1.88%)` | `0.00% <0.00%> (ø%)` | |
   | [...re/execute/executor/dumper/AbstractJDBCDumper.java](https://codecov.io/gh/apache/shardingsphere/pull/8141/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9leGVjdXRlL2V4ZWN1dG9yL2R1bXBlci9BYnN0cmFjdEpEQkNEdW1wZXIuamF2YQ==) | `88.09% <0.00%> (+4.76%)` | `0.00% <0.00%> (ø%)` | |
   | [...scaling/core/service/RegistryRepositoryHolder.java](https://codecov.io/gh/apache/shardingsphere/pull/8141/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9zZXJ2aWNlL1JlZ2lzdHJ5UmVwb3NpdG9yeUhvbGRlci5qYXZh) | `100.00% <0.00%> (+5.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...ere/scaling/core/utils/RdbmsConfigurationUtil.java](https://codecov.io/gh/apache/shardingsphere/pull/8141/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS91dGlscy9SZGJtc0NvbmZpZ3VyYXRpb25VdGlsLmphdmE=) | `80.00% <0.00%> (+40.00%)` | `0.00% <0.00%> (ø%)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8141?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8141?src=pr&el=footer). Last update [9199238...ce49f0b](https://codecov.io/gh/apache/shardingsphere/pull/8141?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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] wenweibin commented on a change in pull request #8141: Use mock to instead of TestShardingRule and TestTableRule in DataNodesTest class

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



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/DataNodesTest.java
##########
@@ -79,18 +77,19 @@ public void assertGetDataNodeGroups() {
     }
     
     private DataNodes getRoutedRuleDataNodes() {
-        TestTableRule tableRule1 = new TestTableRule(dataSourceNames1, logicTableName1);
-        TestTableRule tableRule2 = new TestTableRule(dataSourceNames2, logicTableName2);
-        List<TestTableRule> tableRules = Arrays.asList(tableRule1, tableRule2);
-        ShardingSphereRule rule1 = new TestShardingRule(tableRules);
+        Map<String, Collection<DataNode>> nodeMap = new HashMap<>();
+        nodeMap.put(logicTableName1, getExpectedDataNodes(dataSourceNames1, logicTableName1));
+        nodeMap.put(logicTableName2, getExpectedDataNodes(dataSourceNames2, logicTableName2));
+        DataNodeContainedRule rule1 = mock(DataNodeContainedRule.class);
+        when(rule1.getAllDataNodes()).thenReturn(nodeMap);
         Map<String, Collection<String>> dataSourceMapper = Collections.singletonMap(logicDataSourceName, replicaDataSourceNames);
         DataSourceContainedRule rule2 = mock(DataSourceContainedRule.class);
         when(rule2.getDataSourceMapper()).thenReturn(dataSourceMapper);
         return new DataNodes(Arrays.asList(rule1, rule2));
     }
     
     private DataNodes getNonRoutedRuleDataNodes() {
-        return new DataNodes(Collections.singleton(new TestShardingSphereRule()));

Review comment:
       OK.I will finish it in next pr.




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