fix(rustproxy): Use cooperative cancellation for background tasks, prune stale caches and metric entries, and switch tests to dynamic port allocation to avoid port conflicts
This commit is contained in:
@@ -2,15 +2,17 @@ import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import * as net from 'net';
|
||||
import * as tls from 'tls';
|
||||
import { SmartProxy } from '../ts/index.js';
|
||||
import { findFreePorts, assertPortsFree } from './helpers/port-allocator.js';
|
||||
|
||||
let testProxy: SmartProxy;
|
||||
let targetServer: net.Server;
|
||||
|
||||
const ECHO_PORT = 47200;
|
||||
const PROXY_PORT = 47201;
|
||||
let ECHO_PORT: number;
|
||||
let PROXY_PORT: number;
|
||||
|
||||
// Create a simple echo server as target
|
||||
tap.test('setup test environment', async () => {
|
||||
[ECHO_PORT, PROXY_PORT] = await findFreePorts(2);
|
||||
// Create target server that echoes data back
|
||||
targetServer = net.createServer((socket) => {
|
||||
console.log('Target server: client connected');
|
||||
@@ -148,6 +150,8 @@ tap.test('cleanup', async () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
await assertPortsFree([ECHO_PORT, PROXY_PORT]);
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user