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>
This commit is contained in:
StillHammer 2025-11-15 13:21:57 +08:00
parent 484b9ab5d4
commit aa322d5214
2 changed files with 4 additions and 5 deletions

View File

@ -67,8 +67,7 @@ int main() {
try {
auto module = loader.load(modulePath, "TestModule", false);
nlohmann::json configJson;
configJson["version"] = "v1";
nlohmann::json configJson = nlohmann::json::object();
auto config = std::make_unique<JsonDataNode>("config", configJson);
module->setConfiguration(*config, nullptr, nullptr);
moduleSystem->registerModule("TestModule", std::move(module));

View File

@ -54,9 +54,9 @@ public:
// Clone configuration for storage
config = std::make_unique<JsonDataNode>("config", nlohmann::json::object());
// Extract version if available (use current moduleVersion as default)
moduleVersion = configNode.getString("version", moduleVersion);
std::cout << "[TestModule] Version set to: " << moduleVersion << std::endl;
// Note: moduleVersion is a global compiled into the .so file
// We DO NOT overwrite it from config to preserve hot-reload version changes
std::cout << "[TestModule] Compiled version: " << moduleVersion << std::endl;
}
const IDataNode& getConfiguration() override {