|
2 | 2 |
|
3 | 3 | namespace Tests\Feature; |
4 | 4 |
|
| 5 | +use App\Models\WorkflowNamespace; |
| 6 | +use App\Support\CoordinationHealthContract; |
5 | 7 | use App\Support\ServerTopology; |
6 | 8 | use Illuminate\Foundation\Testing\RefreshDatabase; |
7 | 9 | use Tests\TestCase; |
| 10 | +use Workflow\V2\Support\WorkerCompatibilityFleet; |
8 | 11 |
|
9 | 12 | class ClusterInfoTest extends TestCase |
10 | 13 | { |
@@ -205,6 +208,108 @@ public function test_it_switches_cluster_topology_execution_mode_when_embedded_d |
205 | 208 | ->assertJsonPath('topology.execution_mode', 'local_queue_worker'); |
206 | 209 | } |
207 | 210 |
|
| 211 | + public function test_it_publishes_a_versioned_coordination_health_manifest(): void |
| 212 | + { |
| 213 | + $response = $this->getJson('/api/cluster/info')->assertOk(); |
| 214 | + |
| 215 | + $response |
| 216 | + ->assertJsonPath('coordination_health.schema', CoordinationHealthContract::SCHEMA) |
| 217 | + ->assertJsonPath('coordination_health.version', CoordinationHealthContract::VERSION) |
| 218 | + ->assertJsonPath('coordination_health.namespace_scope', 'all_namespaces') |
| 219 | + ->assertJsonPath('coordination_health.http_status', 200); |
| 220 | + |
| 221 | + $this->assertContains( |
| 222 | + $response->json('coordination_health.status'), |
| 223 | + ['ok', 'warning', 'error', 'blocked', 'unavailable'], |
| 224 | + ); |
| 225 | + $this->assertIsArray($response->json('coordination_health.categories')); |
| 226 | + $this->assertIsArray($response->json('coordination_health.warning_checks')); |
| 227 | + $this->assertIsArray($response->json('coordination_health.error_checks')); |
| 228 | + $this->assertIsArray($response->json('coordination_health.checks')); |
| 229 | + } |
| 230 | + |
| 231 | + public function test_it_surfaces_worker_compatibility_warnings_in_coordination_health(): void |
| 232 | + { |
| 233 | + WorkflowNamespace::query()->create([ |
| 234 | + 'name' => 'default', |
| 235 | + 'description' => 'Default namespace', |
| 236 | + 'retention_days' => 30, |
| 237 | + 'status' => 'active', |
| 238 | + ]); |
| 239 | + |
| 240 | + config([ |
| 241 | + 'workflows.v2.compatibility.current' => 'build-a', |
| 242 | + 'workflows.v2.compatibility.supported' => ['build-a'], |
| 243 | + 'workflows.v2.compatibility.namespace' => 'default', |
| 244 | + 'workflows.v2.fleet.validation_mode' => 'warn', |
| 245 | + ]); |
| 246 | + WorkerCompatibilityFleet::clear(); |
| 247 | + |
| 248 | + try { |
| 249 | + WorkerCompatibilityFleet::recordForNamespace( |
| 250 | + 'default', |
| 251 | + ['build-b'], |
| 252 | + 'database', |
| 253 | + 'default', |
| 254 | + 'worker-b', |
| 255 | + ); |
| 256 | + |
| 257 | + $response = $this->getJson('/api/cluster/info')->assertOk(); |
| 258 | + |
| 259 | + $response |
| 260 | + ->assertJsonPath('coordination_health.status', 'warning') |
| 261 | + ->assertJsonPath('coordination_health.http_status', 200); |
| 262 | + |
| 263 | + $this->assertContains( |
| 264 | + 'worker_compatibility', |
| 265 | + $response->json('coordination_health.warning_checks', []), |
| 266 | + ); |
| 267 | + } finally { |
| 268 | + WorkerCompatibilityFleet::clear(); |
| 269 | + } |
| 270 | + } |
| 271 | + |
| 272 | + public function test_it_fails_coordination_health_closed_when_fleet_validation_requires_compatible_workers(): void |
| 273 | + { |
| 274 | + WorkflowNamespace::query()->create([ |
| 275 | + 'name' => 'default', |
| 276 | + 'description' => 'Default namespace', |
| 277 | + 'retention_days' => 30, |
| 278 | + 'status' => 'active', |
| 279 | + ]); |
| 280 | + |
| 281 | + config([ |
| 282 | + 'workflows.v2.compatibility.current' => 'build-a', |
| 283 | + 'workflows.v2.compatibility.supported' => ['build-a'], |
| 284 | + 'workflows.v2.compatibility.namespace' => 'default', |
| 285 | + 'workflows.v2.fleet.validation_mode' => 'fail', |
| 286 | + ]); |
| 287 | + WorkerCompatibilityFleet::clear(); |
| 288 | + |
| 289 | + try { |
| 290 | + WorkerCompatibilityFleet::recordForNamespace( |
| 291 | + 'default', |
| 292 | + ['build-b'], |
| 293 | + 'database', |
| 294 | + 'default', |
| 295 | + 'worker-b', |
| 296 | + ); |
| 297 | + |
| 298 | + $response = $this->getJson('/api/cluster/info')->assertOk(); |
| 299 | + |
| 300 | + $response |
| 301 | + ->assertJsonPath('coordination_health.status', 'error') |
| 302 | + ->assertJsonPath('coordination_health.http_status', 503); |
| 303 | + |
| 304 | + $this->assertContains( |
| 305 | + 'worker_compatibility', |
| 306 | + $response->json('coordination_health.error_checks', []), |
| 307 | + ); |
| 308 | + } finally { |
| 309 | + WorkerCompatibilityFleet::clear(); |
| 310 | + } |
| 311 | + } |
| 312 | + |
208 | 313 | public function test_it_publishes_matching_role_wake_ownership_for_dedicated_matching_shape(): void |
209 | 314 | { |
210 | 315 | config([ |
|
0 commit comments