- 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.
117 lines
3.7 KiB
PHP
117 lines
3.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once '/var/www/html/vendor/autoload.php';
|
|
require_once '/var/www/html/tests/bootstrap.php';
|
|
|
|
use App\Framework\Database\ConnectionInterface;
|
|
|
|
echo "🧪 Testing Queue System with Simple Approach...\n\n";
|
|
|
|
// Test 1: Check Database Tables exist using Framework Configuration
|
|
echo "1. Testing Database Tables (using Framework Configuration):\n";
|
|
|
|
try {
|
|
// Use framework's test container creation function
|
|
$container = createTestContainer();
|
|
|
|
$connection = $container->get(ConnectionInterface::class);
|
|
echo " ✅ Framework database connection established\n";
|
|
|
|
$tables = [
|
|
'queue_workers',
|
|
'distributed_locks',
|
|
'job_assignments',
|
|
'worker_health_checks',
|
|
'failover_events',
|
|
];
|
|
|
|
foreach ($tables as $table) {
|
|
$stmt = $connection->prepare("SHOW TABLES LIKE ?");
|
|
$stmt->execute([$table]);
|
|
if ($stmt->fetchColumn()) {
|
|
echo " ✅ Table '$table' exists\n";
|
|
} else {
|
|
echo " ❌ Table '$table' missing\n";
|
|
}
|
|
}
|
|
} catch (Exception $e) {
|
|
echo " ❌ Database error: " . $e->getMessage() . "\n";
|
|
}
|
|
|
|
// Test 2: Test Value Objects
|
|
echo "\n2. Testing Value Objects:\n";
|
|
|
|
try {
|
|
require_once '/var/www/html/vendor/autoload.php';
|
|
|
|
// Test WorkerId
|
|
$workerId = \App\Framework\Queue\ValueObjects\WorkerId::generate();
|
|
echo " ✅ WorkerId generation: " . $workerId->toString() . "\n";
|
|
|
|
// Test QueueName
|
|
$queueName = \App\Framework\Queue\ValueObjects\QueueName::forCommand('test');
|
|
echo " ✅ QueueName creation: " . $queueName->toString() . "\n";
|
|
|
|
// Test JobId
|
|
$jobId = \App\Framework\Queue\ValueObjects\JobId::generate();
|
|
echo " ✅ JobId generation: " . $jobId->toString() . "\n";
|
|
|
|
// Test LockKey
|
|
$lockKey = \App\Framework\Queue\ValueObjects\LockKey::forQueue($queueName);
|
|
echo " ✅ LockKey creation: " . $lockKey->toString() . "\n";
|
|
|
|
} catch (Exception $e) {
|
|
echo " ❌ Value Object error: " . $e->getMessage() . "\n";
|
|
}
|
|
|
|
// Test 3: Test Console Commands are discoverable
|
|
echo "\n3. Testing Console Commands Discovery:\n";
|
|
|
|
try {
|
|
$output = shell_exec('docker exec php php console.php --help 2>/dev/null | grep worker');
|
|
if ($output && strpos($output, 'worker') !== false) {
|
|
echo " ✅ Worker commands discovered\n";
|
|
echo " 📝 Found: " . trim($output) . "\n";
|
|
} else {
|
|
echo " ❌ Worker commands not found or command failed\n";
|
|
}
|
|
} catch (Exception $e) {
|
|
echo " ❌ Console command discovery error: " . $e->getMessage() . "\n";
|
|
}
|
|
|
|
// Test 4: Test database connectivity for queue tables
|
|
echo "\n4. Testing Database Table Structure:\n";
|
|
|
|
try {
|
|
// Test queue_workers table structure using DESCRIBE (MySQL/MariaDB)
|
|
$stmt = $connection->prepare("DESCRIBE queue_workers");
|
|
$stmt->execute();
|
|
$columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
if (count($columns) > 0) {
|
|
echo " ✅ queue_workers table has " . count($columns) . " columns\n";
|
|
$expectedColumns = ['id', 'worker_id', 'hostname', 'pid', 'queues', 'status', 'last_heartbeat', 'created_at', 'updated_at'];
|
|
foreach ($expectedColumns as $col) {
|
|
$found = false;
|
|
foreach ($columns as $column) {
|
|
if ($column['Field'] === $col) { // MySQL uses 'Field' not 'name'
|
|
$found = true;
|
|
|
|
break;
|
|
}
|
|
}
|
|
if ($found) {
|
|
echo " ✅ Column '$col' exists\n";
|
|
} else {
|
|
echo " ❌ Column '$col' missing\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
echo " ❌ Table structure error: " . $e->getMessage() . "\n";
|
|
}
|
|
|
|
echo "\n🎯 Simple Queue System test completed!\n";
|