You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.5 KiB
PHP
60 lines
2.5 KiB
PHP
<?php
|
|
|
|
// Static contract test: the greenfield Agent initializer must stay isolated
|
|
// from the legacy Python engine setup and must expose an explicit CLI entry.
|
|
$root = dirname(__DIR__);
|
|
$read = static function (string $relative) use ($root): string {
|
|
$contents = file_get_contents($root . '/' . $relative);
|
|
if ($contents === false) {
|
|
throw new RuntimeException('Cannot read ' . $relative);
|
|
}
|
|
return $contents;
|
|
};
|
|
$assert = static function ($condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
$setup = $read('app/Command/CloudAgentSetup.php');
|
|
$xcat = $read('app/Command/XCat.php');
|
|
$schema = $read('sql/cloud_agent_v1.sql');
|
|
|
|
$assert(str_contains($setup, 'final class CloudAgentSetup'),
|
|
'The independent CloudAgentSetup command is missing.');
|
|
$assert(str_contains($setup, "cloud_agent_v1.sql"),
|
|
'CloudAgentSetup does not load the greenfield Agent schema.');
|
|
$assert(str_contains($setup, 'Model::resolveConnection()'),
|
|
'CloudAgentSetup does not use the configured default database connection.');
|
|
$assert(str_contains($setup, "getSchemaBuilder()->hasTable")
|
|
|| str_contains($setup, 'getSchemaBuilder();'),
|
|
'CloudAgentSetup does not guard complete or partial fresh-schema installs.');
|
|
$assert(str_contains($setup, 'assertSchemaMarker')
|
|
&& str_contains($setup, 'SCHEMA_FINGERPRINT'),
|
|
'CloudAgentSetup does not verify the fresh-schema marker.');
|
|
|
|
foreach ([
|
|
'CloudSetup::', 'exportEngineConfig', 'cloud.sql', 'CloudEngineClient',
|
|
'CloudSecrets', 'cloud_instances', 'cloud_jobs', 'engine.hmac',
|
|
] as $legacy) {
|
|
$assert(!str_contains($setup, $legacy),
|
|
'CloudAgentSetup must not depend on legacy setup material: ' . $legacy);
|
|
}
|
|
|
|
foreach ([
|
|
'cloud_agents', 'cloud_agent_client_certificates', 'cloud_agent_operations',
|
|
'cloud_agent_instance_state', 'cloud_agent_artifacts', 'cloud_agent_schema_meta',
|
|
] as $table) {
|
|
$assert(str_contains($setup, "'" . $table . "'")
|
|
&& str_contains($schema, 'CREATE TABLE ' . $table),
|
|
'Agent schema table is not guarded by the independent initializer: ' . $table);
|
|
}
|
|
|
|
$assert(str_contains($xcat, "'cloudAgentInit' => CloudAgentSetup::initialize()"),
|
|
'xcat has no independent cloudAgentInit entry.');
|
|
$assert(str_contains($xcat, 'php xcat cloudInit')
|
|
&& str_contains($xcat, 'php xcat cloudAgentInit'),
|
|
'The legacy cloudInit help entry or the new Agent help entry disappeared.');
|
|
|
|
echo "Independent Go Agent setup contract checks passed.\n";
|