Chore: Optimize test suite performance and eliminate errors#2148
Merged
caneppelevitor merged 3 commits intostagefrom Jan 29, 2026
Merged
Chore: Optimize test suite performance and eliminate errors#2148caneppelevitor merged 3 commits intostagefrom
caneppelevitor merged 3 commits intostagefrom
Conversation
|
caneppelevitor
approved these changes
Nov 18, 2025
Implemented comprehensive test optimization to improve performance and reliability: **Performance Improvements:** - Reduced total test execution time from ~197s to ~126s (36% faster) - All 70 tests now passing with 100% success rate - Eliminated timeout and duplicate key errors **Key Changes:** 1. Shared MongoDB Instance - Created global setup/teardown for single MongoMemoryServer instance - Eliminated per-test-suite MongoDB instances - Reduced startup overhead significantly 2. Database Cleanup - Added CleanupDatabase utility to clear collections between test suites - Prevents duplicate key errors from hardcoded test data IDs - Ensures clean state for each test suite 3. Test Configuration - Set maxWorkers to 1 for sequential execution (avoids data conflicts) - Increased test timeout to 30s for reliability - Configured MongoDB binary caching 4. Updated Test Files - Removed individual MongoMemoryServer instances - Added database cleanup in afterAll hooks - Updated all e2e tests to use shared MongoDB instance Files modified: - server/tests/globalSetup.ts (new) - server/tests/globalTeardown.ts (new) - server/tests/utils/CleanupDatabase.ts (new) - server/tests/jest-e2e.config.json - jest-mongodb-config.js (new) - All e2e test files and parser.service.spec.ts
Achieved 67% faster test execution by enabling parallel test runs. **Performance Results:** - Original (with timeouts): ~197s - Sequential optimization: 125.687s (36% improvement) - Parallel execution: 65.429s (67% improvement, 48% faster than sequential) **Key Changes:** 1. Enabled parallel execution (maxWorkers: 50% in jest-e2e.config.json) 2. Updated SeedTestUser to use upsert operation instead of insertOne 3. Updated SeedTestPersonality to use bulkWrite with upsert operations 4. Eliminated duplicate key errors during parallel test execution **Technical Details:** - Changed seed functions from insertOne/insertMany to updateOne/bulkWrite with upsert: true - This makes seed operations idempotent and safe for concurrent execution - Tests can now run in parallel without data conflicts - All 70 tests passing with 100% success rate Test Results: - Test Suites: 7 passed, 7 total - Tests: 70 passed, 70 total - Time: 65.429s (vs 125.687s sequential)
c940b5b to
c190d2f
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Comprehensive test suite optimization that improves performance by 36% and eliminates all timeout and duplicate key errors. All 70 tests now pass reliably.
Performance Improvements
📈 Key Achievements
🔧 What Changed
Latest Optimization (Parallel Execution):
✨ Benefits
The tests are now 3x faster than the original implementation while maintaining 100% reliability!
Test plan
Related Ticket # (issue)
Type of change
Developer Checklist
General
console.logor related logging is added.Backend Changes
Tests
Merge Request Review Checklist