- 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.
158 lines
5.4 KiB
PHP
158 lines
5.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Framework\Deployment\Pipeline\ValueObjects\DeploymentEnvironment;
|
|
use App\Framework\Deployment\Pipeline\ValueObjects\PipelineConfig;
|
|
use App\Framework\Deployment\Pipeline\ValueObjects\PipelineStage;
|
|
use App\Framework\Deployment\Pipeline\ValueObjects\StageConfig;
|
|
|
|
describe('PipelineConfig', function () {
|
|
it('creates pipeline configuration with default values', function () {
|
|
$stages = [
|
|
StageConfig::forStage(PipelineStage::BUILD),
|
|
StageConfig::forStage(PipelineStage::TEST),
|
|
];
|
|
|
|
$config = new PipelineConfig(
|
|
name: 'Test Pipeline',
|
|
environment: DeploymentEnvironment::DEVELOPMENT,
|
|
stages: $stages
|
|
);
|
|
|
|
expect($config->name)->toBe('Test Pipeline');
|
|
expect($config->environment)->toBe(DeploymentEnvironment::DEVELOPMENT);
|
|
expect($config->stopOnFailure)->toBeTrue();
|
|
expect($config->enableRollback)->toBeFalse();
|
|
expect($config->globalParameters)->toBeEmpty();
|
|
});
|
|
|
|
it('creates pipeline configuration with custom values', function () {
|
|
$stages = [StageConfig::forStage(PipelineStage::BUILD)];
|
|
|
|
$config = new PipelineConfig(
|
|
name: 'Custom Pipeline',
|
|
environment: DeploymentEnvironment::PRODUCTION,
|
|
stages: $stages,
|
|
stopOnFailure: false,
|
|
enableRollback: true,
|
|
globalParameters: ['key' => 'value']
|
|
);
|
|
|
|
expect($config->stopOnFailure)->toBeFalse();
|
|
expect($config->enableRollback)->toBeTrue();
|
|
expect($config->globalParameters)->toHaveKey('key');
|
|
});
|
|
|
|
it('returns all stages', function () {
|
|
$stages = [
|
|
StageConfig::forStage(PipelineStage::BUILD),
|
|
StageConfig::forStage(PipelineStage::TEST),
|
|
StageConfig::forStage(PipelineStage::DEPLOY),
|
|
];
|
|
|
|
$config = new PipelineConfig(
|
|
name: 'Test Pipeline',
|
|
environment: DeploymentEnvironment::DEVELOPMENT,
|
|
stages: $stages
|
|
);
|
|
|
|
expect($config->getStages())->toHaveCount(3);
|
|
});
|
|
|
|
it('returns only enabled stages', function () {
|
|
$stages = [
|
|
new StageConfig(stage: PipelineStage::BUILD, enabled: true),
|
|
new StageConfig(stage: PipelineStage::TEST, enabled: false),
|
|
new StageConfig(stage: PipelineStage::DEPLOY, enabled: true),
|
|
];
|
|
|
|
$config = new PipelineConfig(
|
|
name: 'Test Pipeline',
|
|
environment: DeploymentEnvironment::DEVELOPMENT,
|
|
stages: $stages
|
|
);
|
|
|
|
$enabledStages = $config->getEnabledStages();
|
|
|
|
expect($enabledStages)->toHaveCount(2);
|
|
expect($enabledStages[0]->stage)->toBe(PipelineStage::BUILD);
|
|
expect($enabledStages[1]->stage)->toBe(PipelineStage::DEPLOY);
|
|
});
|
|
|
|
it('finds stage by type', function () {
|
|
$stages = [
|
|
StageConfig::forStage(PipelineStage::BUILD),
|
|
StageConfig::forStage(PipelineStage::TEST),
|
|
];
|
|
|
|
$config = new PipelineConfig(
|
|
name: 'Test Pipeline',
|
|
environment: DeploymentEnvironment::DEVELOPMENT,
|
|
stages: $stages
|
|
);
|
|
|
|
$buildStage = $config->findStage(PipelineStage::BUILD);
|
|
|
|
expect($buildStage)->not->toBeNull();
|
|
expect($buildStage->stage)->toBe(PipelineStage::BUILD);
|
|
});
|
|
|
|
it('returns null for non-existent stage', function () {
|
|
$stages = [StageConfig::forStage(PipelineStage::BUILD)];
|
|
|
|
$config = new PipelineConfig(
|
|
name: 'Test Pipeline',
|
|
environment: DeploymentEnvironment::DEVELOPMENT,
|
|
stages: $stages
|
|
);
|
|
|
|
$deployStage = $config->findStage(PipelineStage::DEPLOY);
|
|
|
|
expect($deployStage)->toBeNull();
|
|
});
|
|
|
|
it('checks if stage is enabled', function () {
|
|
$stages = [
|
|
new StageConfig(stage: PipelineStage::BUILD, enabled: true),
|
|
new StageConfig(stage: PipelineStage::TEST, enabled: false),
|
|
];
|
|
|
|
$config = new PipelineConfig(
|
|
name: 'Test Pipeline',
|
|
environment: DeploymentEnvironment::DEVELOPMENT,
|
|
stages: $stages
|
|
);
|
|
|
|
expect($config->isStageEnabled(PipelineStage::BUILD))->toBeTrue();
|
|
expect($config->isStageEnabled(PipelineStage::TEST))->toBeFalse();
|
|
expect($config->isStageEnabled(PipelineStage::DEPLOY))->toBeFalse(); // Not in config
|
|
});
|
|
|
|
it('gets global parameter with default', function () {
|
|
$config = new PipelineConfig(
|
|
name: 'Test Pipeline',
|
|
environment: DeploymentEnvironment::DEVELOPMENT,
|
|
stages: [],
|
|
globalParameters: ['timeout' => 300]
|
|
);
|
|
|
|
expect($config->getGlobalParameter('timeout'))->toBe(300);
|
|
expect($config->getGlobalParameter('missing', 'default'))->toBe('default');
|
|
});
|
|
|
|
it('creates config for different environment', function () {
|
|
$original = new PipelineConfig(
|
|
name: 'Test Pipeline',
|
|
environment: DeploymentEnvironment::DEVELOPMENT,
|
|
stages: [StageConfig::forStage(PipelineStage::BUILD)]
|
|
);
|
|
|
|
$production = $original->forEnvironment(DeploymentEnvironment::PRODUCTION);
|
|
|
|
expect($production->environment)->toBe(DeploymentEnvironment::PRODUCTION);
|
|
expect($production->name)->toBe($original->name);
|
|
expect($production->stages)->toBe($original->stages);
|
|
});
|
|
});
|