import { expect, test } from 'bun:test'; import { fleetNameserverProblems } from './container-manager'; // Recurrence gate for celilo#1290: a nameserver the sim cannot route // blackholes the lookups ansible's Gathering Facts performs, and the failure // used to surface as an unrelated 600s command timeout. This gate fails at // init instead, naming the address. test('accepts the sim-hosted primary with no fallback set', () => { const out = ['dns.primary = 203.0.113.1', 'System config key not found: dns.fallback'].join('\n'); expect(fleetNameserverProblems(out)).toEqual([]); }); test('accepts nameservers in every simulated subnet', () => { const out = ['dns.primary = 203.0.113.1', 'dns.fallback = 100.64.0.64,10.226.10.10'].join('\n'); expect(fleetNameserverProblems(out)).toEqual([]); }); test('rejects the unroutable public resolvers celilo#1290 shipped', () => { const out = ['dns.primary = 203.0.113.1', 'dns.fallback = 1.0.0.1,8.8.8.8'].join('\n'); const problems = fleetNameserverProblems(out); expect(problems).toHaveLength(2); expect(problems[0]).toContain('1.0.0.1'); expect(problems[0]).toContain('no simulated subnet'); expect(problems[1]).toContain('8.8.8.8'); }); test('rejects core discovery last-resort 1.1.1.1', () => { const out = ['dns.primary = 203.0.113.1', 'dns.fallback = 1.1.1.1'].join('\n'); expect(fleetNameserverProblems(out)).toHaveLength(1); }); test('flags a missing primary — the birth list would be empty', () => { const out = 'No system configuration set'; const problems = fleetNameserverProblems(out); expect(problems).toHaveLength(1); expect(problems[0]).toContain('dns.primary is not set'); }); test('flags a non-IP entry instead of silently passing it', () => { const out = 'dns.primary = not-an-ip'; const problems = fleetNameserverProblems(out); expect(problems).toHaveLength(1); expect(problems[0]).toContain('not an IPv4 address'); });