tests: Improve stability of Subscribe tests#6420
tests: Improve stability of Subscribe tests#6420kuznetsss wants to merge 8 commits intoXRPLF:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses flaky Subscribe tests by introducing a synchronization mechanism to ensure WebSocket subscription messages have been initiated before tests check for them. The issue (#6399) was caused by race conditions where tests would check for messages before the server's background thread had posted the async write operations.
Changes:
- Added
syncClose()method to test Env class that closes a ledger and synchronizes with the server's io_context - Replaced all
env.close()calls in Subscribe_test.cpp withBEAST_EXPECT(env.syncClose())to ensure synchronization - Added lambda capture of
thisinsendPaymentshelper to support BEAST_EXPECT usage
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/test/jtx/Env.h | Added syncClose() method with comprehensive documentation that closes a ledger and waits for all posted async operations to start |
| src/test/rpc/Subscribe_test.cpp | Replaced env.close() with env.syncClose() throughout and fixed lambda capture to enable test assertions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #6420 +/- ##
=========================================
- Coverage 79.8% 79.8% -0.0%
=========================================
Files 858 858
Lines 67757 67761 +4
Branches 7562 7553 -9
=========================================
- Hits 54081 54079 -2
- Misses 13676 13682 +6
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
godexsoft
left a comment
There was a problem hiding this comment.
Seems like this relies on the fact we have one thread in tests. If it changes there may be issues but for now this is best we can do by the looks of it 👍
|
@godexsoft, you are right and it turned out that the application was not single threaded. I've added an assert into |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a1q123456
left a comment
There was a problem hiding this comment.
May be a good approach. We can merge it and see if it works.
High Level Overview of Change
This PR improves stability of Subscribe tests.
Fixes #6399.
Context of Change
Subscribe tests were flaky because each test performs some operations (e.g. sends transactions) and waits for messages to appear in subscription with 100ms timeout. If tests are slow (because compiled in debug or the machine is slow) some of them could fail. This PR adds an attempt to synchronise background
Env's thread and test's thread by ensuring that all the scheduled operations are started before test's thread starts to wait for a websocket message. This is done by limiting IO threads of the app insideEnvto1and adding a synchronisation barrier after closing ledger.Type of Change
.gitignore, formatting, dropping support for older tooling)API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)