This commit is contained in:
2025-05-23 19:49:25 +00:00
parent e0f6e3237b
commit a7438a7cd6
40 changed files with 189 additions and 178 deletions

View File

@ -1,17 +1,18 @@
import { tap, expect } from '@git.zone/tapbundle';
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as net from 'net';
import { startTestServer, stopTestServer, type ITestServer } from '../../helpers/server.loader.js';
import { startTestServer, stopTestServer, type ITestServer } from '../server.loader.js';
const TEST_PORT = 30033;
const TEST_PORT = 2525;
const TEST_TIMEOUT = 60000; // Longer timeout for keepalive tests
tap.test('Keepalive - should maintain TCP keepalive', async (tools) => {
const done = tools.defer();
// Start test server
const testServer = await startTestServer({ port: TEST_PORT });
const testServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
const socket = net.createConnection({
host: 'localhost',
port: TEST_PORT,
@ -71,7 +72,7 @@ tap.test('Keepalive - should maintain TCP keepalive', async (tools) => {
socket.end();
} finally {
await stopTestServer(testServer);
await stopTestServer();
done.resolve();
}
});
@ -80,9 +81,10 @@ tap.test('Keepalive - should maintain idle connection for extended period', asyn
const done = tools.defer();
// Start test server
const testServer = await startTestServer({ port: TEST_PORT });
const testServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
const socket = net.createConnection({
host: 'localhost',
port: TEST_PORT,
@ -142,7 +144,7 @@ tap.test('Keepalive - should maintain idle connection for extended period', asyn
socket.end();
} finally {
await stopTestServer(testServer);
await stopTestServer();
done.resolve();
}
});
@ -151,9 +153,10 @@ tap.test('Keepalive - should detect connection loss', async (tools) => {
const done = tools.defer();
// Start test server
const testServer = await startTestServer({ port: TEST_PORT });
const testServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
const socket = net.createConnection({
host: 'localhost',
port: TEST_PORT,
@ -202,7 +205,7 @@ tap.test('Keepalive - should detect connection loss', async (tools) => {
console.log('Connection established, now simulating server shutdown...');
// Shutdown server to simulate connection loss
await stopTestServer(testServer);
await stopTestServer();
// Wait for keepalive to detect connection loss
await new Promise(resolve => setTimeout(resolve, 10000));
@ -221,9 +224,10 @@ tap.test('Keepalive - should handle long-running SMTP session', async (tools) =>
const done = tools.defer();
// Start test server
const testServer = await startTestServer({ port: TEST_PORT });
const testServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
const socket = net.createConnection({
host: 'localhost',
port: TEST_PORT,
@ -294,7 +298,7 @@ tap.test('Keepalive - should handle long-running SMTP session', async (tools) =>
socket.end();
} finally {
await stopTestServer(testServer);
await stopTestServer();
done.resolve();
}
});
@ -303,9 +307,10 @@ tap.test('Keepalive - should handle NOOP as keepalive mechanism', async (tools)
const done = tools.defer();
// Start test server
const testServer = await startTestServer({ port: TEST_PORT });
const testServer = await startTestServer();
try {
await new Promise(resolve => setTimeout(resolve, 1000));try {
const socket = net.createConnection({
host: 'localhost',
port: TEST_PORT,
@ -362,7 +367,7 @@ tap.test('Keepalive - should handle NOOP as keepalive mechanism', async (tools)
socket.end();
} finally {
await stopTestServer(testServer);
await stopTestServer();
done.resolve();
}
});