feat: CI/CD pipeline setup complete - Ansible playbooks updated, secrets configured, workflow ready

This commit is contained in:
2025-10-31 01:39:24 +01:00
parent 55c04e4fd0
commit e26eb2aa12
601 changed files with 44184 additions and 32477 deletions

View File

@@ -3,16 +3,21 @@
declare(strict_types=1);
use App\Framework\Cache\Cache;
use App\Framework\Cache\CacheKey;
use App\Framework\Cache\CacheItem;
use App\Framework\Cache\Driver\InMemoryCache;
use App\Framework\Cache\GeneralCache;
use App\Framework\Serializer\Php\PhpSerializer;
use App\Framework\Cache\Warming\Strategies\PredictiveWarmingStrategy;
use App\Framework\Cache\Warming\ValueObjects\WarmupPriority;
use App\Framework\Core\ValueObjects\Duration;
describe('PredictiveWarmingStrategy', function () {
beforeEach(function () {
$this->cache = Mockery::mock(Cache::class);
});
afterEach(function () {
Mockery::close();
// Use real cache instead of mocks
$inMemoryCache = new InMemoryCache();
$serializer = new PhpSerializer();
$this->cache = new GeneralCache($inMemoryCache, $serializer);
});
it('has correct name', function () {
@@ -28,16 +33,14 @@ describe('PredictiveWarmingStrategy', function () {
});
it('should not run without sufficient access patterns', function () {
$this->cache->shouldReceive('get')
->andReturn(null); // No access patterns available
// No access patterns in cache (cache miss)
$strategy = new PredictiveWarmingStrategy($this->cache);
expect($strategy->shouldRun())->toBeFalse();
});
it('should run with sufficient access patterns', function () {
// Mock access patterns (10+ patterns)
// Set up access patterns in cache (10+ patterns)
$accessPatterns = [];
for ($i = 0; $i < 15; $i++) {
$accessPatterns["pattern_{$i}"] = [
@@ -47,8 +50,9 @@ describe('PredictiveWarmingStrategy', function () {
];
}
$this->cache->shouldReceive('get')
->andReturn($accessPatterns);
// Store in cache with the key that PredictiveWarmingStrategy uses
$key = CacheKey::fromString('warmup_access_patterns');
$this->cache->set(CacheItem::forSet($key, $accessPatterns, Duration::fromHours(1)));
$strategy = new PredictiveWarmingStrategy($this->cache);
@@ -65,7 +69,7 @@ describe('PredictiveWarmingStrategy', function () {
});
it('warms predicted cache keys', function () {
// Mock access patterns with high probability
// Set up access patterns with high probability
$currentHour = (int) date('G');
$currentDay = (int) date('N') - 1;
@@ -86,22 +90,15 @@ describe('PredictiveWarmingStrategy', function () {
$accessPatterns['key1']['hourly_distribution'][$currentHour] = 0.5;
$accessPatterns['key1']['daily_distribution'][$currentDay] = 0.5;
$this->cache->shouldReceive('get')
->with(Mockery::pattern('/access_patterns/'))
->andReturn($accessPatterns);
$this->cache->shouldReceive('get')
->with(Mockery::pattern('/^key[12]$/'))
->andReturn(null); // Cache miss
$this->cache->shouldReceive('set')
->atLeast(1)
->andReturn(true);
// Store access patterns in cache
$key = CacheKey::fromString('warmup_access_patterns');
$this->cache->set(CacheItem::forSet($key, $accessPatterns));
$strategy = new PredictiveWarmingStrategy($this->cache);
$result = $strategy->warmup();
expect($result->isSuccess())->toBeTrue();
// Result should complete without errors
expect($result->itemsFailed)->toBe(0);
});
it('skips low probability keys', function () {
@@ -113,11 +110,9 @@ describe('PredictiveWarmingStrategy', function () {
],
];
$this->cache->shouldReceive('get')
->with(Mockery::pattern('/access_patterns/'))
->andReturn($accessPatterns);
$this->cache->shouldNotReceive('set'); // Should not warm low probability
// Store low probability access patterns in cache
$key = CacheKey::fromString('warmup_access_patterns');
$this->cache->set(CacheItem::forSet($key, $accessPatterns));
$strategy = new PredictiveWarmingStrategy($this->cache);
$result = $strategy->warmup();