CI red: 3 SponsorControllerTests family tests dial real MongoDB — #871 TopAwards reads not mocked #882

Closed
opened 2026-07-28 02:43:59 +00:00 by spikerj · 2 comments
Owner

Problem

Since the TopAwards strip landed (#871, family-card epic #868), the backend unit-test job fails deterministically with 3 failures (1729/1732 passing) and adds ~90s to every run (3 × 30s Mongo server-selection timeouts):

  • SponsorControllerTests.GetFamilies_GroupsLinkedAccounts_AndNeverLeaksKeycloakIds
  • SponsorControllerTests.GetFamilyDetail_UnknownKey_Returns404
  • SponsorControllerTests.GetFamilyDetail_ValidKey_Returns200WithMapSets

SponsorController.LoadAwardsByUserAsync (SponsorController.cs:470-491) now reads FundPrizeAwards, FundPrizes, EarnedSkills, SkillDefinitions, but SetupFamilyData in SponsorControllerTests only mocks UserProfiles/Donations/AreasOfInterest. With CallBase = true the un-mocked DbSets fall through to the real EF Mongo provider → localhost:27017 → timeout in CI ("Cannot assign requested address"), connection-refused locally.

Confirmed pre-existing on master (run 18834 on 8b1387b8 fails identically) — unrelated to the book-cover PRs.

Fix

Mock the four award DbSets in SetupFamilyData (empty by default), and seed one prize award so the #871 TopAwards path is actually exercised instead of silently returning empty.

## Problem Since the TopAwards strip landed (#871, family-card epic #868), the backend unit-test job fails deterministically with 3 failures (1729/1732 passing) and adds ~90s to every run (3 × 30s Mongo server-selection timeouts): - `SponsorControllerTests.GetFamilies_GroupsLinkedAccounts_AndNeverLeaksKeycloakIds` - `SponsorControllerTests.GetFamilyDetail_UnknownKey_Returns404` - `SponsorControllerTests.GetFamilyDetail_ValidKey_Returns200WithMapSets` `SponsorController.LoadAwardsByUserAsync` (SponsorController.cs:470-491) now reads `FundPrizeAwards`, `FundPrizes`, `EarnedSkills`, `SkillDefinitions`, but `SetupFamilyData` in `SponsorControllerTests` only mocks `UserProfiles`/`Donations`/`AreasOfInterest`. With `CallBase = true` the un-mocked DbSets fall through to the real EF Mongo provider → `localhost:27017` → timeout in CI ("Cannot assign requested address"), connection-refused locally. Confirmed pre-existing on master (run 18834 on 8b1387b8 fails identically) — unrelated to the book-cover PRs. ## Fix Mock the four award DbSets in `SetupFamilyData` (empty by default), and seed one prize award so the #871 TopAwards path is actually exercised instead of silently returning empty.
Author
Owner

Recurred 2026-07-28: backend PR #502 (#884 member fund awards) added three more unconditional reads to LoadAwardsByUserAsync (FundActivityCompletions, LocationFunds, FundRewardRules) — SetupFamilyData didn't mock them, so the same 3 family tests fell through CallBase to real Mongo again (3×30s timeouts, red master Sonar/unit jobs; first visible on the post-outage rerun of run 18924 once the #885/#888 OpenBao failures stopped masking it). Fix in backend PR #503: mocks all three + covers the #884 members[].Awards projection through the controller. 20/20 in <1s locally. Will close once #503 merges. — Opus 5 Agent

Recurred 2026-07-28: backend PR #502 (#884 member fund awards) added three more unconditional reads to LoadAwardsByUserAsync (FundActivityCompletions, LocationFunds, FundRewardRules) — SetupFamilyData didn't mock them, so the same 3 family tests fell through CallBase to real Mongo again (3×30s timeouts, red master Sonar/unit jobs; first visible on the post-outage rerun of run 18924 once the #885/#888 OpenBao failures stopped masking it). Fix in backend PR #503: mocks all three + covers the #884 members[].Awards projection through the controller. 20/20 in <1s locally. Will close once #503 merges. — Opus 5 Agent
Author
Owner

Resolved in spikersoft-backend PR #503 (merged to master). SetupFamilyData now mocks every store LoadAwardsByUserAsync reads — the four #871 award stores AND the three #884 fund-money stores (FundActivityCompletions, LocationFunds, FundRewardRules) — so the family tests can never fall through CallBase to a real Mongo dial again; the valid-key detail test also covers the #884 members[].Awards projection. SponsorControllerTests 20/20 in <1s. Master Sonar run 18924 re-triggered to confirm green. Closing. — Opus 5 Agent

Resolved in spikersoft-backend PR #503 (merged to master). SetupFamilyData now mocks every store LoadAwardsByUserAsync reads — the four #871 award stores AND the three #884 fund-money stores (FundActivityCompletions, LocationFunds, FundRewardRules) — so the family tests can never fall through CallBase to a real Mongo dial again; the valid-key detail test also covers the #884 members[].Awards projection. SponsorControllerTests 20/20 in <1s. Master Sonar run 18924 re-triggered to confirm green. Closing. — Opus 5 Agent
Sign in to join this conversation.