Repository navigation
test: make matchmaking tests deterministic - #822
RounakKumarAgarwal wants to merge 2 commits into
Conversation
TestMatchmakingService used Elo 1200 and 1250, which are inside each other's +-200 range, so the background matcher could pair and remove both users before the test checked the pool. - use 1200 and 2000 so the two users can never be matched - give each test its own user IDs and remove them with t.Cleanup, so leftovers from one test (e.g. Charlie) can't affect the next run - assert only on the test's own users instead of the global pool size - TestEloTolerance: wait for the match instead of a fixed 100ms sleep, and move Charlie to 700 (range 500-900); at 800 his range touched Alice's at 1000 and the two could match Fixes AOSSIE-Org#760 Signed-off-by: Rounak Agarwal <agarwalrounak2005@gmail.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Call findMatch synchronously so the 'no compatible opponent' check doesn't depend on a fixed 200ms sleep, and check AddToPool errors in TestEloTolerance like the other tests do. Signed-off-by: Rounak Agarwal <agarwalrounak2005@gmail.com>
Fixes #760
Problem
TestMatchmakingServicewas flaky because Alice (1200) and Bob (1250) are inside each other's ±200 range. The background matcher could pair and remove both users before the test checked the pool.There was also a second problem: the tests share one matchmaking service and never cleaned up, so Charlie from
TestEloTolerancestayed in the pool and broke the next run.Changes
Tests only, no change to the matchmaking logic.
1200and2000so the two users can never be matched.t.Cleanup.TestEloTolerance: wait for Alice and Bob to be matched (up to 2s) instead of a fixed 100ms sleep, and check Charlie with a direct matching pass instead of sleeping. Charlie also moves from800to700: at 800 his range (600–1000) touched Alice's (1000–1400), so they could match.Testing
Windows 11, Git Bash.
Before (on
main): passes on the 1st run, fails on every run after that:After (with this PR):

Summary by CodeRabbit