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.
46 lines
1.9 KiB
PHTML
46 lines
1.9 KiB
PHTML
|
2 weeks ago
|
<?php
|
||
|
|
|
||
|
|
$root = dirname(__DIR__);
|
||
|
|
$read = static function (string $path) use ($root): string {
|
||
|
|
$value = file_get_contents($root . '/' . $path);
|
||
|
|
if (!is_string($value)) {
|
||
|
|
throw new RuntimeException('Unable to read ' . $path);
|
||
|
|
}
|
||
|
|
return $value;
|
||
|
|
};
|
||
|
|
$assert = static function (bool $condition, string $message): void {
|
||
|
|
if (!$condition) {
|
||
|
|
throw new RuntimeException($message);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$lifecycle = $read('app/Services/Cloud/CloudLifecycleService.php');
|
||
|
|
$worker = $read('app/Services/Cloud/CloudWorkerService.php');
|
||
|
|
$renewal = $read('app/Services/Cloud/CloudRenewalService.php');
|
||
|
|
$upgrade = $read('app/Services/Cloud/CloudPlanUpgradeService.php');
|
||
|
|
|
||
|
|
$assert(str_contains($lifecycle,
|
||
|
|
'CloudInstanceNetworkPolicy::synchronizeLocked(')
|
||
|
|
&& str_contains($lifecycle,
|
||
|
|
'CloudInstanceNetworkPolicy::prepareJobLocked(')
|
||
|
|
&& str_contains($lifecycle, '!$aggregateNetworkPolicy')
|
||
|
|
&& str_contains($lifecycle, '$policyDeferred'),
|
||
|
|
'Lifecycle no longer separates enforced pool policy from legacy quota enforcement.');
|
||
|
|
$assert(str_contains($worker,
|
||
|
|
'CloudInstanceNetworkPolicy::jobStillDesired(')
|
||
|
|
&& substr_count($worker,
|
||
|
|
'CloudInstanceNetworkPolicy::finishJobLocked(') >= 2
|
||
|
|
&& str_contains($worker,
|
||
|
|
'releaseAfterInstanceDeletedLocked($instance)'),
|
||
|
|
'Worker lost pre-dispatch convergence, terminal convergence, or delete cleanup.');
|
||
|
|
$assert(str_contains($renewal, '$aggregateNetworkPolicy')
|
||
|
|
&& str_contains($renewal, '!$aggregateNetworkPolicy')
|
||
|
|
&& str_contains($upgrade, '$aggregateNetworkPolicy')
|
||
|
|
&& str_contains($upgrade, '!$aggregateNetworkPolicy'),
|
||
|
|
'Renewal or upgrade can bypass another active network restriction.');
|
||
|
|
$assert(str_contains($lifecycle, "'_network_policy'")
|
||
|
|
&& str_contains($worker, 'payloadMarker('),
|
||
|
|
'Policy jobs are not bound to an immutable aggregate execution snapshot.');
|
||
|
|
|
||
|
|
echo "Cloud traffic restriction integration contract passed.\n";
|