Skip to content

fix: use non-overlapping Elo values in TestMatchmakingService to avoid race - #786

Open
Kulraj69 wants to merge 1 commit into
AOSSIE-Org:mainfrom
Kulraj69:fix-760-flaky-matchmaking-test
Open

Kulraj69 wants to merge 1 commit into
AOSSIE-Org:mainfrom
Kulraj69:fix-760-flaky-matchmaking-test

Conversation

@Kulraj69

@Kulraj69 Kulraj69 commented Oct 28, 2026 •

Copy link
Copy Markdown

Description

TestMatchmakingService creates two users with Elo 1200 and 1250 (both within the default ±200 match range). StartMatchmaking launches findMatch in a goroutine, which can pair and remove both users before the pool-size assertion runs. When that happens the test fails with "Expected 2 users in pool after both started matchmaking, got 0".

Fix: use Elo 2000 for the second user (range 1800–2200), which does not overlap with user1's 1000–1400 range. The matcher leaves both in the pool, so the pool-size assertions are deterministic.

Testing

  • go test ./services/ -run TestMatchmakingService -count=20 — 20/20 passes
  • go test ./... — full backend suite passes
  • go vet ./... — clean

AI Disclosure

I used an AI assistant to draft the fix and run the tests. I reviewed every line and the change matches the plan discussed in the issue.

Fixes #760

Summary by CodeRabbit

  • Tests
    • Updated a matchmaking test scenario to use a player with a higher rating. No user-facing behavior changes are included.

…d race

Signed-off-by: Kulraj69 <Kulraj69@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9ae45df6-3864-4904-8081-97f880cf2cc8
Commits

Reviewing files that changed from the base of the PR and between 95b24b5 and bc58a3f.

Files selected for processing: 1
  • backend/services/matchmaking_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Walkthrough

The matchmaking test changes Bob’s Elo rating from 1250 to 2000.

Changes: Matchmaking test

Layer / File(s) Summary
Test matchmaking pool assertions
backend/services/matchmaking_test.go
The test now adds Bob with an Elo rating of 2000 instead of 1250.

Priority: Low

Estimated code review effort: 1 (Trivial) | ~2 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: rixitgithub

Merge Risk: Minimal · up to bc58a

No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: using non-overlapping Elo values in TestMatchmakingService to prevent intermittent test failures.
Linked Issues check Passed Issue #760 requires a deterministic test fix without changing matchmaking logic. The diff changes Bob's Elo from 1250 to 2000 in TestMatchmakingService. This removes the overlap with user1's default…
Out of Scope Changes check Passed The pull request changes one test input in backend/services/matchmaking_test.go. The change directly addresses the timing-dependent failure in issue #760. No unrelated production or test changes are…
Full details: Linked Issues check

Explanation

Issue #760 requires a deterministic test fix without changing matchmaking logic. The diff changes Bob's Elo from 1250 to 2000 in TestMatchmakingService. This removes the overlap with user1's default ±200 range and supports the existing pool-size assertions. No matchmaking implementation changed.

Full details: Out of Scope Changes check

Explanation

The pull request changes one test input in backend/services/matchmaking_test.go. The change directly addresses the timing-dependent failure in issue #760. No unrelated production or test changes are present.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitcordapp

gitcordapp Bot commented Oct 28, 2026

Copy link
Copy Markdown

Link your account with Gitcord

Thanks for opening this PR, @Kulraj69!

To receive Discord notifications and contributor tracking for this organization:

  1. Join Discord: https://discord.gg/hjUhu33uAn
  2. In Discord, run /link Kulraj69
  3. Paste the verification code into your GitHub bio (or a public gist)
  4. Click Verify in Discord (or run /verify-link Kulraj69)

Once linked, Gitcord can notify you about reviews, merges, and more.

— Posted by Gitcord

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Flaky test – TestMatchmakingService fails intermittently (users matched before pool assertion)

1 participant