This commit introduces unit tests, E2E tests, and implementation updates related to edge gateway lifecycle management, including update handling, artifact validation, and rollback mechanisms. It also refines routing, component interaction, and backend methods to improve update tracking, status transitions, and artifact management.
23 lines
1.4 KiB
PHP
23 lines
1.4 KiB
PHP
<?php
|
|
|
|
it('builds update command payloads with artifact urls, checksums, and the service name', function (): void {
|
|
$source = file_get_contents(app_path('classes/edge_gateway_manager.php'));
|
|
|
|
expect($source)->not->toBeFalse();
|
|
expect($source)->toContain("'artifactUrl' => \$this->buildAgentArtifactUrl('agent.mjs')");
|
|
expect($source)->toContain("'artifactSha256' => \$this->buildAgentArtifactSha256('agent.mjs')");
|
|
expect($source)->toContain("'packageUrl' => \$this->buildAgentArtifactUrl('package.json')");
|
|
expect($source)->toContain("'packageSha256' => \$this->buildAgentArtifactSha256('package.json')");
|
|
expect($source)->toContain("'serviceName' => self::DEFAULT_AGENT_SERVICE_NAME");
|
|
});
|
|
|
|
it('finalizes active update jobs from heartbeat metadata when the agent reports completion or rollback', function (): void {
|
|
$source = file_get_contents(app_path('classes/edge_gateway_manager.php'));
|
|
|
|
expect($source)->toContain("\$state = strtoupper(trim((string)(\$lastUpdate['state'] ?? '')));");
|
|
expect($source)->toContain("if (!in_array(\$state, ['COMPLETED', 'FAILED', 'ROLLED_BACK'], true)) {");
|
|
expect($source)->toContain("\$updateJob->status->set(\$state);");
|
|
expect($source)->toContain("'heartbeat_installed_version' => \$payload['installed_version'] ?? \$gateway->installed_version->value()");
|
|
expect($source)->toContain("'heartbeat_target_version' => \$payload['target_version'] ?? \$gateway->target_version->value()");
|
|
});
|