- Create AnsibleDeployStage using framework's Process module for secure command execution - Integrate AnsibleDeployStage into DeploymentPipelineCommands for production deployments - Add force_deploy flag support in Ansible playbook to override stale locks - Use PHP deployment module as orchestrator (php console.php deploy:production) - Fix ErrorAggregationInitializer to use Environment class instead of $_ENV superglobal Architecture: - BuildStage → AnsibleDeployStage → HealthCheckStage for production - Process module provides timeout, error handling, and output capture - Ansible playbook supports rollback via rollback-git-based.yml - Zero-downtime deployments with health checks
113 lines
3.9 KiB
PHP
113 lines
3.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Manual Test for ML Monitoring Scheduler
|
|
*
|
|
* Tests scheduler job registration and execution simulation
|
|
*/
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\Core\AppBootstrapper;
|
|
use App\Framework\MachineLearning\Scheduler\MLMonitoringScheduler;
|
|
use App\Framework\Scheduler\Services\SchedulerService;
|
|
|
|
echo "=== ML Monitoring Scheduler Manual Test ===\n\n";
|
|
|
|
try {
|
|
// Bootstrap framework
|
|
echo "1. Bootstrapping framework...\n";
|
|
$basePath = dirname(__DIR__, 2);
|
|
|
|
// Create minimal dependencies
|
|
$clock = new \App\Framework\DateTime\SystemClock();
|
|
$highResClock = new \App\Framework\DateTime\SystemHighResolutionClock();
|
|
$memoryMonitor = new \App\Framework\Performance\MemoryMonitor();
|
|
$collector = new \App\Framework\Performance\EnhancedPerformanceCollector(
|
|
$clock,
|
|
$highResClock,
|
|
$memoryMonitor,
|
|
enabled: false
|
|
);
|
|
|
|
$bootstrapper = new AppBootstrapper($basePath, $collector, $memoryMonitor);
|
|
$container = $bootstrapper->bootstrapWorker();
|
|
echo " ✓ Framework bootstrapped\n\n";
|
|
|
|
// Manually initialize ML Model Management
|
|
echo " → Manually registering ML Model Management services...\n";
|
|
$mlInitializer = new \App\Framework\MachineLearning\ModelManagement\MLModelManagementInitializer($container);
|
|
$mlInitializer->initialize();
|
|
echo " ✓ ML Model Management initialized\n\n";
|
|
|
|
// Get scheduler services
|
|
echo "2. Testing Scheduler Services...\n";
|
|
$schedulerService = $container->get(SchedulerService::class);
|
|
echo " ✓ SchedulerService retrieved\n";
|
|
|
|
$mlScheduler = $container->get(MLMonitoringScheduler::class);
|
|
echo " ✓ MLMonitoringScheduler retrieved\n\n";
|
|
|
|
// Schedule all ML monitoring jobs
|
|
echo "3. Scheduling ML Monitoring Jobs...\n";
|
|
try {
|
|
$mlScheduler->scheduleAll();
|
|
echo " ✓ All ML monitoring jobs scheduled\n\n";
|
|
} catch (\Throwable $e) {
|
|
echo " ✗ Scheduling error: " . $e->getMessage() . "\n";
|
|
echo " File: " . $e->getFile() . ":" . $e->getLine() . "\n\n";
|
|
}
|
|
|
|
// Check scheduled tasks
|
|
echo "4. Verifying Scheduled Tasks...\n";
|
|
try {
|
|
$dueTasks = $schedulerService->getDueTasks();
|
|
echo " ✓ getDueTasks() works\n";
|
|
echo " - Currently due tasks: " . count($dueTasks) . "\n";
|
|
} catch (\Throwable $e) {
|
|
echo " ✗ Verification error: " . $e->getMessage() . "\n";
|
|
}
|
|
echo "\n";
|
|
|
|
// Test immediate execution of due tasks (simulation)
|
|
echo "5. Testing Task Execution (Simulation)...\n";
|
|
try {
|
|
$results = $schedulerService->executeDueTasks();
|
|
echo " ✓ executeDueTasks() completed\n";
|
|
echo " - Tasks executed: " . count($results) . "\n";
|
|
|
|
foreach ($results as $result) {
|
|
$status = $result->success ? '✓' : '✗';
|
|
echo " {$status} {$result->taskName}: ";
|
|
|
|
if ($result->success) {
|
|
echo "Success\n";
|
|
if (!empty($result->returnValue)) {
|
|
echo " Return: " . json_encode($result->returnValue, JSON_PRETTY_PRINT) . "\n";
|
|
}
|
|
} else {
|
|
echo "Failed\n";
|
|
if ($result->error !== null) {
|
|
echo " Error: " . $result->error . "\n";
|
|
}
|
|
}
|
|
}
|
|
} catch (\Throwable $e) {
|
|
echo " ✗ Execution error: " . $e->getMessage() . "\n";
|
|
echo " File: " . $e->getFile() . ":" . $e->getLine() . "\n";
|
|
}
|
|
echo "\n";
|
|
|
|
echo "=== Scheduler Test Completed ===\n";
|
|
echo "✓ Scheduler integration test successful\n";
|
|
|
|
} catch (\Throwable $e) {
|
|
echo "\n!!! FATAL ERROR !!!\n";
|
|
echo "Error: " . $e->getMessage() . "\n";
|
|
echo "File: " . $e->getFile() . ":" . $e->getLine() . "\n";
|
|
echo "\nStack trace:\n" . $e->getTraceAsString() . "\n";
|
|
exit(1);
|
|
}
|