|
4 | 4 |
|
5 | 5 | namespace Tests\Unit\V2; |
6 | 6 |
|
| 7 | +use Illuminate\Cache\CacheManager; |
| 8 | +use Illuminate\Cache\Repository; |
7 | 9 | use Illuminate\Support\Carbon; |
| 10 | +use Tests\Support\NonLockingCacheStore; |
8 | 11 | use Tests\TestCase; |
9 | 12 | use Workflow\V2\Support\BackendCapabilities; |
10 | 13 |
|
@@ -93,11 +96,17 @@ public function testSnapshotIncludesFrozenReadinessContractMatrix(): void |
93 | 96 | 'info', |
94 | 97 | $contract['backend_capabilities']['queue']['poll_mode']['sync_or_missing_queue_severity'] |
95 | 98 | ); |
| 99 | + $this->assertSame('warning', $contract['backend_capabilities']['cache']['dispatch_blocking_severity']); |
| 100 | + $this->assertSame('acceleration_only', $contract['backend_capabilities']['cache']['role']); |
96 | 101 | $this->assertSame('avro', $contract['backend_capabilities']['codec']['default_for_new_v2_runs']); |
97 | 102 | $this->assertSame( |
98 | 103 | 'evaluated_by_backend_capabilities_snapshot', |
99 | 104 | $contract['effective_states']['dispatch']['state'] |
100 | 105 | ); |
| 106 | + $this->assertStringContainsString( |
| 107 | + 'cache diagnostics stay warning-only', |
| 108 | + $contract['effective_states']['dispatch']['blocking_rule'] |
| 109 | + ); |
101 | 110 | } |
102 | 111 |
|
103 | 112 | public function testSnapshotCanInspectAnExplicitTaskQueueConnection(): void |
@@ -372,6 +381,8 @@ public function testSnapshotIncludesSeverityRollupOfOkWhenAdmissionIsClean(): vo |
372 | 381 | ->set('cache.default', 'array'); |
373 | 382 | config() |
374 | 383 | ->set('cache.stores.array.driver', 'array'); |
| 384 | + config() |
| 385 | + ->set('workflows.serializer', 'avro'); |
375 | 386 |
|
376 | 387 | $snapshot = BackendCapabilities::snapshot(); |
377 | 388 |
|
@@ -439,4 +450,49 @@ public function testSnapshotSeverityRollupReportsErrorWhenAnyIssueIsErrorSeverit |
439 | 450 | $this->assertSame('error', $snapshot['severity']); |
440 | 451 | $this->assertFalse($snapshot['supported']); |
441 | 452 | } |
| 453 | + |
| 454 | + public function testCustomNoLockCacheStoreIsWarningOnlyAndDoesNotFailSupport(): void |
| 455 | + { |
| 456 | + config()->set('database.default', 'pgsql'); |
| 457 | + config() |
| 458 | + ->set('database.connections.pgsql.driver', 'pgsql'); |
| 459 | + config() |
| 460 | + ->set('queue.default', 'redis'); |
| 461 | + config() |
| 462 | + ->set('queue.connections.redis.driver', 'redis'); |
| 463 | + config() |
| 464 | + ->set('workflows.serializer', 'avro'); |
| 465 | + $this->configureNonLockingCacheStore(); |
| 466 | + |
| 467 | + $snapshot = BackendCapabilities::snapshot(); |
| 468 | + |
| 469 | + $this->assertTrue($snapshot['supported']); |
| 470 | + $this->assertTrue(BackendCapabilities::isSupported($snapshot)); |
| 471 | + $this->assertTrue($snapshot['cache']['supported']); |
| 472 | + $this->assertSame('warning', $snapshot['severity']); |
| 473 | + |
| 474 | + $cacheIssue = collect($snapshot['issues'])->firstWhere('code', 'cache_locks_unsupported'); |
| 475 | + $this->assertNotNull($cacheIssue); |
| 476 | + $this->assertSame('warning', $cacheIssue['severity']); |
| 477 | + $this->assertStringContainsString('Wake acceleration remains optional', $cacheIssue['message']); |
| 478 | + } |
| 479 | + |
| 480 | + private function configureNonLockingCacheStore(): void |
| 481 | + { |
| 482 | + $driver = 'test-non-locking'; |
| 483 | + $store = 'test-non-locking'; |
| 484 | + |
| 485 | + $this->app['cache']->extend($driver, function (): Repository { |
| 486 | + if (! $this instanceof CacheManager) { |
| 487 | + throw new \RuntimeException('Unexpected cache manager binding.'); |
| 488 | + } |
| 489 | + |
| 490 | + return new Repository(new NonLockingCacheStore()); |
| 491 | + }); |
| 492 | + |
| 493 | + config() |
| 494 | + ->set("cache.stores.{$store}.driver", $driver); |
| 495 | + config() |
| 496 | + ->set('cache.default', $store); |
| 497 | + } |
442 | 498 | } |
0 commit comments