You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "heliang666s (via GitHub)" <gi...@apache.org> on 2025/01/22 16:52:43 UTC

[PR] Refactoring Metadata Unit Tests [dubbo]

heliang666s opened a new pull request, #15089:
URL: https://github.com/apache/dubbo/pull/15089

   ## What is the purpose of the change?
   Refactoring Metadata Unit Tests
   
   ## Checklist
   - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) field for the change.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in [dubbo samples](https://github.com/apache/dubbo-samples) project.
   - [x] Make sure gitHub actions can pass. [Why the workflow is failing and how to fix it?](../CONTRIBUTING.md)
   


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

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Refactoring Metadata Unit Tests [dubbo]

Posted by "CrazyHZM (via GitHub)" <gi...@apache.org>.
CrazyHZM commented on code in PR #15089:
URL: https://github.com/apache/dubbo/pull/15089#discussion_r1928823637


##########
dubbo-metadata/dubbo-metadata-report-zookeeper/src/test/java/org/apache/dubbo/metadata/store/zookeeper/ZookeeperMetadataReportTest.java:
##########
@@ -30,47 +29,79 @@
 import org.apache.dubbo.metadata.report.identifier.MetadataIdentifier;
 import org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier;
 import org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier;
-import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClient;
+import org.apache.dubbo.remoting.zookeeper.curator5.ZookeeperClientManager;
 
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
 
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE;
 import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
 import static org.apache.dubbo.metadata.ServiceNameMapping.DEFAULT_MAPPING_GROUP;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class ZookeeperMetadataReportTest {
 
-/**
- * 2018/10/9
- */
-class ZookeeperMetadataReportTest {
     private ZookeeperMetadataReport zookeeperMetadataReport;
-    private URL registryUrl;
-    private ZookeeperMetadataReportFactory zookeeperMetadataReportFactory;
-    private static String zookeeperConnectionAddress1;
 
-    @BeforeAll
-    public static void beforeAll() {
-        zookeeperConnectionAddress1 = System.getProperty("zookeeper.connection.address.1");
-    }
+    /**
+     * Uses Map<String, String> to simulate ZK node storage:
+     * key corresponds to the ZK node path, and value corresponds to the node content.
+     */
+    private final Map<String, String> zkDataStore = new ConcurrentHashMap<>();

Review Comment:
   Now that we've mocked `ZookeeperClient`, I think we can simulate the return result directly without actually storing it and spread the `setUp` logic across each unit test.
   



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

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Refactoring Metadata Unit Tests [dubbo]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #15089:
URL: https://github.com/apache/dubbo/pull/15089#issuecomment-2607804093

   ## [Codecov](https://app.codecov.io/gh/apache/dubbo/pull/15089?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   All modified and coverable lines are covered by tests :white_check_mark:
   > Project coverage is 29.21%. Comparing base [(`628dcbf`)](https://app.codecov.io/gh/apache/dubbo/commit/628dcbfcc68657417fa11948d61f42df3edca0d7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`63980a4`)](https://app.codecov.io/gh/apache/dubbo/commit/63980a4b3f66bd487ec0ecbf27f29e854ced4bfe?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   
   > :exclamation:  There is a different number of reports uploaded between BASE (628dcbf) and HEAD (63980a4). Click for more details.
   > 
   > <details><summary>HEAD has 2 uploads less than BASE</summary>
   >
   >| Flag | BASE (628dcbf) | HEAD (63980a4) |
   >|------|------|------|
   >|integration-tests|1|0|
   >|unit-tests|1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@              Coverage Diff              @@
   ##                3.3   #15089       +/-   ##
   =============================================
   - Coverage     60.76%   29.21%   -31.56%     
   + Complexity    10863     8871     -1992     
   =============================================
     Files          1882     1882               
     Lines         86007    86007               
     Branches      12886    12886               
   =============================================
   - Hits          52263    25127    -27136     
   - Misses        28301    56909    +28608     
   + Partials       5443     3971     -1472     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/dubbo/pull/15089/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [integration-tests](https://app.codecov.io/gh/apache/dubbo/pull/15089/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [samples-tests](https://app.codecov.io/gh/apache/dubbo/pull/15089/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `29.21% <ø> (-0.01%)` | :arrow_down: |
   | [unit-tests](https://app.codecov.io/gh/apache/dubbo/pull/15089/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/dubbo/pull/15089?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


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

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [PR] Refactoring Metadata Unit Tests [dubbo]

Posted by "heliang666s (via GitHub)" <gi...@apache.org>.
heliang666s closed pull request #15089: Refactoring Metadata Unit Tests
URL: https://github.com/apache/dubbo/pull/15089


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

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org