mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-23 12:05:27 +08:00
test(postgres): isolate backend fault injection
This commit is contained in:
@@ -987,6 +987,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
QL3_TEST_POSTGRES_MIGRATION_URL: postgresql://ql3_migration:ql3_migration_test@127.0.0.1:5432/ql3_contract
|
QL3_TEST_POSTGRES_MIGRATION_URL: postgresql://ql3_migration:ql3_migration_test@127.0.0.1:5432/ql3_contract
|
||||||
QL3_TEST_POSTGRES_RUNTIME_URL: postgresql://ql3_runtime:ql3_runtime_test@127.0.0.1:5432/ql3_contract
|
QL3_TEST_POSTGRES_RUNTIME_URL: postgresql://ql3_runtime:ql3_runtime_test@127.0.0.1:5432/ql3_contract
|
||||||
|
QL3_TEST_POSTGRES_FAULT_INJECTION_URL: postgresql://postgres:postgres@127.0.0.1:5432/ql3_contract
|
||||||
QL3_TEST_POSTGRES_WORKER_INGRESS_URL: postgresql://ql3_worker_ingress:ql3_worker_ingress_test@127.0.0.1:5432/ql3_contract
|
QL3_TEST_POSTGRES_WORKER_INGRESS_URL: postgresql://ql3_worker_ingress:ql3_worker_ingress_test@127.0.0.1:5432/ql3_contract
|
||||||
run: node --test packages/ql3-cluster-control/test/postgres.integration.test.cjs
|
run: node --test packages/ql3-cluster-control/test/postgres.integration.test.cjs
|
||||||
- name: Test optional AI invocation and price catalog against isolated roles
|
- name: Test optional AI invocation and price catalog against isolated roles
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ const migrationConnectionString =
|
|||||||
process.env.QL3_TEST_POSTGRES_MIGRATION_URL ??
|
process.env.QL3_TEST_POSTGRES_MIGRATION_URL ??
|
||||||
process.env.QL3_TEST_POSTGRES_URL;
|
process.env.QL3_TEST_POSTGRES_URL;
|
||||||
const runtimeConnectionString = process.env.QL3_TEST_POSTGRES_RUNTIME_URL;
|
const runtimeConnectionString = process.env.QL3_TEST_POSTGRES_RUNTIME_URL;
|
||||||
|
const faultInjectionConnectionString =
|
||||||
|
process.env.QL3_TEST_POSTGRES_FAULT_INJECTION_URL ??
|
||||||
|
migrationConnectionString;
|
||||||
const workerIngressConnectionString =
|
const workerIngressConnectionString =
|
||||||
process.env.QL3_TEST_POSTGRES_WORKER_INGRESS_URL;
|
process.env.QL3_TEST_POSTGRES_WORKER_INGRESS_URL;
|
||||||
const mtlsFixtures = path.join(__dirname, 'fixtures', 'mtls');
|
const mtlsFixtures = path.join(__dirname, 'fixtures', 'mtls');
|
||||||
@@ -1038,7 +1041,12 @@ if (!migrationConnectionString || !runtimeConnectionString) {
|
|||||||
|
|
||||||
test('terminating the active runtime backend withdraws admission without killing liveness', async () => {
|
test('terminating the active runtime backend withdraws admission without killing liveness', async () => {
|
||||||
const openMigration = opener('migration', migrationConnectionString);
|
const openMigration = opener('migration', migrationConnectionString);
|
||||||
|
const openFaultInjector = opener(
|
||||||
|
'migration',
|
||||||
|
faultInjectionConnectionString,
|
||||||
|
);
|
||||||
const migration = await openMigration();
|
const migration = await openMigration();
|
||||||
|
const faultInjector = await openFaultInjector();
|
||||||
let application;
|
let application;
|
||||||
let reactivatedApplication;
|
let reactivatedApplication;
|
||||||
try {
|
try {
|
||||||
@@ -1082,7 +1090,7 @@ if (!migrationConnectionString || !runtimeConnectionString) {
|
|||||||
body: { status: 'ready' },
|
body: { status: 'ready' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const backend = await migration.pool.query(
|
const backend = await faultInjector.pool.query(
|
||||||
`SELECT pid
|
`SELECT pid
|
||||||
FROM pg_stat_activity
|
FROM pg_stat_activity
|
||||||
WHERE application_name = 'ql3-cluster-availability-integration'
|
WHERE application_name = 'ql3-cluster-availability-integration'
|
||||||
@@ -1092,7 +1100,7 @@ if (!migrationConnectionString || !runtimeConnectionString) {
|
|||||||
);
|
);
|
||||||
assert.equal(backend.rowCount, 1);
|
assert.equal(backend.rowCount, 1);
|
||||||
const terminatedBackendPid = backend.rows[0].pid;
|
const terminatedBackendPid = backend.rows[0].pid;
|
||||||
const terminated = await migration.pool.query(
|
const terminated = await faultInjector.pool.query(
|
||||||
'SELECT pg_terminate_backend($1) AS terminated',
|
'SELECT pg_terminate_backend($1) AS terminated',
|
||||||
[terminatedBackendPid],
|
[terminatedBackendPid],
|
||||||
);
|
);
|
||||||
@@ -1119,7 +1127,7 @@ if (!migrationConnectionString || !runtimeConnectionString) {
|
|||||||
await probeRequest(reactivatedApplication.address, '/readyz'),
|
await probeRequest(reactivatedApplication.address, '/readyz'),
|
||||||
{ status: 200, body: { status: 'ready' } },
|
{ status: 200, body: { status: 'ready' } },
|
||||||
);
|
);
|
||||||
const replacementBackend = await migration.pool.query(
|
const replacementBackend = await faultInjector.pool.query(
|
||||||
`SELECT pid
|
`SELECT pid
|
||||||
FROM pg_stat_activity
|
FROM pg_stat_activity
|
||||||
WHERE application_name = 'ql3-cluster-availability-integration'
|
WHERE application_name = 'ql3-cluster-availability-integration'
|
||||||
@@ -1132,6 +1140,7 @@ if (!migrationConnectionString || !runtimeConnectionString) {
|
|||||||
} finally {
|
} finally {
|
||||||
await application?.stop();
|
await application?.stop();
|
||||||
await reactivatedApplication?.stop();
|
await reactivatedApplication?.stop();
|
||||||
|
await faultInjector.close();
|
||||||
await migration.close();
|
await migration.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user