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:
@@ -1,17 +1,19 @@
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as net from 'net';
|
||||
import { SmartProxy } from '../ts/proxies/smart-proxy/smart-proxy.js';
|
||||
import { findFreePorts, assertPortsFree } from './helpers/port-allocator.js';
|
||||
|
||||
let echoServer: net.Server;
|
||||
let proxy: SmartProxy;
|
||||
|
||||
const ECHO_PORT = 47400;
|
||||
const PROXY_PORT_1 = 47401;
|
||||
const PROXY_PORT_2 = 47402;
|
||||
let ECHO_PORT: number;
|
||||
let PROXY_PORT_1: number;
|
||||
let PROXY_PORT_2: number;
|
||||
|
||||
tap.test('port forwarding should not immediately close connections', async (tools) => {
|
||||
// Set a timeout for this test
|
||||
tools.timeout(10000); // 10 seconds
|
||||
[ECHO_PORT, PROXY_PORT_1, PROXY_PORT_2] = await findFreePorts(3);
|
||||
// Create an echo server
|
||||
echoServer = await new Promise<net.Server>((resolve, reject) => {
|
||||
const server = net.createServer((socket) => {
|
||||
@@ -96,6 +98,7 @@ tap.test('cleanup', async () => {
|
||||
});
|
||||
});
|
||||
}
|
||||
await assertPortsFree([ECHO_PORT, PROXY_PORT_1, PROXY_PORT_2]);
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user