ddbed30ed7
feat: Add Scenario 11 IO System test & fix IntraIO routing architecture
...
Implémentation complète du scénario 11 (IO System Stress Test) avec correction majeure de l'architecture de routing IntraIO.
## Nouveaux Modules de Test (Scenario 11)
- ProducerModule: Publie messages pour tests IO
- ConsumerModule: Consomme et valide messages reçus
- BroadcastModule: Test multi-subscriber broadcasting
- BatchModule: Test low-frequency batching
- IOStressModule: Tests de charge concurrents
## Test d'Intégration
- test_11_io_system.cpp: 6 tests validant:
* Basic Publish-Subscribe
* Pattern Matching avec wildcards
* Multi-Module Routing (1-to-many)
* Low-Frequency Subscriptions (batching)
* Backpressure & Queue Overflow
* Thread Safety (concurrent pub/pull)
## Fix Architecture Critique: IntraIO Routing
**Problème**: IntraIO::publish() et subscribe() n'utilisaient PAS IntraIOManager pour router entre modules.
**Solution**: Utilisation de JSON comme format de transport intermédiaire
- IntraIO::publish() → extrait JSON → IntraIOManager::routeMessage()
- IntraIO::subscribe() → enregistre au IntraIOManager::registerSubscription()
- IntraIOManager::routeMessage() → copie JSON pour chaque subscriber → deliverMessage()
**Bénéfices**:
- ✅ Routing centralisé fonctionnel
- ✅ Support 1-to-many (copie JSON au lieu de move unique_ptr)
- ✅ Pas besoin d'implémenter IDataNode::clone()
- ✅ Compatible futur NetworkIO (JSON sérialisable)
## Modules Scenario 13 (Cross-System)
- ConfigWatcherModule, PlayerModule, EconomyModule, MetricsModule
- test_13_cross_system.cpp (stub)
## Documentation
- CLAUDE_NEXT_SESSION.md: Instructions détaillées pour build/test
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 11:43:08 +08:00
9105610b29
feat: Add integration tests 8-10 & fix CTest configuration
...
Added three new integration test scenarios:
- Test 08: Config Hot-Reload (dynamic configuration updates)
- Test 09: Module Dependencies (dependency injection & cascade reload)
- Test 10: Multi-Version Coexistence (canary deployment & progressive migration)
Fixes:
- Fixed CTest working directory for all tests (add WORKING_DIRECTORY)
- Fixed module paths to use relative paths (./ prefix)
- Fixed IModule.h comments for clarity
New test modules:
- ConfigurableModule (for config reload testing)
- BaseModule, DependentModule, IndependentModule (for dependency testing)
- GameLogicModuleV1/V2/V3 (for multi-version testing)
Test coverage now includes 10 comprehensive integration scenarios covering
hot-reload, chaos testing, stress testing, race conditions, memory leaks,
error recovery, limits, config reload, dependencies, and multi-versioning.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 07:34:15 +08:00
360f39325b
feat: Add Memory Leak Hunter test & fix critical ModuleLoader leaks
...
**Test Suite Completion - Scenario 5**
Add comprehensive memory leak detection test for hot-reload system with 200 reload cycles.
**New Test: test_05_memory_leak**
- 200 hot-reload cycles without recompilation
- Memory monitoring every 5 seconds (RSS, temp files, .so handles)
- Multi-threaded: Engine (60 FPS) + ReloadScheduler + MemoryMonitor
- Strict validation: <10 MB growth, <50 KB/reload, ≤2 temp files
**New Module: LeakTestModule**
- Controlled memory allocations (1 MB work buffer)
- Large state serialization (100 KB blob)
- Simulates real-world module behavior
**Critical Fix: ModuleLoader Memory Leaks** (src/ModuleLoader.cpp:34-39)
- Auto-unload previous library before loading new one
- Prevents library handle leaks (+200 .so mappings eliminated)
- Prevents temp file accumulation (778 files → 1-2 files)
- Memory leak reduced by 97%: 36.5 MB → 1.9 MB
**Test Results - Before Fix:**
- Memory growth: 36.5 MB ❌
- Per reload: 187.1 KB ❌
- Temp files: 778 ❌
- Mapped .so: +200 ❌
**Test Results - After Fix:**
- Memory growth: 1.9 MB ✅
- Per reload: 9.7 KB ✅
- Temp files: 1-2 ✅
- Mapped .so: stable ✅
- 200/200 reloads successful (100%)
**Enhanced SystemUtils helpers:**
- countTempFiles(): Count temp module files
- getMappedLibraryCount(): Track .so handle leaks via /proc/self/maps
**Test Lifecycle Improvements:**
- test_04 & test_05: Destroy old module before reload to prevent use-after-free
- Proper state/config preservation across reload boundary
**Files Modified:**
- src/ModuleLoader.cpp: Auto-unload on load()
- tests/integration/test_05_memory_leak.cpp: NEW - 200 cycle leak detector
- tests/modules/LeakTestModule.cpp: NEW - Test module with allocations
- tests/helpers/SystemUtils.{h,cpp}: Memory monitoring functions
- tests/integration/test_04_race_condition.cpp: Fixed module lifecycle
- tests/CMakeLists.txt: Added test_05 and LeakTestModule
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 10:06:18 +08:00
aa322d5214
fix: Correct hot-reload version validation in race condition test
...
Fixed critical bug where moduleVersion was being overwritten during
setConfiguration(), preventing proper hot-reload validation.
## Problem
- TestModule::setConfiguration() called configNode.getString("version")
- This overwrote the compiled moduleVersion (v2, v3, etc.) back to "v1"
- All reloads appeared successful but versions never actually changed
- Test validated thread safety but NOT actual hot-reload functionality
## Solution
- Removed moduleVersion overwrite from setConfiguration()
- moduleVersion now preserved as global compiled into .so
- Added clear comments explaining this is a compile-time value
- Simplified test configuration (no longer passes version param)
## Test Results (After Fix)
✅ 15/15 compilations (100%)
✅ 29/29 reloads (100%)
✅ Versions actually change: v1 → v2 → v5 → v14 → v15
✅ 0 corruptions
✅ 0 crashes
✅ 330ms avg reload time (file stability check working)
✅ Test now validates REAL hot-reload, not just thread safety
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 13:21:57 +08:00
484b9ab5d4
feat: Add Scenario 4 - Race Condition Hunter test suite
...
Add comprehensive concurrent compilation and hot-reload testing infrastructure
to validate thread safety and file stability during race conditions.
## New Components
### AutoCompiler Helper (tests/helpers/AutoCompiler.{h,cpp})
- Automatically modifies source files to bump version numbers
- Compiles modules repeatedly on separate thread (15 iterations @ 1s interval)
- Tracks compilation success/failure rates with atomic counters
- Thread-safe compilation statistics
### Race Condition Test (tests/integration/test_04_race_condition.cpp)
- **3 concurrent threads:**
- Compiler: Recompiles TestModule.so every 1 second
- FileWatcher: Detects .so changes and triggers hot-reload with mutex protection
- Engine: Runs at 60 FPS with try_lock to skip frames during reload
- Validates module integrity (health status, version, configuration)
- Tracks metrics: compilation rate, reload success, corrupted loads, crashes
- 90-second timeout with progress monitoring
### TestModule Enhancements (tests/modules/TestModule.cpp)
- Added global moduleVersion variable for AutoCompiler modification
- Version bumping support for reload validation
## Test Results (Initial Implementation)
```
Duration: 88s
Compilations: 15/15 (100%) ✅
Reloads: ~30 (100% success) ✅
Corrupted: 0 ✅
Crashes: 0 ✅
File Stability: 328ms avg (proves >100ms wait) ✅
```
## Known Issue (To Fix in Next Commit)
- Module versions not actually changing during reload
- setConfiguration() overwrites compiled version
- Reload mechanism validated but version bumping needs fix
## Files Modified
- tests/CMakeLists.txt: Add AutoCompiler to helpers, add test_04
- tests/modules/TestModule.cpp: Add version bumping support
- .gitignore: Add build/ and logs/
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 10:55:44 +08:00