[PM-36965] feat: Add SeederApi scene for migration cohort CSV-export testing#7906
[PM-36965] feat: Add SeederApi scene for migration cohort CSV-export testing#7906cyprain-okeke wants to merge 7 commits into
Conversation
…testing
Adds MigrationCohortExportScene, the HTTP/API equivalent of the PM-36965
SQL seed script: it creates a migration cohort plus N inert placeholder
organizations and their cohort assignments, so the Admin Portal
cohort-management table has a populated cohort ready to Export CSV.
Organizations and assignments are bulk-inserted via LinqToDB BulkCopy
(the same path BulkCommitter uses) to stay fast at scale. Because BulkCopy
bypasses the repository CreateAsync tracking hook, the scene records
PlayItem rows itself so DELETE /seed/{playId} can tear the seeded
organizations down; the empty cohort row is not play-id tracked and is
removed by name.
Covered by integration tests asserting database persistence, cohort
reuse-by-name, and play-id tracking.
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the new Code Review DetailsNo code-level findings. The implementation follows established Seeder conventions (BulkCopy + PR Metadata Assessment
|
… add churn-path and range tests - Wrap cohort + orgs + assignments + PlayItem inserts in one transaction so a mid-sequence failure rolls back instead of leaving partly-seeded state. - Move cohort creation into the transactional BulkCopy path. - Enforce OrgCount range explicitly in SeedAsync (SceneExecutor does not run DataAnnotations on scene requests), returning BadRequest out of range. - Reframe the CreationDate comment around observed batch behavior (rot-hardening). - Add tests: null MigrationPathId => churn cohort, OrgCount range validation (0/-1/100001 rejected, 1 accepted), and assert persisted MigrationPathId.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7906 +/- ##
=======================================
Coverage 61.40% 61.40%
=======================================
Files 2227 2227
Lines 98345 98345
Branches 8894 8894
=======================================
Hits 60386 60386
Misses 35822 35822
Partials 2137 2137 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
SeedControllerTests covers scene discovery/naming and delete generically, not per-scene end-to-end behavior; and cleanup is handled by DeleteOldPlayDataJob (verified running clean locally against SQL Server with no Command errors), so the dedicated cleanup tests are redundant. Restores SeedControllerTests to its original state and removes MigrationCohortExportSceneCleanupTests.



🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-36965
📔 Objective
Adds
MigrationCohortExportSceneto the Seeder — the HTTP/API equivalent of thePM-36965 SQL seed script — so QA and local environments can populate the Admin
Portal migration-cohort management table with a cohort ready to Export CSV,
without hand-running SQL.
Given a
cohortNameandorgCount, the scene creates (or reuses by name) amigration cohort, then bulk-creates N inert placeholder organizations
(
Enabled = false, no billing, no users) and their cohort assignments. RealOrganizationrows are required becauseOrganizationPlanMigrationCohortAssignmenthas a FK to
Organizationwith a UNIQUE constraint onOrganizationId.Usage (local, SeederApi on
:5047):Optional args:
migrationPathId(default1;null= churn-only cohort),namePrefix(defaultpm36965-seed-).Implementation notes
BulkCopy(the samepath
BulkCommitteruses) to stay fast up to the[Range(1, 100000)]ceiling.BulkCopybypasses the repositoryCreateAsyncplay-id tracking hook, so thescene records
PlayItemrows itself. This letsDELETE /seed/{playId}tear theseeded organizations down (assignments cascade via FK). The emptied cohort row is
not play-id tracked (
PlayItemhas noCohortId) and is removed by name.Testing
back), cohort reuse-by-name, and one-
PlayItem-per-org tracking for cleanup.SeederApi.IntegrationTestsuite: 180/180 passing.📸 Screenshots