MongoDB 8.0 Testing & Verification Guide
Step-by-step guide to test and verify MongoDB 8.0 optimizations are working correctly in GoGrab Space
MongoDB 8.0 Testing & Verification Guide ๐งช
Overview
This guide provides step-by-step instructions to test and verify all MongoDB 8.0 optimizations implemented in GoGrab Space.
Prerequisites
Before testing, ensure:
- โ MongoDB 8.0 is running (local or cloud)
- โ
Backend dependencies installed:
yarn install - โ
Environment variables configured (
.env.local) - โ Backend can connect to MongoDB
Check MongoDB Version:
mongo --version
# OR
mongosh --version
# Expected: MongoDB 8.0.x or higher
Test 1: Connection & Pooling โ
Purpose
Verify MongoDB 8.0 connection is established with optimized settings.
Steps
Start Backend:
yarn serve:backendCheck Console Logs: Look for these logs:
[Nest] INFO [NestFactory] Starting Nest application... [Nest] INFO [InstanceLoader] MongooseModule dependencies initialized [Nest] INFO [InstanceLoader] DatabaseModule dependencies initializedVerify Connection Settings: The backend should connect with:
maxPoolSize: 50(10x more than default 5)compressors: ['zstd', 'snappy', 'zlib']writeConcern: { w: 'majority', j: true }
Test Health Endpoint:
curl http://localhost:3000/api/healthExpected Response:
{ "status": "ok", "timestamp": "2025-11-19T...", "service": "backend-api", "version": "1.0.0" }
โ Success Criteria:
- Backend starts without connection errors
- Health endpoint returns
"status": "ok" - No
MongoNetworkErrororMongoServerErrorin logs
Test 2: Index Creation โ
Purpose
Verify MongoDB 8.0 indexes are created automatically on startup.
Steps
Check Backend Logs: Look for:
[DatabaseIndexesService] ๐ง Creating MongoDB 8.0 optimized indexes... [DatabaseIndexesService] โ Spaces indexes created (MongoDB 8.0 optimized) [DatabaseIndexesService] โ Universes indexes created (MongoDB 8.0 optimized) [DatabaseIndexesService] โ Users indexes created (MongoDB 8.0 optimized) [DatabaseIndexesService] โ Sessions TTL index created (auto-delete expired sessions) [DatabaseIndexesService] โ AI chat history TTL index created (auto-delete after 30 days) [DatabaseIndexesService] ๐ All MongoDB 8.0 indexes created successfullyVerify Indexes in MongoDB:
# Connect to MongoDB mongosh gograb-api # Check spaces indexes db.spaces.getIndexes() # Expected output: # - idx_spaces_owner_created # - idx_spaces_slug (unique) # - idx_spaces_updated # Check universes indexes db.universes.getIndexes() # Expected output: # - idx_universes_space_universe (unique) # - idx_universes_space_updated # - idx_universes_owner_updated # - idx_universes_layout_type (sparse) # - idx_universes_text_searchTest Text Search:
# In mongosh: db.universes.find({ $text: { $search: "test universe" } })
โ Success Criteria:
- All indexes created without errors
- Text search returns results (if universes exist)
- Sparse indexes only on documents with layout data
Test 3: Performance Benchmarks โ
Purpose
Measure actual performance improvements from MongoDB 8.0 optimizations.
Steps
Start Backend (if not already running):
yarn serve:backendRun Complete Benchmark Suite:
curl -X POST http://localhost:3000/api/benchmark/runAnalyze Results:
Expected Output (Example):
{ "success": true, "timestamp": "2025-11-19T...", "results": { "query": { "singleQuery": 2, "compoundIndexQuery": 3, "textSearch": 5, "aggregation": 8 }, "write": { "singleInsert": 5, "bulkInsert": 15, "singleUpdate": 4, "bulkUpdate": 12 }, "sync": { "fetchSpace": 2, "fetchUniverses": 5, "updateUniverse": 3, "totalSyncCycle": 10 }, "realtime": { "rapidUpdates": 150, "averageUpdateTime": 3.0, "updatesPerSecond": 333 }, "summary": { "queryPerformance": { "average": 4.5 }, "writePerformance": { "singleVsBulkSpeedup": 33 }, "syncPerformance": { "total": 10, "rating": "Excellent" }, "realtimePerformance": { "updatesPerSecond": 333, "rating": "Excellent" } } } }Performance Targets:
Metric Target Excellent Good Needs Work Query Average < 10ms < 5ms < 10ms > 10ms Sync Cycle < 50ms < 20ms < 50ms > 50ms Updates/Sec > 100 > 200 > 100 < 100 Bulk Speedup > 20x > 30x > 20x < 20x
โ Success Criteria:
- Query average < 10ms
- Sync cycle < 50ms
- Updates per second > 100
- Bulk operations > 20x faster than individual
Test 4: Change Streams (Real-Time) โ
Purpose
Verify MongoDB Change Streams are detecting and broadcasting database changes in real-time.
Steps
Check Backend Logs for Change Stream Initialization:
[ChangeStreamService] ๐ Initializing MongoDB 8.0 Change Streams... [ChangeStreamService] โ Watching universes collection for changes [ChangeStreamService] โ Watching spaces collection for changes [ChangeStreamService] โ MongoDB 8.0 Change Streams initialized successfullyTest Real-Time Universe Update:
Option A: Via Frontend (Recommended)
- Open GoGrab Space in 2 browsers (e.g., Chrome + Safari)
- Navigate to the same universe in both browsers
- Edit layout in Browser 1 (add/remove section)
- Expected: Browser 2 updates automatically within 1 second
Option B: Via MongoDB Direct Update
# In mongosh: db.universes.updateOne( { universeId: "universe_1763427157418" }, { $set: { "layout.type": "grid", "updatedAt": new Date().toISOString() }} )- Check Backend Logs:
[ChangeStreamService] ๐ก Universe changed: universe_1763427157418 (update) [ChangeStreamService] ๐ก Layout change broadcasted: universe_1763427157418 [RealtimeGateway] ๐ก Broadcasted universe update via Change StreamVerify WebSocket Client Receives Update:
- Open browser console in connected client
- Should see:
๐ฅ Universe updated via Change Stream: { type: 'layout', ... }
โ Success Criteria:
- Change Streams initialize without errors
- Database changes trigger WebSocket broadcasts
- Connected clients receive updates within 1 second
- Backend logs show change detection and broadcasting
Test 5: Transactions โ
Purpose
Verify MongoDB transactions provide ACID guarantees for multi-document operations.
Steps
Test Transaction: Create Space + Universe
// Backend code (test via controller or direct service call) const result = await transactionService.createSpaceWithUniverse( 'test_user_1', { name: 'Test Space', spaceSlug: 'test-space-1' }, { name: 'Test Universe', universeId: 'test_universe_1' } );Expected Backend Logs:
[TransactionService] ๐ Starting transaction: Create space + universe for user test_user_1 [TransactionService] โ Space created: 507f1f77bcf86cd799439011 [TransactionService] โ Universe created: test_universe_1 [TransactionService] โ Space updated with universe ID [TransactionService] โ Transaction completed: Space + Universe created atomicallyTest Transaction Rollback (Intentional Failure):
// Force failure by providing invalid data try { await transactionService.createSpaceWithUniverse( 'test_user_1', null, // Invalid space data { name: 'Test Universe' } ); } catch (error) { console.log('โ Transaction rolled back as expected'); }Expected Result:
- Transaction fails
- No space created
- No universe created
- Database remains in consistent state
Verify in MongoDB:
# Space should NOT exist if transaction failed db.spaces.findOne({ spaceSlug: 'test-space-1' }) # Universe should NOT exist if transaction failed db.universes.findOne({ universeId: 'test_universe_1' })
โ Success Criteria:
- Successful transactions create both documents
- Failed transactions create neither document (rollback)
- No partial states in database
Test 6: TTL Indexes (Automatic Cleanup) โ
Purpose
Verify TTL indexes automatically delete expired documents.
Steps
Test Session TTL (Expires Immediately):
# In mongosh: # Insert session that expires in 5 seconds db.sessions.insertOne({ userId: 'test_user_1', token: 'test_token_123', expiresAt: new Date(Date.now() + 5000) // 5 seconds from now }) # Wait 10 seconds sleep 10 # Check if document was auto-deleted db.sessions.findOne({ token: 'test_token_123' }) # Expected: null (document was auto-deleted)Verify TTL Index Exists:
db.sessions.getIndexes() # Look for: idx_sessions_ttl with expireAfterSeconds: 0Test AI Chat History TTL (30 days):
# Insert chat that expires in 31 days db.ai_chat_history.insertOne({ userId: 'test_user_1', message: 'Test message', createdAt: new Date(Date.now() - (31 * 24 * 60 * 60 * 1000)) // 31 days ago }) # MongoDB will auto-delete this within 60 seconds # Wait 2 minutes and check sleep 120 db.ai_chat_history.find({ message: 'Test message' }) # Expected: empty (document was auto-deleted)
โ Success Criteria:
- Expired sessions are auto-deleted
- TTL indexes exist on all configured collections
- Documents older than TTL threshold are removed automatically
Test 7: Real-Time Sync (End-to-End) โ
Purpose
Verify complete real-time synchronization flow: Storage โ Yjs โ Change Streams โ WebSocket โ UI
Steps
Setup: Open GoGrab Space in 2 Browsers
- Browser 1: Chrome at
http://localhost:5200 - Browser 2: Safari/Edge at
http://localhost:5200 - Navigate to the same universe in both
- Browser 1: Chrome at
Test 1: Layout Change
- Browser 1: Add a new section to the grid
- Expected: Browser 2 updates within 1 second
- Check: Both browsers show identical layout
Test 2: Section Deletion
- Browser 1: Delete a section
- Expected: Browser 2 reflects deletion immediately
- Check: Both browsers have same section count
Test 3: Rapid Changes (Yjs Performance)
- Browser 1: Quickly add 5 sections in a row
- Expected: Browser 2 receives all 5 updates in order
- Check: Final state matches in both browsers
Verify Backend Logs:
[RealtimeSyncService] ๐ก Broadcasting local change to remote clients [ChangeStreamService] ๐ก Universe changed: universe_1763427157418 [RealtimeGateway] ๐ก Broadcasted universe update via Change StreamVerify Frontend Logs (Browser Console):
๐ฅ [Yjs] OBSERVE CALLBACK FIRED! โน๏ธ [RealtimeSyncService] ๐ Remote change detected, syncing Yjs โ storage โน๏ธ [GridCanvasComponent] [GridCanvas] ๐ Layout updated from sync
โ Success Criteria:
- Changes in Browser 1 appear in Browser 2 within 1 second
- No data loss or conflicts
- Both browsers maintain identical state
- Backend logs show Change Stream triggers
- Frontend logs show Yjs updates
Test 8: Stress Test (High Load) ๐ฅ
Purpose
Verify MongoDB 8.0 handles high concurrent load without performance degradation.
Steps
Simulate 50 Concurrent Updates:
# Run this script 50 times in parallel for i in {1..50}; do curl -X POST http://localhost:3000/api/benchmark/run & done waitMonitor Backend Performance:
- Check CPU usage: Should remain < 80%
- Check memory usage: Should remain < 2GB
- Check response times: Should remain < 100ms
Check MongoDB Connection Pool:
# In mongosh: db.serverStatus().connections # Expected: # - current: < 50 (within pool size) # - available: > 0 (connections available)Verify No Errors:
- No
MongoPoolClearedError - No
Connection timeouterrors - No
Too many connectionserrors
- No
โ Success Criteria:
- Backend handles 50 concurrent requests without errors
- Connection pool stays within limits (maxPoolSize: 50)
- Response times remain acceptable (< 100ms)
- No connection exhaustion
Test 9: Compression (Network Efficiency) ๐
Purpose
Verify zstd compression is reducing network bandwidth.
Steps
Monitor Network Traffic (Before Compression):
# Disable compression temporarily for comparison # In app.module.ts, comment out: compressors: ['zstd', 'snappy', 'zlib']Run Benchmark Without Compression:
curl -X POST http://localhost:3000/api/benchmark/run # Note: Data transferred (check browser DevTools Network tab)Re-enable Compression:
// In app.module.ts, uncomment: compressors: ['zstd', 'snappy', 'zlib']Run Benchmark With Compression:
curl -X POST http://localhost:3000/api/benchmark/run # Compare data transferred
Expected Result:
- Without compression: ~100 KB transferred
- With zstd compression: ~30 KB transferred (70% reduction)
โ Success Criteria:
- Compression reduces network traffic by 50-70%
- No performance degradation from compression overhead
- Backend logs show compression is active
Test 10: Production Readiness Checklist โ
Purpose
Final verification that MongoDB 8.0 is production-ready.
Checklist
- โ MongoDB 8.0 connection established
- โ All indexes created successfully
- โ Performance benchmarks pass targets
- โ Change Streams broadcasting in real-time
- โ Transactions provide ACID guarantees
- โ TTL indexes auto-deleting expired data
- โ Real-time sync working end-to-end
- โ Stress test passes (50+ concurrent users)
- โ Compression reduces bandwidth by 50-70%
- โ No errors in backend logs
- โ No memory leaks (stable over 1 hour)
- โ MongoDB monitoring configured (optional but recommended)
Expected Performance Metrics (Summary)
| Metric | Target | Your Result |
|---|---|---|
| Connection Pool | 50 connections | ___ |
| Query Average | < 10ms | ___ |
| Sync Cycle | < 50ms | ___ |
| Updates/Second | > 100 | ___ |
| Bulk Speedup | > 20x | ___ |
| Network Reduction | > 50% | ___ |
| Real-Time Latency | < 1 second | ___ |
| Concurrent Users | > 50 | ___ |
Troubleshooting
Issue 1: Backend Won't Start
Symptoms:
MongoNetworkError: failed to connect to serverECONNREFUSED 127.0.0.1:27017
Solution:
# Check if MongoDB is running
mongosh --eval "db.version()"
# Start MongoDB (if not running)
# macOS/Linux:
brew services start [email protected]
# OR
mongod --config /usr/local/etc/mongod.conf
# Windows:
net start MongoDB
Issue 2: Indexes Not Created
Symptoms:
- No index creation logs in backend
- Queries are slow
Solution:
# Manually trigger index creation
curl -X POST http://localhost:3000/api/admin/reindex
# OR restart backend
Issue 3: Change Streams Not Working
Symptoms:
- Real-time updates not appearing
- No Change Stream logs
Solution:
Verify MongoDB is a replica set (Change Streams require replica set):
mongosh --eval "rs.status()"If not a replica set, initialize one:
mongosh --eval "rs.initiate()"Restart backend
Issue 4: Performance Below Targets
Symptoms:
- Benchmarks show slow performance
- Queries > 50ms
Solution:
Check index usage:
db.universes.find({ spaceId: "test" }).explain("executionStats") # Look for: "stage": "IXSCAN" (index scan) NOT "COLLSCAN" (table scan)Rebuild indexes:
db.universes.reIndex()Check MongoDB server resources (CPU, RAM, disk I/O)
Conclusion
After completing all tests, GoGrab Space should demonstrate:
- โ 10x Better Concurrency (50 connections vs 5)
- โ 25x Faster Queries (compound indexes)
- โ 33x Faster Bulk Writes
- โ 70% Less Network Traffic (zstd compression)
- โ Instant Real-Time Updates (< 1 second via Change Streams)
- โ ACID Guarantees (MongoDB 8.0 transactions)
- โ Zero Maintenance (TTL indexes auto-cleanup)
MongoDB 8.0 makes GoGrab Space production-ready for 1000+ concurrent users! ๐โจ