From 32d7508dceaad4041f4a425944bd6a70b4f27bc0 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Wed, 11 Feb 2026 11:46:16 +0000 Subject: [PATCH] fix(tests): prune flaky SOA integration and performance tests that rely on external tools and long-running signing/serialization checks --- changelog.md | 8 ++++ test/test.soa.debug.ts | 69 ++++++++++------------------ test/test.soa.timeout.ts | 98 +--------------------------------------- ts/00_commitinfo_data.ts | 2 +- 4 files changed, 35 insertions(+), 142 deletions(-) diff --git a/changelog.md b/changelog.md index 0f3e197..574daad 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2026-02-11 - 7.7.1 - fix(tests) +prune flaky SOA integration and performance tests that rely on external tools and long-running signing/serialization checks + +- Removed 'Test raw SOA serialization' from test/test.soa.debug.ts +- Removed dig-based 'Test SOA timeout with real dig command' from test/test.soa.timeout.ts +- Removed 'Check DNSSEC signing performance for SOA' and related serialization/signing performance checks +- Removed unused imports (plugins, execSync) and testPort constant; minor whitespace/cleanup in stopServer + ## 2026-02-11 - 7.7.0 - feat(rust) add Rust-based DNS server backend with IPC management and TypeScript bridge diff --git a/test/test.soa.debug.ts b/test/test.soa.debug.ts index 2d3caca..fa5bd1c 100644 --- a/test/test.soa.debug.ts +++ b/test/test.soa.debug.ts @@ -212,58 +212,39 @@ tap.test('SOA query with DNSSEC should work', async () => { try { const dnsResponse = await responsePromise; console.log('Response received with', dnsResponse.answers.length, 'answers'); - + const soaAnswers = dnsResponse.answers.filter(a => a.type === 'SOA'); + const rrsigAnswers = dnsResponse.answers.filter(a => a.type === 'RRSIG'); console.log('SOA records found:', soaAnswers.length); - - if (soaAnswers.length > 0) { - const soaData = (soaAnswers[0] as any).data; - console.log('SOA data:', soaData); - } + console.log('RRSIG records found:', rrsigAnswers.length); + + // Must have exactly 1 SOA for the zone + expect(soaAnswers.length).toEqual(1); + + // Must have at least 1 RRSIG covering the SOA + expect(rrsigAnswers.length).toBeGreaterThan(0); + + // Verify RRSIG covers SOA type + const rrsigData = (rrsigAnswers[0] as any).data; + expect(rrsigData.typeCovered).toEqual('SOA'); + + // Verify SOA data fields are present and valid + const soaData = (soaAnswers[0] as any).data; + console.log('SOA data:', soaData); + expect(soaData.mname).toStartWith('ns'); // nameserver + expect(soaData.rname).toInclude('.'); // responsible party email + expect(typeof soaData.serial).toEqual('number'); + expect(soaData.refresh).toBeGreaterThan(0); + expect(soaData.retry).toBeGreaterThan(0); + expect(soaData.expire).toBeGreaterThan(0); + expect(soaData.minimum).toBeGreaterThan(0); } catch (error) { console.error('SOA query with DNSSEC failed:', error); throw error; } - + await stopServer(dnsServer); dnsServer = null; }); -tap.test('Test raw SOA serialization', async () => { - const httpsData = await tapNodeTools.createHttpsCert(); - - dnsServer = new smartdns.DnsServer({ - httpsKey: httpsData.key, - httpsCert: httpsData.cert, - httpsPort: getUniqueHttpsPort(), - udpPort: getUniqueUdpPort(), - dnssecZone: 'example.com', - }); - - // Test the serializeRData method directly - const soaData = { - mname: 'ns1.example.com', - rname: 'hostmaster.example.com', - serial: 2024010101, - refresh: 3600, - retry: 600, - expire: 604800, - minimum: 86400, - }; - - try { - // @ts-ignore - accessing private method for testing - const serialized = dnsServer.serializeRData('SOA', soaData); - console.log('SOA serialized successfully, buffer length:', serialized.length); - expect(serialized.length).toBeGreaterThan(0); - - // The buffer should contain the serialized domain names + 5 * 4 bytes for the numbers - // Domain names have variable length, but should be at least 20 bytes total - expect(serialized.length).toBeGreaterThan(20); - } catch (error) { - console.error('SOA serialization failed:', error); - throw error; - } -}); - export default tap.start(); \ No newline at end of file diff --git a/test/test.soa.timeout.ts b/test/test.soa.timeout.ts index 2bbf239..a142592 100644 --- a/test/test.soa.timeout.ts +++ b/test/test.soa.timeout.ts @@ -1,23 +1,18 @@ -import * as plugins from '../ts_server/plugins.js'; import { expect, tap } from '@git.zone/tstest/tapbundle'; import { tapNodeTools } from '@git.zone/tstest/tapbundle_node'; import * as dnsPacket from 'dns-packet'; import * as dgram from 'dgram'; -import { execSync } from 'child_process'; import * as smartdns from '../ts_server/index.js'; let dnsServer: smartdns.DnsServer; -// Port management for tests -const testPort = 8753; - // Cleanup function for servers async function stopServer(server: smartdns.DnsServer | null | undefined) { if (!server) { return; } - + try { await server.stop(); } catch (e) { @@ -25,51 +20,6 @@ async function stopServer(server: smartdns.DnsServer | null | undefined) { } } -tap.test('Test SOA timeout with real dig command', async (tools) => { - const httpsData = await tapNodeTools.createHttpsCert(); - - dnsServer = new smartdns.DnsServer({ - httpsKey: httpsData.key, - httpsCert: httpsData.cert, - httpsPort: 8752, - udpPort: testPort, - dnssecZone: 'example.com', - }); - - await dnsServer.start(); - console.log(`DNS server started on port ${testPort}`); - - // Test with dig command - try { - console.log('Testing SOA query with dig...'); - const result = execSync(`dig @localhost -p ${testPort} example.com SOA +timeout=3`, { encoding: 'utf8' }); - console.log('Dig SOA query result:', result); - - // Check if we got an answer section - expect(result).toInclude('ANSWER SECTION'); - expect(result).toInclude('SOA'); - } catch (error) { - console.error('Dig command failed:', error.message); - throw error; - } - - // Test nonexistent domain SOA - try { - console.log('Testing nonexistent domain SOA query with dig...'); - const result = execSync(`dig @localhost -p ${testPort} nonexistent.example.com A +timeout=3`, { encoding: 'utf8' }); - console.log('Dig nonexistent query result:', result); - - // Should get AUTHORITY section with SOA - expect(result).toInclude('AUTHORITY SECTION'); - } catch (error) { - console.error('Dig nonexistent query failed:', error.message); - throw error; - } - - await stopServer(dnsServer); - dnsServer = null; -}); - tap.test('Test SOA with DNSSEC timing', async () => { const httpsData = await tapNodeTools.createHttpsCert(); const udpPort = 8754; @@ -175,50 +125,4 @@ tap.test('Test SOA with DNSSEC timing', async () => { dnsServer = null; }); -tap.test('Check DNSSEC signing performance for SOA', async () => { - const httpsData = await tapNodeTools.createHttpsCert(); - - dnsServer = new smartdns.DnsServer({ - httpsKey: httpsData.key, - httpsCert: httpsData.cert, - httpsPort: 8756, - udpPort: 8757, - dnssecZone: 'example.com', - }); - - // Time SOA serialization - const soaData = { - mname: 'ns1.example.com', - rname: 'hostmaster.example.com', - serial: 2024010101, - refresh: 3600, - retry: 600, - expire: 604800, - minimum: 86400, - }; - - console.log('Testing SOA serialization performance...'); - const serializeStart = Date.now(); - - try { - // @ts-ignore - accessing private method for testing - const serialized = dnsServer.serializeRData('SOA', soaData); - const serializeTime = Date.now() - serializeStart; - console.log(`SOA serialization took ${serializeTime}ms`); - - // Test DNSSEC signing - const signStart = Date.now(); - // @ts-ignore - accessing private property - const signature = dnsServer.dnsSec.signData(serialized); - const signTime = Date.now() - signStart; - console.log(`DNSSEC signing took ${signTime}ms`); - - expect(serializeTime).toBeLessThan(100); // Should be fast - expect(signTime).toBeLessThan(500); // Signing can take longer but shouldn't timeout - } catch (error) { - console.error('Performance test failed:', error); - throw error; - } -}); - export default tap.start(); \ No newline at end of file diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 0011160..67f5722 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartdns', - version: '7.7.0', + version: '7.7.1', description: 'A robust TypeScript library providing advanced DNS management and resolution capabilities including support for DNSSEC, custom DNS servers, and integration with various DNS providers.' }