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>
119 lines
3.2 KiB
C++
119 lines
3.2 KiB
C++
#include "AutoCompiler.h"
|
|
#include <fstream>
|
|
#include <sstream>
|
|
#include <regex>
|
|
#include <filesystem>
|
|
#include <chrono>
|
|
#include <iostream>
|
|
#include <cstdlib>
|
|
|
|
namespace TestHelpers {
|
|
|
|
AutoCompiler::AutoCompiler(const std::string& moduleName,
|
|
const std::string& buildDir,
|
|
const std::string& sourcePath)
|
|
: moduleName_(moduleName)
|
|
, buildDir_(buildDir)
|
|
, sourcePath_(sourcePath)
|
|
{
|
|
}
|
|
|
|
AutoCompiler::~AutoCompiler() {
|
|
stop();
|
|
}
|
|
|
|
void AutoCompiler::start(int iterations, int intervalMs) {
|
|
if (running_.load()) {
|
|
return; // Already running
|
|
}
|
|
|
|
running_ = true;
|
|
compilationThread_ = std::thread(&AutoCompiler::compilationLoop, this, iterations, intervalMs);
|
|
}
|
|
|
|
void AutoCompiler::stop() {
|
|
running_ = false;
|
|
if (compilationThread_.joinable()) {
|
|
compilationThread_.join();
|
|
}
|
|
}
|
|
|
|
void AutoCompiler::waitForCompletion() {
|
|
if (compilationThread_.joinable()) {
|
|
compilationThread_.join();
|
|
}
|
|
}
|
|
|
|
void AutoCompiler::modifySourceVersion(int iteration) {
|
|
// Read entire file
|
|
std::ifstream inFile(sourcePath_);
|
|
if (!inFile.is_open()) {
|
|
std::cerr << "[AutoCompiler] Failed to open source file: " << sourcePath_ << std::endl;
|
|
return;
|
|
}
|
|
|
|
std::stringstream buffer;
|
|
buffer << inFile.rdbuf();
|
|
inFile.close();
|
|
|
|
std::string content = buffer.str();
|
|
|
|
// Replace version string: moduleVersion = "vX" → moduleVersion = "vITERATION"
|
|
std::regex versionRegex(R"(std::string\s+moduleVersion\s*=\s*"v\d+")");
|
|
std::string newVersion = "std::string moduleVersion = \"v" + std::to_string(iteration) + "\"";
|
|
content = std::regex_replace(content, versionRegex, newVersion);
|
|
|
|
// Write back to file
|
|
std::ofstream outFile(sourcePath_);
|
|
if (!outFile.is_open()) {
|
|
std::cerr << "[AutoCompiler] Failed to write source file: " << sourcePath_ << std::endl;
|
|
return;
|
|
}
|
|
|
|
outFile << content;
|
|
outFile.close();
|
|
}
|
|
|
|
bool AutoCompiler::compile(int iteration) {
|
|
// Modify source version before compiling
|
|
modifySourceVersion(iteration);
|
|
|
|
// Small delay to ensure file is written
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
|
// Build the module using make
|
|
// Note: Tests run from build/tests/, so we use make -C .. to build from build directory
|
|
std::string command;
|
|
if (buildDir_ == "build") {
|
|
command = "make -C .. " + moduleName_ + " 2>&1 > /dev/null";
|
|
} else {
|
|
command = "make -C " + buildDir_ + " " + moduleName_ + " 2>&1 > /dev/null";
|
|
}
|
|
int result = std::system(command.c_str());
|
|
|
|
return (result == 0);
|
|
}
|
|
|
|
void AutoCompiler::compilationLoop(int iterations, int intervalMs) {
|
|
for (int i = 1; i <= iterations && running_.load(); ++i) {
|
|
currentIteration_ = i;
|
|
|
|
// Compile
|
|
bool success = compile(i);
|
|
if (success) {
|
|
successCount_++;
|
|
} else {
|
|
failureCount_++;
|
|
}
|
|
|
|
// Wait for next iteration
|
|
if (i < iterations) {
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(intervalMs));
|
|
}
|
|
}
|
|
|
|
running_ = false;
|
|
}
|
|
|
|
} // namespace TestHelpers
|