refactor: unify public network mutation admission
parent
718bfaef31
commit
d9e3fe7552
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cloud;
|
||||
|
||||
use App\Models\CloudBackupRecovery;
|
||||
use App\Models\CloudInstance;
|
||||
use App\Models\CloudInstanceMigration;
|
||||
use App\Models\CloudPublicNetworkTransition;
|
||||
use Illuminate\Database\Capsule\Manager as DB;
|
||||
|
||||
/**
|
||||
* Read-only admission for starting a new canonical public-network mutation.
|
||||
*
|
||||
* This module deliberately does not inspect address inventory and does not
|
||||
* own transaction or row-lock policy. Callers that write must lock the
|
||||
* instance first, assert this decision, and retain their locked transition
|
||||
* recheck before freezing resources.
|
||||
*/
|
||||
final class CloudPublicNetworkMutationAdmission
|
||||
{
|
||||
public static function inspect(
|
||||
CloudInstance $instance
|
||||
): CloudPublicNetworkMutationDecision {
|
||||
return self::inspectMany([$instance])[(int) $instance->id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Inspect an arbitrary number of instances with a fixed four-query
|
||||
* catalog projection. Results are keyed by instance id.
|
||||
*
|
||||
* @param iterable<CloudInstance> $instances
|
||||
* @return array<int,CloudPublicNetworkMutationDecision>
|
||||
*/
|
||||
public static function inspectMany(iterable $instances): array
|
||||
{
|
||||
$byId = [];
|
||||
foreach ($instances as $instance) {
|
||||
if (!$instance instanceof CloudInstance) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Public-network mutation admission requires instances'
|
||||
);
|
||||
}
|
||||
$byId[(int) ($instance->id ?? 0)] = $instance;
|
||||
}
|
||||
ksort($byId, SORT_NUMERIC);
|
||||
|
||||
$decisions = [];
|
||||
$candidateIds = [];
|
||||
foreach ($byId as $instanceId => $instance) {
|
||||
if ($instanceId < 1
|
||||
|| (string) ($instance->status ?? '') !== 'active') {
|
||||
$decisions[$instanceId] = self::deny(
|
||||
CloudPublicNetworkMutationDecision::INSTANCE_INACTIVE,
|
||||
'只有处于活动状态的实例可以更换公网地址。'
|
||||
);
|
||||
} elseif (!$instance->serviceAvailable()) {
|
||||
$decisions[$instanceId] = self::deny(
|
||||
CloudPublicNetworkMutationDecision::SERVICE_UNAVAILABLE,
|
||||
'实例服务不可用,暂不能更换公网地址。'
|
||||
);
|
||||
} else {
|
||||
$candidateIds[] = $instanceId;
|
||||
}
|
||||
}
|
||||
if ($candidateIds === []) {
|
||||
return $decisions;
|
||||
}
|
||||
|
||||
try {
|
||||
$migrations = CloudInstanceMigration::whereIn(
|
||||
'instance_id', $candidateIds
|
||||
)->whereIn(
|
||||
'state',
|
||||
CloudInstanceMigrationWorkflow::blockingStates()
|
||||
)->pluck('instance_id')->mapWithKeys(
|
||||
static fn ($id): array => [(int) $id => true]
|
||||
)->all();
|
||||
$recoveries = CloudBackupRecovery::whereIn(
|
||||
'instance_id', $candidateIds
|
||||
)->whereIn('state', ['recovering', 'uncertain'])
|
||||
->pluck('instance_id')->mapWithKeys(
|
||||
static fn ($id): array => [(int) $id => true]
|
||||
)->all();
|
||||
|
||||
$latestJobIds = CloudJobService::blockingQueryForInstances(
|
||||
$candidateIds
|
||||
)->selectRaw('MAX(id) AS id')->groupBy('instance_id')->toBase();
|
||||
$jobRows = DB::table('cloud_jobs as admission_job')->joinSub(
|
||||
$latestJobIds,
|
||||
'latest_public_network_blocking_job',
|
||||
'latest_public_network_blocking_job.id',
|
||||
'=',
|
||||
'admission_job.id'
|
||||
)->get([
|
||||
'admission_job.id',
|
||||
'admission_job.instance_id',
|
||||
'admission_job.kind',
|
||||
'admission_job.status',
|
||||
'admission_job.updated_at',
|
||||
]);
|
||||
$jobs = [];
|
||||
foreach ($jobRows as $job) {
|
||||
$jobs[(int) $job->instance_id] = $job;
|
||||
}
|
||||
|
||||
$transitions = CloudPublicNetworkTransition::whereIn(
|
||||
'instance_id', $candidateIds
|
||||
)->where('active_transition', 1)->pluck('instance_id')
|
||||
->mapWithKeys(
|
||||
static fn ($id): array => [(int) $id => true]
|
||||
)->all();
|
||||
} catch (\Throwable) {
|
||||
foreach ($candidateIds as $instanceId) {
|
||||
$decisions[$instanceId] = self::catalogUnavailable();
|
||||
}
|
||||
ksort($decisions, SORT_NUMERIC);
|
||||
return $decisions;
|
||||
}
|
||||
|
||||
foreach ($candidateIds as $instanceId) {
|
||||
$job = $jobs[$instanceId] ?? null;
|
||||
$decisions[$instanceId] = match (true) {
|
||||
isset($migrations[$instanceId]) => self::deny(
|
||||
CloudPublicNetworkMutationDecision::MIGRATION_ACTIVE,
|
||||
'实例正在维护迁移,请先等待迁移收敛。'
|
||||
),
|
||||
isset($recoveries[$instanceId]) => self::deny(
|
||||
CloudPublicNetworkMutationDecision::BACKUP_RECOVERY_ACTIVE,
|
||||
'虚拟机正在恢复备份,请等待完成。'
|
||||
),
|
||||
$job !== null => new CloudPublicNetworkMutationDecision(
|
||||
CloudPublicNetworkMutationDecision::JOB_ACTIVE,
|
||||
'实例已有任务,请等待完成。',
|
||||
[
|
||||
'id' => (string) $job->id,
|
||||
'kind' => (string) $job->kind,
|
||||
'status' => (string) $job->status,
|
||||
'updated_at' => max(0, (int) $job->updated_at),
|
||||
]
|
||||
),
|
||||
isset($transitions[$instanceId]) => self::deny(
|
||||
CloudPublicNetworkMutationDecision::TRANSITION_ACTIVE,
|
||||
'虚拟机已有公网网络变更正在处理。'
|
||||
),
|
||||
default => new CloudPublicNetworkMutationDecision(
|
||||
CloudPublicNetworkMutationDecision::READY,
|
||||
''
|
||||
),
|
||||
};
|
||||
}
|
||||
ksort($decisions, SORT_NUMERIC);
|
||||
return $decisions;
|
||||
}
|
||||
|
||||
public static function assertCanBegin(CloudInstance $instance): void
|
||||
{
|
||||
$decision = self::inspect($instance);
|
||||
if (!$decision->allowed()) {
|
||||
throw new CloudError($decision->message, 409);
|
||||
}
|
||||
}
|
||||
|
||||
/** @param iterable<CloudInstance> $instances */
|
||||
public static function assertCanBeginMany(iterable $instances): void
|
||||
{
|
||||
foreach (self::inspectMany($instances) as $decision) {
|
||||
if (!$decision->allowed()) {
|
||||
throw new CloudError($decision->message, 409);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function deny(
|
||||
string $reasonCode,
|
||||
string $message
|
||||
): CloudPublicNetworkMutationDecision {
|
||||
return new CloudPublicNetworkMutationDecision(
|
||||
$reasonCode,
|
||||
$message
|
||||
);
|
||||
}
|
||||
|
||||
private static function catalogUnavailable(): CloudPublicNetworkMutationDecision
|
||||
{
|
||||
return self::deny(
|
||||
CloudPublicNetworkMutationDecision::CATALOG_UNAVAILABLE,
|
||||
'公网网络变更运行态目录不可用,请联系管理员。'
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cloud;
|
||||
|
||||
/** Immutable advisory result for starting one new public-network mutation. */
|
||||
final readonly class CloudPublicNetworkMutationDecision
|
||||
{
|
||||
public const READY = 'ready';
|
||||
public const INSTANCE_INACTIVE = 'instance_inactive';
|
||||
public const SERVICE_UNAVAILABLE = 'service_unavailable';
|
||||
public const MIGRATION_ACTIVE = 'migration_active';
|
||||
public const BACKUP_RECOVERY_ACTIVE = 'backup_recovery_active';
|
||||
public const JOB_ACTIVE = 'job_active';
|
||||
public const TRANSITION_ACTIVE = 'transition_active';
|
||||
public const CATALOG_UNAVAILABLE = 'catalog_unavailable';
|
||||
|
||||
private const CODES = [
|
||||
self::READY,
|
||||
self::INSTANCE_INACTIVE,
|
||||
self::SERVICE_UNAVAILABLE,
|
||||
self::MIGRATION_ACTIVE,
|
||||
self::BACKUP_RECOVERY_ACTIVE,
|
||||
self::JOB_ACTIVE,
|
||||
self::TRANSITION_ACTIVE,
|
||||
self::CATALOG_UNAVAILABLE,
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array{id:string,kind:string,status:string,updated_at:int}|null $activeJob
|
||||
*/
|
||||
public function __construct(
|
||||
public string $reasonCode,
|
||||
public string $message,
|
||||
public ?array $activeJob = null
|
||||
) {
|
||||
if (!in_array($reasonCode, self::CODES, true)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Unsupported public-network mutation admission reason'
|
||||
);
|
||||
}
|
||||
if (($reasonCode === self::READY) !== ($message === '')) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Public-network mutation admission message shape is invalid'
|
||||
);
|
||||
}
|
||||
if (($reasonCode === self::JOB_ACTIVE) !== ($activeJob !== null)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Public-network mutation active-job shape is invalid'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function allowed(): bool
|
||||
{
|
||||
return $this->reasonCode === self::READY;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,298 @@
|
||||
<?php
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
use App\Models\CloudInstance;
|
||||
use App\Services\Cloud\CloudError;
|
||||
use App\Services\Cloud\CloudPublicNetworkMutationAdmission;
|
||||
use App\Services\Cloud\CloudPublicNetworkMutationDecision;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
$assert = static function (bool $condition, string $message): void {
|
||||
if (!$condition) {
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
};
|
||||
|
||||
$capsule = new Capsule();
|
||||
$capsule->addConnection([
|
||||
'driver' => 'sqlite', 'database' => ':memory:',
|
||||
], 'default');
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
||||
$schema = $capsule->schema('default');
|
||||
$assert((new ReflectionClass(
|
||||
CloudPublicNetworkMutationDecision::class
|
||||
))->isReadOnly(), 'Admission decision is not immutable.');
|
||||
|
||||
$schema->create('cloud_instances', static function (Blueprint $table): void {
|
||||
$table->increments('id');
|
||||
$table->string('status');
|
||||
$table->string('service_status');
|
||||
$table->integer('expires_at')->nullable();
|
||||
});
|
||||
$schema->create('cloud_instance_migrations', static function (
|
||||
Blueprint $table
|
||||
): void {
|
||||
$table->increments('id');
|
||||
$table->integer('instance_id');
|
||||
$table->string('state');
|
||||
});
|
||||
$schema->create('cloud_backup_recoveries', static function (
|
||||
Blueprint $table
|
||||
): void {
|
||||
$table->increments('id');
|
||||
$table->integer('instance_id');
|
||||
$table->string('state');
|
||||
});
|
||||
$schema->create('cloud_public_network_transitions', static function (
|
||||
Blueprint $table
|
||||
): void {
|
||||
$table->increments('id');
|
||||
$table->integer('instance_id');
|
||||
$table->integer('active_transition')->nullable();
|
||||
});
|
||||
$schema->create('cloud_jobs', static function (Blueprint $table): void {
|
||||
$table->increments('id');
|
||||
$table->string('operation_id')->nullable();
|
||||
$table->string('request_idempotency_key')->nullable();
|
||||
$table->string('request_fingerprint')->nullable();
|
||||
$table->integer('instance_id')->nullable();
|
||||
$table->integer('parent_job_id')->nullable();
|
||||
$table->integer('host_id')->nullable();
|
||||
$table->string('kind');
|
||||
$table->string('execution_mode')->nullable();
|
||||
$table->string('phase');
|
||||
$table->string('outcome')->nullable();
|
||||
$table->string('status');
|
||||
$table->integer('attempts')->nullable();
|
||||
$table->integer('dispatch_attempts')->nullable();
|
||||
$table->integer('dispatch_deadline_at')->nullable();
|
||||
$table->integer('dispatch_started_at')->nullable();
|
||||
$table->integer('agent_accepted_at')->nullable();
|
||||
$table->integer('dispatched_at')->nullable();
|
||||
$table->integer('receipt_deadline_at')->nullable();
|
||||
$table->integer('terminal_at')->nullable();
|
||||
$table->boolean('effect_may_have_applied')->nullable();
|
||||
$table->boolean('safe_to_resubmit')->nullable();
|
||||
$table->string('effect_resolution')->nullable();
|
||||
$table->integer('effect_resolved_at')->nullable();
|
||||
$table->boolean('finalization_incident')->default(false);
|
||||
$table->string('finalization_error_code')->nullable();
|
||||
$table->string('completion_event_id')->nullable();
|
||||
$table->string('error_code')->nullable();
|
||||
$table->text('result_json')->nullable();
|
||||
$table->integer('updated_at');
|
||||
});
|
||||
|
||||
$now = time();
|
||||
Capsule::table('cloud_instances')->insert([
|
||||
'id' => 1,
|
||||
'status' => 'active',
|
||||
'service_status' => 'active',
|
||||
'expires_at' => $now + 86400,
|
||||
]);
|
||||
$instance = static fn (): CloudInstance => CloudInstance::findOrFail(1);
|
||||
$reason = static fn (): string =>
|
||||
CloudPublicNetworkMutationAdmission::inspect($instance())->reasonCode;
|
||||
|
||||
// Exercise the same catalog reads directly so the fixture fails with the
|
||||
// actual SQL error instead of being reduced to the public fail-closed code.
|
||||
\App\Models\CloudInstanceMigration::where('instance_id', 1)
|
||||
->whereIn(
|
||||
'state',
|
||||
\App\Services\Cloud\CloudInstanceMigrationWorkflow::blockingStates()
|
||||
)->exists();
|
||||
\App\Models\CloudBackupRecovery::where('instance_id', 1)
|
||||
->whereIn('state', ['recovering', 'uncertain'])->exists();
|
||||
\App\Services\Cloud\CloudJobService::blockingQueryForInstance(1)
|
||||
->orderByDesc('id')->first(['id', 'kind', 'status', 'updated_at']);
|
||||
|
||||
$ready = CloudPublicNetworkMutationAdmission::inspect($instance());
|
||||
$assert($ready->allowed()
|
||||
&& $ready->reasonCode === CloudPublicNetworkMutationDecision::READY
|
||||
&& $ready->message === '' && $ready->activeJob === null,
|
||||
'A healthy instance was not admitted: ' . $ready->reasonCode);
|
||||
|
||||
Capsule::table('cloud_instances')->where('id', 1)->update([
|
||||
'status' => 'stopped',
|
||||
]);
|
||||
$assert($reason() === CloudPublicNetworkMutationDecision::INSTANCE_INACTIVE,
|
||||
'Inactive instance reason drifted.');
|
||||
Capsule::table('cloud_instances')->where('id', 1)->update([
|
||||
'status' => 'active', 'expires_at' => $now - 1,
|
||||
]);
|
||||
$assert($reason() === CloudPublicNetworkMutationDecision::SERVICE_UNAVAILABLE,
|
||||
'Unavailable service reason drifted.');
|
||||
Capsule::table('cloud_instances')->where('id', 1)->update([
|
||||
'expires_at' => $now + 86400,
|
||||
]);
|
||||
|
||||
Capsule::table('cloud_instance_migrations')->insert([
|
||||
'id' => 1, 'instance_id' => 1, 'state' => 'preparing_source',
|
||||
]);
|
||||
$assert($reason() === CloudPublicNetworkMutationDecision::MIGRATION_ACTIVE,
|
||||
'Maintenance migration did not fence public-network mutation.');
|
||||
Capsule::table('cloud_instance_migrations')->delete();
|
||||
|
||||
Capsule::table('cloud_backup_recoveries')->insert([
|
||||
'id' => 1, 'instance_id' => 1, 'state' => 'uncertain',
|
||||
]);
|
||||
$assert($reason()
|
||||
=== CloudPublicNetworkMutationDecision::BACKUP_RECOVERY_ACTIVE,
|
||||
'Backup recovery did not fence public-network mutation.');
|
||||
Capsule::table('cloud_backup_recoveries')->delete();
|
||||
|
||||
Capsule::table('cloud_jobs')->insert([
|
||||
'id' => 1,
|
||||
'operation_id' => str_repeat('a', 32),
|
||||
'request_idempotency_key' => 'admission-job-0001',
|
||||
'request_fingerprint' => str_repeat('b', 64),
|
||||
'instance_id' => 1,
|
||||
'parent_job_id' => null,
|
||||
'host_id' => 1,
|
||||
'kind' => 'restart',
|
||||
'execution_mode' => 'agent',
|
||||
'phase' => 'active',
|
||||
'outcome' => null,
|
||||
'status' => 'running',
|
||||
'attempts' => 1,
|
||||
'dispatch_attempts' => 1,
|
||||
'dispatch_deadline_at' => $now + 60,
|
||||
'dispatch_started_at' => $now,
|
||||
'agent_accepted_at' => $now,
|
||||
'dispatched_at' => $now,
|
||||
'receipt_deadline_at' => $now + 60,
|
||||
'terminal_at' => null,
|
||||
'effect_may_have_applied' => null,
|
||||
'safe_to_resubmit' => null,
|
||||
'effect_resolution' => 'not_applicable',
|
||||
'effect_resolved_at' => null,
|
||||
'finalization_incident' => 0,
|
||||
'finalization_error_code' => null,
|
||||
'completion_event_id' => null,
|
||||
'error_code' => null,
|
||||
'result_json' => null,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
$job = CloudPublicNetworkMutationAdmission::inspect($instance());
|
||||
$assert($job->reasonCode === CloudPublicNetworkMutationDecision::JOB_ACTIVE
|
||||
&& ($job->activeJob['id'] ?? null) === '1',
|
||||
'Blocking job did not project its immutable admission reason.');
|
||||
Capsule::table('cloud_jobs')->delete();
|
||||
|
||||
Capsule::table('cloud_public_network_transitions')->insert([
|
||||
'id' => 1, 'instance_id' => 1, 'active_transition' => 1,
|
||||
]);
|
||||
$assert($reason() === CloudPublicNetworkMutationDecision::TRANSITION_ACTIVE,
|
||||
'Active transition did not fence public-network mutation.');
|
||||
Capsule::table('cloud_public_network_transitions')->delete();
|
||||
|
||||
foreach ([2, 3, 4, 5] as $instanceId) {
|
||||
Capsule::table('cloud_instances')->insert([
|
||||
'id' => $instanceId,
|
||||
'status' => 'active',
|
||||
'service_status' => 'active',
|
||||
'expires_at' => $now + 86400,
|
||||
]);
|
||||
}
|
||||
Capsule::table('cloud_instance_migrations')->insert([
|
||||
'id' => 2, 'instance_id' => 2, 'state' => 'preparing_source',
|
||||
]);
|
||||
Capsule::table('cloud_backup_recoveries')->insert([
|
||||
['id' => 2, 'instance_id' => 2, 'state' => 'recovering'],
|
||||
['id' => 3, 'instance_id' => 3, 'state' => 'uncertain'],
|
||||
]);
|
||||
$jobRow = static function (int $id, int $instanceId) use ($now): array {
|
||||
return [
|
||||
'id' => $id,
|
||||
'operation_id' => str_pad(dechex($id), 32, '0', STR_PAD_LEFT),
|
||||
'request_idempotency_key' => 'admission-job-' . str_pad(
|
||||
(string) $id,
|
||||
4,
|
||||
'0',
|
||||
STR_PAD_LEFT
|
||||
),
|
||||
'request_fingerprint' => hash('sha256', 'admission-' . $id),
|
||||
'instance_id' => $instanceId,
|
||||
'parent_job_id' => null,
|
||||
'host_id' => 1,
|
||||
'kind' => 'restart',
|
||||
'execution_mode' => 'agent',
|
||||
'phase' => 'active',
|
||||
'outcome' => null,
|
||||
'status' => 'running',
|
||||
'attempts' => 1,
|
||||
'dispatch_attempts' => 1,
|
||||
'dispatch_deadline_at' => $now + 60,
|
||||
'dispatch_started_at' => $now,
|
||||
'agent_accepted_at' => $now,
|
||||
'dispatched_at' => $now,
|
||||
'receipt_deadline_at' => $now + 60,
|
||||
'terminal_at' => null,
|
||||
'effect_may_have_applied' => null,
|
||||
'safe_to_resubmit' => null,
|
||||
'effect_resolution' => 'not_applicable',
|
||||
'effect_resolved_at' => null,
|
||||
'finalization_incident' => 0,
|
||||
'finalization_error_code' => null,
|
||||
'completion_event_id' => null,
|
||||
'error_code' => null,
|
||||
'result_json' => null,
|
||||
'updated_at' => $now + $id,
|
||||
];
|
||||
};
|
||||
Capsule::table('cloud_jobs')->insert([
|
||||
$jobRow(20, 2),
|
||||
$jobRow(30, 3),
|
||||
$jobRow(40, 4),
|
||||
$jobRow(41, 4),
|
||||
]);
|
||||
Capsule::table('cloud_public_network_transitions')->insert([
|
||||
['id' => 2, 'instance_id' => 2, 'active_transition' => 1],
|
||||
['id' => 3, 'instance_id' => 3, 'active_transition' => 1],
|
||||
['id' => 4, 'instance_id' => 4, 'active_transition' => 1],
|
||||
['id' => 5, 'instance_id' => 5, 'active_transition' => 1],
|
||||
]);
|
||||
$manyInstances = CloudInstance::whereIn('id', [1, 2, 3, 4, 5])
|
||||
->orderBy('id')->get();
|
||||
$connection = Capsule::connection('default');
|
||||
$connection->flushQueryLog();
|
||||
$connection->enableQueryLog();
|
||||
$many = CloudPublicNetworkMutationAdmission::inspectMany($manyInstances);
|
||||
$queries = $connection->getQueryLog();
|
||||
$connection->disableQueryLog();
|
||||
$assert(count($queries) === 4,
|
||||
'Multi-instance admission introduced N+1 catalog queries: '
|
||||
. count($queries));
|
||||
$assert($many[1]->reasonCode === CloudPublicNetworkMutationDecision::READY
|
||||
&& $many[2]->reasonCode
|
||||
=== CloudPublicNetworkMutationDecision::MIGRATION_ACTIVE
|
||||
&& $many[3]->reasonCode
|
||||
=== CloudPublicNetworkMutationDecision::BACKUP_RECOVERY_ACTIVE
|
||||
&& $many[4]->reasonCode === CloudPublicNetworkMutationDecision::JOB_ACTIVE
|
||||
&& ($many[4]->activeJob['id'] ?? null) === '41'
|
||||
&& $many[5]->reasonCode
|
||||
=== CloudPublicNetworkMutationDecision::TRANSITION_ACTIVE,
|
||||
'Multi-instance admission priority or latest-job projection drifted.');
|
||||
Capsule::table('cloud_instance_migrations')->delete();
|
||||
Capsule::table('cloud_backup_recoveries')->delete();
|
||||
Capsule::table('cloud_jobs')->delete();
|
||||
Capsule::table('cloud_public_network_transitions')->delete();
|
||||
|
||||
$schema->drop('cloud_backup_recoveries');
|
||||
$unavailable = CloudPublicNetworkMutationAdmission::inspect($instance());
|
||||
$assert(!$unavailable->allowed()
|
||||
&& $unavailable->reasonCode
|
||||
=== CloudPublicNetworkMutationDecision::CATALOG_UNAVAILABLE,
|
||||
'A missing runtime catalog failed open.');
|
||||
try {
|
||||
CloudPublicNetworkMutationAdmission::assertCanBegin($instance());
|
||||
throw new RuntimeException('Missing catalog was accepted by writer seam.');
|
||||
} catch (CloudError $error) {
|
||||
$assert($error->httpStatus === 409,
|
||||
'Admission writer seam returned the wrong status.');
|
||||
}
|
||||
|
||||
echo "Cloud public-network mutation admission behavior passed.\n";
|
||||
Loading…
Reference in New Issue