You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "zhanglistar (via GitHub)" <gi...@apache.org> on 2026/03/04 08:10:44 UTC
[PR] [Test][C++] Fix flaky ReaderTest.testAsyncRead [pulsar-client-cpp]
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Test][C++] Fix flaky ReaderTest.testAsyncRead [pulsar-client-cpp]
Posted by "zhanglistar (via GitHub)" <gi...@apache.org>.
zhanglistar commented on PR #545:
URL: https://github.com/apache/pulsar-client-cpp/pull/545#issuecomment-3996242707
@BewareMyPower Another flaky test https://github.com/apache/pulsar-client-cpp/actions/runs/22660933680/job/65680996230?pr=545
--
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] [Test][C++] Fix flaky ReaderTest.testAsyncRead [pulsar-client-cpp]
Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat merged PR #545:
URL: https://github.com/apache/pulsar-client-cpp/pull/545
--
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