feat(Production): Complete production deployment infrastructure

- Add comprehensive health check system with multiple endpoints
- Add Prometheus metrics endpoint
- Add production logging configurations (5 strategies)
- Add complete deployment documentation suite:
  * QUICKSTART.md - 30-minute deployment guide
  * DEPLOYMENT_CHECKLIST.md - Printable verification checklist
  * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle
  * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference
  * production-logging.md - Logging configuration guide
  * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation
  * README.md - Navigation hub
  * DEPLOYMENT_SUMMARY.md - Executive summary
- Add deployment scripts and automation
- Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment
- Update README with production-ready features

All production infrastructure is now complete and ready for deployment.
This commit is contained in:
2025-10-25 19:18:37 +02:00
parent caa85db796
commit fc3d7e6357
83016 changed files with 378904 additions and 20919 deletions

View File

@@ -16,9 +16,13 @@ use PHPUnit\Framework\TestCase;
final class FailoverPerformanceTest extends TestCase
{
private DatabaseManager $database;
private WorkerRegistry $workerRegistry;
private WorkerHealthCheckService $healthCheckService;
private FailoverRecoveryService $failoverService;
private JobDistributionService $distributionService;
protected function setUp(): void
@@ -70,7 +74,7 @@ final class FailoverPerformanceTest extends TestCase
$iterations = 10;
for ($i = 0; $i < $iterations; $i++) {
$time = PerformanceTestHelper::measureTime(function() {
$time = PerformanceTestHelper::measureTime(function () {
return $this->healthCheckService->checkAllWorkers();
});
$detectionTimes[] = $time;
@@ -83,7 +87,7 @@ final class FailoverPerformanceTest extends TestCase
// Verify failed workers were detected
$failedWorkers = $this->workerRegistry->getWorkersByStatus(WorkerStatus::FAILED);
$detectedFailures = array_map(fn($w) => $w->id->toString(), $failedWorkers);
$detectedFailures = array_map(fn ($w) => $w->id->toString(), $failedWorkers);
echo "\nWorker Failure Detection Results:\n";
echo "Workers created: " . count($workers) . "\n";
@@ -123,7 +127,7 @@ final class FailoverPerformanceTest extends TestCase
if ($assignedWorker) {
$assignedJobs[] = [
'job' => $job,
'worker_id' => $assignedWorker->id->toString()
'worker_id' => $assignedWorker->id->toString(),
];
}
}
@@ -135,7 +139,7 @@ final class FailoverPerformanceTest extends TestCase
// Find jobs assigned to failed worker
$jobsToReassign = array_filter(
$assignedJobs,
fn($item) => $item['worker_id'] === $failedWorkerId
fn ($item) => $item['worker_id'] === $failedWorkerId
);
echo "\nJob Reassignment Test:\n";
@@ -143,7 +147,7 @@ final class FailoverPerformanceTest extends TestCase
echo "Jobs to reassign: " . count($jobsToReassign) . "\n";
// Measure job reassignment performance
$reassignmentTime = PerformanceTestHelper::measureTime(function() use ($failedWorkerId) {
$reassignmentTime = PerformanceTestHelper::measureTime(function () use ($failedWorkerId) {
return $this->failoverService->reassignFailedWorkerJobs($failedWorkerId);
});
@@ -184,7 +188,7 @@ final class FailoverPerformanceTest extends TestCase
$failedWorkerIds = [
$workers[0]->id->toString(),
$workers[1]->id->toString(),
$workers[2]->id->toString()
$workers[2]->id->toString(),
];
foreach ($failedWorkerIds as $workerId) {
@@ -197,7 +201,7 @@ final class FailoverPerformanceTest extends TestCase
echo "Total jobs: " . count($jobs) . "\n";
// Measure full system recovery time
$recoveryTime = PerformanceTestHelper::measureTime(function() {
$recoveryTime = PerformanceTestHelper::measureTime(function () {
return $this->failoverService->performFullSystemRecovery();
});
@@ -231,7 +235,7 @@ final class FailoverPerformanceTest extends TestCase
PerformanceTestHelper::createTestWorker('medium_capacity_1', 20),
PerformanceTestHelper::createTestWorker('medium_capacity_2', 20),
PerformanceTestHelper::createTestWorker('low_capacity_1', 10),
PerformanceTestHelper::createTestWorker('low_capacity_2', 10)
PerformanceTestHelper::createTestWorker('low_capacity_2', 10),
];
$this->registerWorkers($workers);
@@ -289,7 +293,7 @@ final class FailoverPerformanceTest extends TestCase
while (microtime(true) < $endTime) {
$job = PerformanceTestHelper::createTestJob("load_job_{$jobsDistributed}");
$result = PerformanceTestHelper::measureTimeWithResult(function() use ($job) {
$result = PerformanceTestHelper::measureTimeWithResult(function () use ($job) {
try {
return $this->distributionService->distributeJob($job);
} catch (\Exception $e) {
@@ -352,7 +356,7 @@ final class FailoverPerformanceTest extends TestCase
$failedWorkerIds = [
$workers[0]->id->toString(),
$workers[1]->id->toString(),
$workers[2]->id->toString()
$workers[2]->id->toString(),
];
foreach ($failedWorkerIds as $workerId) {
@@ -369,7 +373,7 @@ final class FailoverPerformanceTest extends TestCase
// Update heartbeat to simulate worker recovery
$this->updateWorkerHeartbeat($workerId, new \DateTimeImmutable());
$recoveryTime = PerformanceTestHelper::measureTime(function() use ($workerId) {
$recoveryTime = PerformanceTestHelper::measureTime(function () use ($workerId) {
// Simulate health check detecting recovery
$this->healthCheckService->checkWorker($workerId);
@@ -434,6 +438,7 @@ final class FailoverPerformanceTest extends TestCase
WorkerStatus::AVAILABLE
);
}
return $workers;
}
@@ -463,6 +468,7 @@ final class FailoverPerformanceTest extends TestCase
$pdo = $this->database->getConnection();
$stmt = $pdo->prepare('SELECT COUNT(*) FROM jobs WHERE worker_id != ? AND worker_id IS NOT NULL');
$stmt->execute([$failedWorkerId]);
return (int) $stmt->fetchColumn();
}
@@ -471,6 +477,7 @@ final class FailoverPerformanceTest extends TestCase
$pdo = $this->database->getConnection();
$stmt = $pdo->prepare('SELECT COUNT(*) FROM jobs WHERE status = ?');
$stmt->execute([$status->value]);
return (int) $stmt->fetchColumn();
}
@@ -521,4 +528,4 @@ final class FailoverPerformanceTest extends TestCase
$pdo->exec('DELETE FROM workers');
$pdo->exec('DELETE FROM jobs');
}
}
}