fix: close record repair and verification gaps

This commit is contained in:
bryanpedini committed 2026-11-19 15:46:12 +01:00
1 parent 9251c85fd8
commit adff599e08
27 files changed
+787 -153

No files matched your search

+34 -14
View File
@@ -7,8 +7,8 @@ import { importApplyBody } from '../harness/decisions';
import { parseRR, waitForZone } from '../harness/dig';
import { COREDNS_HOST } from '../harness/env';
import { run } from '../harness/proc';
import { address, addAddress, createZone, restartWithSessions, zoneInput } from '../harness/personas';
import { begin, servedZone, threeWay } from '../harness/verify';
import { address, createZone, restartWithSessions, zoneInput } from '../harness/personas';
import { begin, expectBumped, servedZone, storedRow, threeWay, type Rec } from '../harness/verify';
test.use({ group: 'power' });
@@ -69,7 +69,8 @@ test('a power user operates a large installation, with restart and edit conflict
expect(await world.db.delegations()).toHaveLength(48);
const ip = '198.51.100.40';
const file = Array.from({ length: 1200 }, (_, i) => `load-${i} 300 IN A ${ip}`).join('\n') + '\n';
const names = Array.from({ length: 1200 }, (_, i) => `load-${i}`);
const file = names.map((name) => `${name} 300 IN A ${ip}`).join('\n') + '\n';
expect((await first.importPreview(imports, file, 'merge')).json.added).toHaveLength(1200);
const importChange = await begin(world, imports);
expect((await first.importApply()).json).toEqual(importApplyBody(1200, 0, 0));
@@ -78,13 +79,15 @@ test('a power user operates a large installation, with restart and edit conflict
await threeWay(world, first, imports, { ...address('load-0', ip), type: 'A' }, importChange, 'large import');
expect(await world.db.records(imports)).toHaveLength(1202);
const imported = (await world.db.records(imports)).filter((row) => row.name.startsWith('load-'));
expect(imported).toHaveLength(1200);
const queries = imported.map((row) => `${row.name}.${imports} A`).join('\n') + '\n';
const batch = await run('dig', [`@${COREDNS_HOST}`, '-p', String(world.g.dnsPort), '+norecurse', '+nocookie', '+time=3', '+tries=2', '+noall', '+answer', '-f', '-'], { input: queries, timeoutMs: 120_000 });
expect(imported.map((row) => row.name).sort()).toEqual([...names].sort());
const queries = names.map((name) => `${name}.${imports} A`).join('\n') + '\n';
const batch = await run('dig', [`@${COREDNS_HOST}`, '-p', String(world.g.dnsPort), '+norecurse', '+nocookie', '+time=3', '+tries=2', '+noall', '+comments', '+answer', '-f', '-'], { input: queries, timeoutMs: 120_000 });
expect(batch.code, batch.stderr).toBe(0);
const rcodes = Array.from(batch.stdout.matchAll(/->>HEADER<<-\s+opcode:\s*\S+,\s*status:\s*([A-Z]+),/g), (match) => match[1]);
expect(rcodes).toEqual(names.map(() => 'NOERROR'));
const answers = batch.stdout.split('\n').filter((line) => line.trim() && !line.startsWith(';')).map(parseRR);
expect(answers.map((rr) => `${rr.name} ${rr.ttl} ${rr.type} ${rr.data}`).sort()).toEqual(
imported.map((row) => `${row.name}.${imports} 300 A ${ip}`).sort(),
expect(answers.map((rr) => `${rr.name} ${rr.ttl} ${rr.class} ${rr.type} ${rr.data}`).sort()).toEqual(
names.map((name) => `${name}.${imports} 300 IN A ${ip}`).sort(),
);
for (const row of imported) expect(row).toMatchObject({ zone: imports, ttl: 300, record_type: 'A', content: JSON.stringify({ ip }) });
expect((await api.get(`${zp(imports)}/check`)).json.problems).toEqual([]);
@@ -94,22 +97,39 @@ test('a power user imports the supported types in one transaction', async ({ wor
const admin = await world.bootstrapAdmin();
const api = await world.apiAs(admin);
const zone = world.zoneName();
const zonePath = await createZone(api, zone);
await addAddress(api, zonePath, 'www', '192.0.2.5');
await createZone(api, zone);
const ui = await world.uiAs(admin);
const soa = zoneInput(zone);
const replacementNS = 'ns3.example.net.';
const entries = [
['@', 'SOA', `${soa.ns} ${soa.mbox} 0 3600 600 604800 300`],
['@', 'SOA', `${replacementNS} ${soa.mbox} 0 3600 600 604800 300`],
['@', 'NS', 'ns2.example.net.'],
['www', 'A', '192.0.2.5'],
['www', 'AAAA', '2001:db8::50'],
['*.alias', 'CNAME', `www.${zone}`],
['@', 'MX', '0 .'],
['@', 'MX', '17 mail.example.net.'],
['@', 'TXT', '"test"'],
['_tcp._svc', 'SRV', '0 0 0 .'],
['@', 'CAA', '0 issue "ca.example.net"'],
['_tcp._svc', 'SRV', '5 9 8443 svc.example.net.'],
['@', 'CAA', '128 issue "ca.example.net"'],
];
const before = await begin(world, zone);
expect((await ui.importPreview(zone, entries.map(([n, t, v]) => `${n} 300 IN ${t} ${v}\n`).join(''), 'merge')).status).toBe(200);
expect((await ui.importApply()).status).toBe(200);
expect((await world.db.records(zone)).map((row) => row.record_type).sort()).toEqual(['A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'NS', 'SOA', 'SRV', 'TXT']);
const serial = await expectBumped(world, zone, before, 'all-types import');
await storedRow(world, zone, { name: '', type: 'SOA', ttl: 300, data: { ns: replacementNS, MBox: soa.mbox, refresh: 3600, retry: 600, expire: 604800, minttl: 300, serial } });
const imported: Rec[] = [
{ name: '', type: 'NS', ttl: 300, data: { host: 'ns2.example.net.' } },
{ name: 'www', type: 'A', ttl: 300, data: { ip: '192.0.2.5' } },
{ name: 'www', type: 'AAAA', ttl: 300, data: { ip: '2001:db8::50' } },
{ name: '*.alias', type: 'CNAME', ttl: 300, data: { host: `www.${zone}` } },
{ name: '', type: 'MX', ttl: 300, data: { host: 'mail.example.net.', preference: 17 } },
{ name: '', type: 'TXT', ttl: 300, data: { text: 'test' } },
{ name: '_tcp._svc', type: 'SRV', ttl: 300, data: { priority: 5, weight: 9, port: 8443, target: 'svc.example.net.' } },
{ name: '', type: 'CAA', ttl: 300, data: { flag: 128, tag: 'issue', value: 'ca.example.net' } },
];
await ui.openZone(zone);
await waitForZone(world.g, zone, { recorder: world.recorder });
for (const record of imported) await threeWay(world, ui, zone, record, null, 'all-types import');
await servedZone(world, zone);
});