test: harden database qualification startup and cleanup evidence
MariaDB persistence qualification / mariadb (push) Failing after 7s
MariaDB persistence qualification / mariadb (push) Failing after 7s
This commit is contained in:
@@ -5,6 +5,11 @@ import { setTimeout as sleep } from 'node:timers/promises';
|
||||
export const durationMs = 15 * 60 * 1000;
|
||||
export const paceMs = 500;
|
||||
|
||||
export function persistedCareerProfile(profile) {
|
||||
// StructuredCvProfileJson.SerializePersisted omits null properties; CV overrides are a separate contract.
|
||||
return JSON.parse(JSON.stringify(profile, (_key, value) => value === null ? undefined : value));
|
||||
}
|
||||
|
||||
export function summarize(rows) {
|
||||
const values = rows.filter(row => !row.error && row.status === 200).map(row => row.ms).sort((a, b) => a - b);
|
||||
const percentile = p => values.length ? values[Math.ceil(values.length * p) - 1] : null;
|
||||
@@ -25,6 +30,10 @@ export function assertMembership(actual, expected) {
|
||||
if (process.argv.includes('--self-test')) {
|
||||
assert.equal(durationMs, 900000);
|
||||
assert.equal(paceMs, 500);
|
||||
const profile = { contact: { fullName: 'Synthetic', phone: null }, metadata: { fields: {}, updatedAtUtc: null }, values: [null, '', 0, false] };
|
||||
assert.deepEqual(persistedCareerProfile(profile), { contact: { fullName: 'Synthetic' }, metadata: { fields: {} }, values: [null, '', 0, false] });
|
||||
assert.equal(profile.contact.phone, null);
|
||||
assert.notDeepEqual(persistedCareerProfile(profile), persistedCareerProfile({ ...profile, contact: { fullName: 'Changed' } }));
|
||||
assert.deepEqual(summarize([]), { attempts: 0, failures: 0, p50Ms: null, p95Ms: null, p99Ms: null, maxMs: null });
|
||||
const rows = Array.from({ length: 100 }, (_, i) => ({ ms: i + 1, status: 200 }));
|
||||
assert.deepEqual(summarize([...rows, { ms: 999, status: 500 }, { ms: 999, error: 'timeout' }]),
|
||||
|
||||
Reference in New Issue
Block a user