52 lines
4.4 KiB
PHP
52 lines
4.4 KiB
PHP
<?php
|
|
|
|
it('builds the installer around the compose stack artifacts and management polling config', function (): void {
|
|
$managerSource = file_get_contents(app_path('classes/edge_gateway_manager.php'));
|
|
$serviceSource = file_get_contents(app_path('resources/edge-gateway-agent/truckwash-edge-agent.service'));
|
|
$stackServiceSource = file_get_contents(app_path('resources/edge-gateway-agent/truckwash-edge-gateway-stack.service'));
|
|
|
|
expect($managerSource)->not->toBeFalse();
|
|
expect($managerSource)->toContain("'operationPollTimeoutSeconds' => self::COMMAND_POLL_TIMEOUT_SECONDS");
|
|
expect($managerSource)->toContain('fetch_http "Verify install token" "__VERIFY_URL__"');
|
|
expect($managerSource)->toContain('fetch_http "Download PHP edge agent" "__AGENT_URL__" "$INSTALL_DIR/agent.php"');
|
|
expect($managerSource)->toContain('fetch_http "Download LAN worker" "__WORKER_URL__" "$INSTALL_DIR/lan-worker.php"');
|
|
expect($managerSource)->toContain('fetch_http "Download compose stack" "__COMPOSE_URL__" "$INSTALL_DIR/docker-compose.gateway.yml"');
|
|
expect($managerSource)->toContain('fetch_http "Download compose stack service unit" "__STACK_SERVICE_URL__" "$INSTALL_DIR/truckwash-edge-gateway-stack.service"');
|
|
expect($managerSource)->toContain('log_error "Request: GET ${url}"');
|
|
expect($managerSource)->toContain('log_error "Response body preview (first 400 bytes):"');
|
|
expect($managerSource)->toContain('run_step "Installing base packages" apt-get install -y curl ca-certificates docker.io php-cli php-curl php-mbstring php-sqlite3');
|
|
expect($managerSource)->toContain('run_step "Installing Docker Compose runtime" install_compose_runtime');
|
|
expect($managerSource)->toContain('apt-get install -y docker-compose-plugin');
|
|
expect($managerSource)->toContain('apt-get install -y docker-compose');
|
|
expect($managerSource)->toContain('Unable to install Docker Compose using docker-compose-plugin or docker-compose.');
|
|
expect($managerSource)->toContain('Existing claimed gateway detected; reinstall will reuse saved gateway credentials.');
|
|
expect($managerSource)->toContain('run_step "Writing agent config" merge_agent_config "$CONFIG_TEMPLATE_PATH" "$CONFIG_PATH"');
|
|
expect($managerSource)->toContain('systemctl enable truckwash-edge-gateway-stack.service');
|
|
expect($managerSource)->toContain('systemctl restart truckwash-edge-gateway-stack.service');
|
|
expect($managerSource)->toContain('systemctl is-active --quiet truckwash-edge-gateway-stack.service');
|
|
expect($managerSource)->toContain('run_step "Waiting for gateway claim" wait_for_gateway_claim "$CONFIG_PATH" "$HEARTBEAT_MARKER_PATH" "$INSTALL_STARTED_AT" 30');
|
|
expect($managerSource)->toContain('run_step "Waiting for post-reinstall heartbeat" wait_for_post_restart_heartbeat "$HEARTBEAT_MARKER_PATH" "$INSTALL_STARTED_AT" 30');
|
|
expect($managerSource)->toContain('journalctl -u truckwash-edge-gateway-stack.service -n 60 --no-pager || true');
|
|
expect($managerSource)->not->toContain('agent.mjs');
|
|
expect($managerSource)->not->toContain('"brokerUrl"');
|
|
expect($serviceSource)->toContain('ExecStart=/usr/bin/php /opt/truckwash-edge-agent/agent.php --config /opt/truckwash-edge-agent/config.json');
|
|
expect($stackServiceSource)->toContain('ExecStart=/opt/truckwash-edge-agent/gateway-launcher.sh up');
|
|
expect($serviceSource)->not->toContain('node /opt/truckwash-edge-agent/agent.mjs');
|
|
});
|
|
|
|
it('exposes update payload, credential rotation, and operation endpoints without shell transport wiring', function (): void {
|
|
$managerSource = file_get_contents(app_path('classes/edge_gateway_manager.php'));
|
|
$routeSource = file_get_contents(app_path('routes/edgeGatewaysRoute.php'));
|
|
$agentSource = file_get_contents(app_path('resources/edge-gateway-agent/agent.php'));
|
|
|
|
expect($managerSource)->toContain('public function buildUpdateOperationRequest');
|
|
expect($managerSource)->toContain('public function rotateGatewayCredentials');
|
|
expect($routeSource)->toContain("'/edge-gateways/{id}/rotate-credentials'");
|
|
expect($routeSource)->toContain("'/edge-agent/gateways/{id}/operations/next'");
|
|
expect($agentSource)->toContain("/operations/next");
|
|
expect($agentSource)->toContain("/operations/' . \$operationId . '/complete");
|
|
expect($agentSource)->toContain('last-heartbeat-ok.txt');
|
|
expect($routeSource)->not->toContain("'/edge-gateways/{id}/shell-sessions'");
|
|
expect($routeSource)->not->toContain("'/edge-agent/gateways/{id}/shell-actions/poll'");
|
|
});
|