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.
63 lines
2.2 KiB
PHP
63 lines
2.2 KiB
PHP
<?php
|
|
|
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
|
|
|
use App\Controllers\CloudPageController;
|
|
use App\Services\UserCopy\UserCopyCatalog;
|
|
use App\Services\UserCopy\UserCopyManifest;
|
|
use App\Services\UserCopy\UserCopyRuntimeReader;
|
|
use App\Services\UserCopy\UserCopySourceCatalog;
|
|
|
|
$assert = static function ($condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
$invoke = static function (object $target, string $method, array $arguments = []) {
|
|
$reflection = new ReflectionMethod($target, $method);
|
|
return $reflection->invokeArgs($target, $arguments);
|
|
};
|
|
|
|
$expiry = time() - 60;
|
|
$expiredRunning = [
|
|
'id' => '7',
|
|
'api_id' => '7',
|
|
'uuid' => '77777777-7777-4777-8777-777777777777',
|
|
'name' => 'expired-running-vm',
|
|
'state' => 'running',
|
|
'state_fresh' => true,
|
|
'state_sync_status' => 'fresh',
|
|
'service_status' => 'expired_grace',
|
|
'network_status' => 'blocked_expired',
|
|
'service_expires_at' => $expiry,
|
|
'service_paused' => true,
|
|
'region' => 'Tokyo',
|
|
'os_source' => 'cloud_template',
|
|
'os_name' => 'AlmaLinux 10',
|
|
'vcpu' => 2,
|
|
'memory_mib' => 2048,
|
|
'disk_gib' => 40,
|
|
];
|
|
|
|
$controller = new CloudPageController();
|
|
$source = new UserCopySourceCatalog(UserCopyManifest::load());
|
|
$copy = UserCopyCatalog::forPage(
|
|
new UserCopyRuntimeReader(sys_get_temp_dir() . '/virt-copy-missing', $source),
|
|
'zh-CN',
|
|
'cloud.instances'
|
|
);
|
|
$row = $invoke($controller, 'vmListRow', [$expiredRunning, $copy]);
|
|
$detail = $invoke($controller, 'vmDetailView', [$expiredRunning]);
|
|
|
|
$assert($row['state_label'] === '已暂停' && $row['state_class'] === 'other',
|
|
'Expired list first paint still presents the live power state as running.');
|
|
$assert($row['service_expiry_display'] !== '暂未提供'
|
|
&& str_contains($row['service_expiry_display'], date('Y/m/d', $expiry)),
|
|
'Instance list first paint omitted the service expiry date.');
|
|
$assert($detail['state_copy_key'] === 'instance_detail.state.paused'
|
|
&& $detail['state_class'] === 'other'
|
|
&& !array_key_exists('state_label', $detail),
|
|
'Expired detail first paint still presents the live power state as running.');
|
|
|
|
echo "Expired instance SSR presentation checks passed.\n";
|