|
5 | 5 | namespace Tests\Feature\V2; |
6 | 6 |
|
7 | 7 | use Illuminate\Support\Carbon; |
8 | | -use Illuminate\Support\Facades\Schema; |
9 | 8 | use Tests\TestCase; |
10 | 9 | use Workflow\V2\Enums\ActivityStatus; |
11 | 10 | use Workflow\V2\Enums\CommandOutcome; |
@@ -50,31 +49,26 @@ public function testWorkerFleetSnapshotFallsBackToCacheWhenHeartbeatTableIsUnava |
50 | 49 | ->set('workflows.v2.compatibility.namespace', 'metrics-test'); |
51 | 50 |
|
52 | 51 | WorkerCompatibilityFleet::clear(); |
53 | | - Schema::dropIfExists('workflow_worker_compatibility_heartbeats'); |
54 | | - |
55 | | - try { |
56 | | - WorkerCompatibilityFleet::record(['build-a'], 'redis', 'default', 'worker-a'); |
57 | | - |
58 | | - $snapshot = OperatorMetrics::snapshot(); |
59 | | - |
60 | | - $this->assertSame(1, $snapshot['workers']['active_workers']); |
61 | | - $this->assertSame(1, $snapshot['workers']['active_worker_scopes']); |
62 | | - $this->assertSame(1, $snapshot['workers']['active_workers_supporting_required']); |
63 | | - $this->assertCount(1, $snapshot['workers']['fleet']); |
64 | | - $this->assertSame('worker-a', $snapshot['workers']['fleet'][0]['worker_id']); |
65 | | - $this->assertSame('cache', $snapshot['workers']['fleet'][0]['source']); |
66 | | - $this->assertTrue($snapshot['workers']['fleet'][0]['supports_required']); |
67 | | - } finally { |
68 | | - // Restore the dropped table within this test so the next test |
69 | | - // does not depend on Testbench's per-test migrate:fresh racing |
70 | | - // to re-create it. Re-running the migration's up() keeps the |
71 | | - // restored schema in sync with the canonical definition. |
72 | | - if (! Schema::hasTable('workflow_worker_compatibility_heartbeats')) { |
73 | | - $migration = require __DIR__ |
74 | | - . '/../../../src/migrations/2026_04_08_000126_create_worker_compatibility_heartbeats_table.php'; |
75 | | - $migration->up(); |
76 | | - } |
77 | | - } |
| 52 | + |
| 53 | + // Force the fleet onto the legacy cache-only path via configuration |
| 54 | + // instead of dropping the heartbeats table. Dropping the table |
| 55 | + // mutated shared schema state and depended on Testbench's per-test |
| 56 | + // migrate:fresh in the next test to restore it, which raced when |
| 57 | + // the file's tests ran back-to-back in a single PHPUnit process. |
| 58 | + config() |
| 59 | + ->set('workflows.v2.compatibility.disable_heartbeat_table', true); |
| 60 | + |
| 61 | + WorkerCompatibilityFleet::record(['build-a'], 'redis', 'default', 'worker-a'); |
| 62 | + |
| 63 | + $snapshot = OperatorMetrics::snapshot(); |
| 64 | + |
| 65 | + $this->assertSame(1, $snapshot['workers']['active_workers']); |
| 66 | + $this->assertSame(1, $snapshot['workers']['active_worker_scopes']); |
| 67 | + $this->assertSame(1, $snapshot['workers']['active_workers_supporting_required']); |
| 68 | + $this->assertCount(1, $snapshot['workers']['fleet']); |
| 69 | + $this->assertSame('worker-a', $snapshot['workers']['fleet'][0]['worker_id']); |
| 70 | + $this->assertSame('cache', $snapshot['workers']['fleet'][0]['source']); |
| 71 | + $this->assertTrue($snapshot['workers']['fleet'][0]['supports_required']); |
78 | 72 | } |
79 | 73 |
|
80 | 74 | public function testWorkerFleetSnapshotUsesRequestedNamespaceInsteadOfConfiguredCompatibilityNamespace(): void |
|
0 commit comments