You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "pdolif (via GitHub)" <gi...@apache.org> on 2025/10/14 18:22:39 UTC

[PR] [fix][test] Fix flaky LookupPropertiesTest.testConcurrentLookupProperties [pulsar]

pdolif opened a new pull request, #24854:
URL: https://github.com/apache/pulsar/pull/24854

   Fixes #24837
   
   ### Motivation
   
   The test is flaky. It verifies that lookup requests use the lookup properties configured at the time when the request is triggered (and not at the time it is executed).
   Therefore, it triggers 10 broker lookups in sequence and changes the lookup properties before each. The property "broker.id" is set to "key-0", "key-1",..., "key-9" respectively. To verify that the correct properties are used, the test uses the `BrokerIdAwareLoadManager`, which extends `ExtensibleLoadManagerImpl`. It stores a `CLIENT_ID_LIST`. When `assign()` is called, the "broker.id" property is added to the `CLIENT_ID_LIST`. 
   The test waits until all lookup requests finish, and then asserts that `CLIENT_ID_LIST` is equal to "key-0", "key-1",..., "key-9". The assertion fails if the list contains the values in a different order.
   
   When running the tests, I noticed that the order is either "key-0", "key-1",..., "key-9" (ascending) or the reverse order. The reason seems to be related to CompletableFuture "callbacks" like `thenCompose()` and their execution order. For example, for each of the 10 lookup requests, `NamespaceService.getBrokerServiceUrlAsync()` is called (in sequence), which contains the following code:
   
   https://github.com/apache/pulsar/blob/461ffd84d641b855fcc0d09d586ff4b580c21974/pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java#L225-L226
   
   When `thenCompose()` is called, it can either be that the `getBundleAsync(topic)` CompletableFuture is completed or not. If it is completed, `thenCompose()` can be executed immediately for each of the 10 lookup requests. The test passes. If it is not completed, `thenCompose()` is called 10 times but not executed immediately. It seems like the "callbacks" are stacked. Once the CompletableFuture completes, the 10 "callbacks" are executed in LIFO order, i.e., the one for "key-9" is executed first. Therefore, the order in `CLIENT_ID_LIST` will be reversed, and the test fails.
   
   ### Modifications
   
   Make the assertion less strict and ignore the value order.
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: https://github.com/pdolif/pulsar/pull/17


-- 
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: commits-unsubscribe@pulsar.apache.org

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


Re: [PR] [fix][test] Fix flaky LookupPropertiesTest.testConcurrentLookupProperties [pulsar]

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

   ## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/24854?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 74.32%. Comparing base ([`461ffd8`](https://app.codecov.io/gh/apache/pulsar/commit/461ffd84d641b855fcc0d09d586ff4b580c21974?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`aeecb8c`](https://app.codecov.io/gh/apache/pulsar/commit/aeecb8c18bcdef33db15daa2c98bc683ab65ccaa?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/pulsar/pull/24854/graphs/tree.svg?width=650&height=150&src=pr&token=acYqCpsK9J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/pulsar/pull/24854?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #24854      +/-   ##
   ============================================
   - Coverage     74.36%   74.32%   -0.04%     
   + Complexity    33856    33481     -375     
   ============================================
     Files          1913     1913              
     Lines        149280   149280              
     Branches      17324    17324              
   ============================================
   - Hits         111012   110957      -55     
   - Misses        29445    29490      +45     
   - Partials       8823     8833      +10     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pulsar/pull/24854/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [inttests](https://app.codecov.io/gh/apache/pulsar/pull/24854/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `26.63% <ø> (-0.02%)` | :arrow_down: |
   | [systests](https://app.codecov.io/gh/apache/pulsar/pull/24854/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `22.77% <ø> (-0.08%)` | :arrow_down: |
   | [unittests](https://app.codecov.io/gh/apache/pulsar/pull/24854/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.86% <ø> (-0.03%)` | :arrow_down: |
   
   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.
   [see 102 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/24854/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: commits-unsubscribe@pulsar.apache.org

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


Re: [PR] [fix][test] Fix flaky LookupPropertiesTest.testConcurrentLookupProperties [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari merged PR #24854:
URL: https://github.com/apache/pulsar/pull/24854


-- 
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: commits-unsubscribe@pulsar.apache.org

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