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,14 +2,16 @@ import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as plugins from '../ts/plugins.js';
|
||||
import { SmartProxy } from '../ts/index.js';
|
||||
import * as net from 'net';
|
||||
import { findFreePorts, assertPortsFree } from './helpers/port-allocator.js';
|
||||
|
||||
let smartProxyInstance: SmartProxy;
|
||||
let echoServer: net.Server;
|
||||
const echoServerPort = 47300;
|
||||
const proxyPort = 47301;
|
||||
let echoServerPort: number;
|
||||
let proxyPort: number;
|
||||
|
||||
// Create an echo server for testing
|
||||
tap.test('should create echo server for testing', async () => {
|
||||
[echoServerPort, proxyPort] = await findFreePorts(2);
|
||||
echoServer = net.createServer((socket) => {
|
||||
socket.on('data', (data) => {
|
||||
socket.write(data); // Echo back the data
|
||||
@@ -267,6 +269,8 @@ tap.test('should clean up resources', async () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
await assertPortsFree([echoServerPort, proxyPort]);
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
Reference in New Issue
Block a user