zhanglistar opened a new pull request, #545:
URL: https://github.com/apache/pulsar-client-cpp/pull/545

   <!--
   ### Contribution Checklist
     
     - PR title format should be *[type][component] summary*. For details, see 
*[Guideline - Pulsar PR Naming 
Convention](https://docs.google.com/document/d/1d8Pw6ZbWk-_pCKdOmdvx9rnhPiyuxwq60_TrD68d7BA/edit#heading=h.trs9rsex3xom)*.
 
   
     - Fill out the template below to describe the changes contributed by the 
pull request. That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue, not mix up code from 
multiple issues.
     
     - Each commit in the pull request has a meaningful commit message
   
     - Once all items of the checklist are addressed, remove the above text and 
this checklist, leaving only the filled out template below.
   -->
   
   Fixes #542
   
   ### Motivation
   
   `ReaderTest.testAsyncRead` was flaky because it assumed the i-th 
`readNextAsync` callback would receive the i-th message. With partitioned 
topics or async scheduling, callbacks can complete in any order, so the 
assertion `content == "my-message-" + std::to_string(i)` sometimes failed (e.g. 
expected "my-message-8" but got "my-message-9"). This change makes the test 
order-independent so it passes for both single- and multi-partition topics.
   
   ### Modifications
   
   - In `testAsyncRead`, replaced order-dependent assertions with a set-based 
check: fire 10 `readNextAsync` calls, collect the 10 message bodies in a fixed 
array using `std::atomic<int>` for the index (no mutex), wait until 10 messages 
are received, then assert that the set of received strings equals 
`{"my-message-0", ..., "my-message-9"}`.
   - Removed the assumption that callback completion order matches send order 
so the test is stable for partitioned and non-partitioned topics.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   This change is already covered by existing tests:
   
   - Run: `./pulsar-tests --gtest_filter='*testAsyncRead*'`
   - Passes for both parameterized cases (single partition and partitioned 
topic); no flaky failures from callback order.
   
   ### Documentation
   
   - [x] `doc-not-needed`  
     Test-only change; no user-facing or API documentation updates required.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to