mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-23 20:15:19 +08:00
fix(ci): seed durable package trust in recovery gate
This commit is contained in:
@@ -626,6 +626,10 @@ async function runSeed() {
|
|||||||
loadPostgresConnectionEnvironment,
|
loadPostgresConnectionEnvironment,
|
||||||
PostgresPluginPackageSecretBindingTransitionRepository,
|
PostgresPluginPackageSecretBindingTransitionRepository,
|
||||||
} = ql3Require('@qinglong/cluster-postgres/package-executor');
|
} = ql3Require('@qinglong/cluster-postgres/package-executor');
|
||||||
|
const {
|
||||||
|
assertPostgresPackageManagerSchemaReady,
|
||||||
|
PostgresPluginPackagePublisherTrustAuthorityRepository,
|
||||||
|
} = ql3Require('@qinglong/cluster-postgres/package-manager');
|
||||||
const { PostgresPluginPackageInstallRepository } = ql3Require(
|
const { PostgresPluginPackageInstallRepository } = ql3Require(
|
||||||
'@qinglong/cluster-postgres/plugin-package-install',
|
'@qinglong/cluster-postgres/plugin-package-install',
|
||||||
);
|
);
|
||||||
@@ -640,6 +644,9 @@ async function runSeed() {
|
|||||||
const { createPluginPackageSecretBindingTransitionPlan } = ql3Require(
|
const { createPluginPackageSecretBindingTransitionPlan } = ql3Require(
|
||||||
'@qinglong/runtime-core/plugin-package-secret-binding-transition-plan',
|
'@qinglong/runtime-core/plugin-package-secret-binding-transition-plan',
|
||||||
);
|
);
|
||||||
|
const { createPluginPackagePublisherTrustSnapshot } = ql3Require(
|
||||||
|
'@qinglong/runtime-core/plugin-package-publisher-trust',
|
||||||
|
);
|
||||||
const fixture = readFixture(process.env.QL3_E2E_FIXTURE_FILE);
|
const fixture = readFixture(process.env.QL3_E2E_FIXTURE_FILE);
|
||||||
const mode = process.env.QL3_E2E_MODE;
|
const mode = process.env.QL3_E2E_MODE;
|
||||||
if (!['seed-initial', 'seed-upgrade', 'commit-transition'].includes(mode)) {
|
if (!['seed-initial', 'seed-upgrade', 'commit-transition'].includes(mode)) {
|
||||||
@@ -701,6 +708,56 @@ async function runSeed() {
|
|||||||
}
|
}
|
||||||
const selected =
|
const selected =
|
||||||
mode === 'seed-initial' ? fixture.initial : fixture.upgrade;
|
mode === 'seed-initial' ? fixture.initial : fixture.upgrade;
|
||||||
|
let publisherTrustStatus = null;
|
||||||
|
if (mode === 'seed-initial') {
|
||||||
|
const packageManagerConnection = loadPostgresConnectionEnvironment(
|
||||||
|
process.env,
|
||||||
|
{
|
||||||
|
host: 'QL3_E2E_POSTGRES_HOST',
|
||||||
|
port: 'QL3_E2E_POSTGRES_PORT',
|
||||||
|
database: 'QL3_E2E_POSTGRES_DATABASE',
|
||||||
|
user: 'QL3_E2E_POSTGRES_PACKAGE_MANAGER_USER',
|
||||||
|
password: 'QL3_E2E_POSTGRES_PACKAGE_MANAGER_PASSWORD',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const packageManagerDatabase = await createPostgresDatabaseOpener({
|
||||||
|
role: 'package-manager',
|
||||||
|
connection: {
|
||||||
|
...packageManagerConnection,
|
||||||
|
tls: { mode: 'disable' },
|
||||||
|
},
|
||||||
|
pool: {
|
||||||
|
applicationName: 'qinglong3-plugin-package-e2e-trust-seed',
|
||||||
|
maxConnections: 1,
|
||||||
|
connectionTimeoutMs: 15_000,
|
||||||
|
},
|
||||||
|
onPoolError() {},
|
||||||
|
})();
|
||||||
|
try {
|
||||||
|
await assertPostgresPackageManagerSchemaReady(
|
||||||
|
packageManagerDatabase.pool,
|
||||||
|
);
|
||||||
|
const observed =
|
||||||
|
await new PostgresPluginPackagePublisherTrustAuthorityRepository(
|
||||||
|
packageManagerDatabase.pool,
|
||||||
|
).observeSnapshot({
|
||||||
|
authorityId: 'cluster',
|
||||||
|
snapshot: createPluginPackagePublisherTrustSnapshot(
|
||||||
|
fixture.trust.keys,
|
||||||
|
),
|
||||||
|
observedBy: 'plugin-recovery-e2e-package-manager',
|
||||||
|
observedAtMs: selected.lock.createdAtMs,
|
||||||
|
});
|
||||||
|
if (!['created', 'existing'].includes(observed.status)) {
|
||||||
|
throw new Error(
|
||||||
|
'Plugin Package E2E publisher trust authority conflicts with the fixture',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
publisherTrustStatus = observed.status;
|
||||||
|
} finally {
|
||||||
|
await packageManagerDatabase.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
const lock = normalizePluginPackageLock(selected.lock);
|
const lock = normalizePluginPackageLock(selected.lock);
|
||||||
const repository = new PostgresPluginPackageInstallRepository(
|
const repository = new PostgresPluginPackageInstallRepository(
|
||||||
database.pool,
|
database.pool,
|
||||||
@@ -732,6 +789,7 @@ async function runSeed() {
|
|||||||
phase: mode === 'seed-initial' ? 'initial' : 'upgrade',
|
phase: mode === 'seed-initial' ? 'initial' : 'upgrade',
|
||||||
status: result.status,
|
status: result.status,
|
||||||
state: result.record.state,
|
state: result.record.state,
|
||||||
|
publisherTrustStatus,
|
||||||
installationId: result.record.installationId,
|
installationId: result.record.installationId,
|
||||||
lockDigest: result.record.lockDigest,
|
lockDigest: result.record.lockDigest,
|
||||||
recordDigest: result.record.recordDigest,
|
recordDigest: result.record.recordDigest,
|
||||||
|
|||||||
@@ -879,6 +879,19 @@ function seedJob(name, mode) {
|
|||||||
{ name: 'QL3_E2E_POSTGRES_HOST', value: POSTGRES_NAME },
|
{ name: 'QL3_E2E_POSTGRES_HOST', value: POSTGRES_NAME },
|
||||||
{ name: 'QL3_E2E_POSTGRES_PORT', value: '5432' },
|
{ name: 'QL3_E2E_POSTGRES_PORT', value: '5432' },
|
||||||
{ name: 'QL3_E2E_POSTGRES_DATABASE', value: 'qinglong' },
|
{ name: 'QL3_E2E_POSTGRES_DATABASE', value: 'qinglong' },
|
||||||
|
{
|
||||||
|
name: 'QL3_E2E_POSTGRES_PACKAGE_MANAGER_USER',
|
||||||
|
value: 'ql3_package_manager',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'QL3_E2E_POSTGRES_PACKAGE_MANAGER_PASSWORD',
|
||||||
|
valueFrom: {
|
||||||
|
secretKeyRef: {
|
||||||
|
name: 'ql3-e2e-postgres-auth',
|
||||||
|
key: 'package-manager-password',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'QL3_E2E_POSTGRES_PACKAGE_EXECUTOR_USER',
|
name: 'QL3_E2E_POSTGRES_PACKAGE_EXECUTOR_USER',
|
||||||
value: 'ql3_package_executor',
|
value: 'ql3_package_executor',
|
||||||
|
|||||||
@@ -69,6 +69,16 @@ test('gate runs migration, healthy activation and a durable rejected upgrade', (
|
|||||||
);
|
);
|
||||||
assert.match(live, /plugin-package-recovery\/base\/recover-job\.yaml/);
|
assert.match(live, /plugin-package-recovery\/base\/recover-job\.yaml/);
|
||||||
assert.match(fixture, /PostgresPluginPackageInstallRepository/);
|
assert.match(fixture, /PostgresPluginPackageInstallRepository/);
|
||||||
|
assert.match(
|
||||||
|
fixture,
|
||||||
|
/PostgresPluginPackagePublisherTrustAuthorityRepository/,
|
||||||
|
);
|
||||||
|
assert.match(fixture, /createPluginPackagePublisherTrustSnapshot/);
|
||||||
|
assert.match(fixture, /role: 'package-manager'/);
|
||||||
|
assert.match(fixture, /authorityId: 'cluster'/);
|
||||||
|
assert.match(fixture, /publisherTrustStatus/);
|
||||||
|
assert.match(live, /QL3_E2E_POSTGRES_PACKAGE_MANAGER_USER/);
|
||||||
|
assert.match(live, /key: 'package-manager-password'/);
|
||||||
assert.match(
|
assert.match(
|
||||||
fixture,
|
fixture,
|
||||||
/PostgresPluginPackageSecretBindingTransitionRepository/,
|
/PostgresPluginPackageSecretBindingTransitionRepository/,
|
||||||
|
|||||||
Reference in New Issue
Block a user