Fix API CI failures
This commit is contained in:
@@ -314,7 +314,9 @@ it('creates updates lists and deactivates scoped employees without exposing raw
|
||||
|
||||
expect($deactivated->data()['active'] ?? true)->toBeFalse();
|
||||
$userRow = api_test_runtime()->queryOne('SELECT `password`, `group_id`, `deleted_at` FROM `users` WHERE `id` = ' . $employeeId);
|
||||
expect($userRow['password'] ?? 'not-null')->toBeNull();
|
||||
expect($userRow)->not->toBeNull();
|
||||
expect(array_key_exists('password', $userRow ?? []))->toBeTrue();
|
||||
expect($userRow['password'])->toBeNull();
|
||||
expect((int)($userRow['group_id'] ?? -1))->toBe(0);
|
||||
expect($userRow['deleted_at'] ?? null)->not->toBeNull();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
it('services broker transport before replaying queued outbox items', function (): void {
|
||||
$agentSource = (string)file_get_contents(app_path('resources/edge-gateway-agent/agent.php'));
|
||||
$runOffset = strpos($agentSource, 'public function run(): void');
|
||||
expect($runOffset)->not->toBeFalse();
|
||||
|
||||
$loopSource = substr($agentSource, (int)$runOffset, 1800);
|
||||
$configureOffset = strpos($loopSource, '$this->configureBrokerClient();');
|
||||
$pumpOffset = strpos($loopSource, '$this->pumpBrokerTransport();');
|
||||
$flushOffset = strpos($loopSource, '$this->flushOutbox();');
|
||||
|
||||
expect($configureOffset)->not->toBeFalse()
|
||||
->and($pumpOffset)->not->toBeFalse()
|
||||
->and($flushOffset)->not->toBeFalse()
|
||||
->and((int)$configureOffset)->toBeLessThan((int)$pumpOffset)
|
||||
->and((int)$pumpOffset)->toBeLessThan((int)$flushOffset);
|
||||
});
|
||||
|
||||
it('bounds stale outbox replay so it cannot monopolize the gateway loop', function (): void {
|
||||
$agentSource = (string)file_get_contents(app_path('resources/edge-gateway-agent/agent.php'));
|
||||
|
||||
expect($agentSource)->toContain('private const OUTBOX_REPLAY_BATCH_LIMIT = 3;')
|
||||
->and($agentSource)->toContain('private const OUTBOX_REPLAY_TIMEOUT_SECONDS = 3;')
|
||||
->and($agentSource)->toContain('private const OUTBOX_OPERATION_COMPLETE_REPLAY_TIMEOUT_SECONDS = 10;')
|
||||
->and($agentSource)->toContain('private const OUTBOX_REPLAY_FAILURE_COOLDOWN_SECONDS = 15;')
|
||||
->and($agentSource)->toContain('private int $lastOutboxFailureAt = 0;')
|
||||
->and($agentSource)->toContain('$this->stateStore->queuedItems(self::OUTBOX_REPLAY_BATCH_LIMIT)')
|
||||
->and($agentSource)->toContain('private function shouldSkipOutboxReplay(): bool')
|
||||
->and($agentSource)->toContain('$this->lastOutboxFailureAt = time();')
|
||||
->and($agentSource)->toContain('? self::OUTBOX_OPERATION_COMPLETE_REPLAY_TIMEOUT_SECONDS')
|
||||
->and($agentSource)->toContain(': self::OUTBOX_REPLAY_TIMEOUT_SECONDS;');
|
||||
});
|
||||
|
||||
it('uses a short control-plane timeout for self-serve machine signals before queueing', function (): void {
|
||||
$agentSource = (string)file_get_contents(app_path('resources/edge-gateway-agent/agent.php'));
|
||||
|
||||
expect($agentSource)->toContain('private const MACHINE_SIGNAL_TIMEOUT_SECONDS = 3;')
|
||||
->and($agentSource)->toContain('private function sendControlPlaneEvent(string $endpoint, array $payload, string $type, int $timeoutSeconds = 20): bool')
|
||||
->and($agentSource)->toContain("'machine_signal',\n self::MACHINE_SIGNAL_TIMEOUT_SECONDS");
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
it('wires self-serve machine signals through the broker control plane', function (): void {
|
||||
$routeSource = (string)file_get_contents(app_path('routes/edgeGatewaysRoute.php'));
|
||||
$agentSource = (string)file_get_contents(app_path('resources/edge-gateway-agent/agent.php'));
|
||||
$machineSignalSource = (string)file_get_contents(app_path('modules/selfserve/classes/selfserve_machine_signal.php'));
|
||||
|
||||
expect($routeSource)->toContain("'/edge-agent/internal/gateways/{id}/selfserve/machine-signal'")
|
||||
->and($routeSource)->toContain('private function handleBrokerSelfserveMachineSignal(): void')
|
||||
->and($routeSource)->toContain('recordBrokerEdgeGatewaySignal($gatewayId, $payload)')
|
||||
->and($agentSource)->toContain("'type' => 'MACHINE_SIGNAL'")
|
||||
->and($agentSource)->toContain('#/edge-agent/gateways/\d+/selfserve/machine-signal$#')
|
||||
->and($machineSignalSource)->toContain('public function recordBrokerEdgeGatewaySignal(int $gatewayId, array $payload): array')
|
||||
->and($machineSignalSource)->toContain('private function recordEdgeGatewaySignalForDepartment(int $gatewayId, int $departmentId, array $payload): array');
|
||||
});
|
||||
Reference in New Issue
Block a user