mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-07-09 17:19:02 +00:00
test(core): fix MCP idle timeout config stubs (#6120)
This commit is contained in:
parent
6a5ad453c8
commit
dab218fcd5
2 changed files with 15 additions and 13 deletions
|
|
@ -54,6 +54,7 @@ const mockDebugLogger = vi.hoisted(() => ({
|
|||
warn: vi.fn(),
|
||||
}));
|
||||
const ORIGINAL_ENV = process.env;
|
||||
const TEST_MCP_TOOL_IDLE_TIMEOUT_MS = 300000;
|
||||
|
||||
vi.mock('node:fs', () => ({
|
||||
existsSync: mockExistsSync,
|
||||
|
|
@ -76,6 +77,7 @@ vi.mock('../utils/debugLogger.js', () => ({
|
|||
*/
|
||||
function cfgWithResources(): Config {
|
||||
return {
|
||||
getMcpToolIdleTimeoutMs: () => TEST_MCP_TOOL_IDLE_TIMEOUT_MS,
|
||||
getResourceRegistry: () => ({
|
||||
registerResource: vi.fn(),
|
||||
removeResourcesByServer: vi.fn(),
|
||||
|
|
@ -1277,6 +1279,7 @@ describe('mcp-client', () => {
|
|||
const registerResource = vi.fn();
|
||||
const removeResourcesByServer = vi.fn();
|
||||
const cfg = {
|
||||
getMcpToolIdleTimeoutMs: () => TEST_MCP_TOOL_IDLE_TIMEOUT_MS,
|
||||
getResourceRegistry: () => ({
|
||||
registerResource,
|
||||
removeResourcesByServer,
|
||||
|
|
@ -1330,6 +1333,7 @@ describe('mcp-client', () => {
|
|||
const registerResource = vi.fn();
|
||||
const removeResourcesByServer = vi.fn();
|
||||
const cfg = {
|
||||
getMcpToolIdleTimeoutMs: () => TEST_MCP_TOOL_IDLE_TIMEOUT_MS,
|
||||
getResourceRegistry: () => ({
|
||||
registerResource,
|
||||
removeResourcesByServer,
|
||||
|
|
|
|||
|
|
@ -149,7 +149,9 @@ function mockMcpSuccess(
|
|||
}
|
||||
|
||||
describe('McpTransportPool', () => {
|
||||
const cliConfig = {} as Config;
|
||||
const cliConfig = {
|
||||
getMcpToolIdleTimeoutMs: () => 300000,
|
||||
} as Config;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
|
|
@ -471,9 +473,8 @@ describe('McpTransportPool', () => {
|
|||
// synchronously when localStatus flips to DISCONNECTED on an
|
||||
// active entry (gated by !restartInProgress so intentional
|
||||
// restart-mid-disconnect doesn't trip it).
|
||||
const { updateMCPServerStatus, MCPServerStatus } = await import(
|
||||
'./mcp-client.js'
|
||||
);
|
||||
const { updateMCPServerStatus, MCPServerStatus } =
|
||||
await import('./mcp-client.js');
|
||||
mockMcpSuccess({ toolNames: ['t1'] });
|
||||
const pool = new McpTransportPool(cliConfig, mkPoolOptions());
|
||||
const cfg = new MCPServerConfig('node');
|
||||
|
|
@ -545,9 +546,8 @@ describe('McpTransportPool', () => {
|
|||
// snapshot — same zombie-attach failure, shifted into drain.
|
||||
// Post-W131 the gate extends to ('active' || 'draining') and
|
||||
// cancels the drain timer in the same step.
|
||||
const { updateMCPServerStatus, MCPServerStatus } = await import(
|
||||
'./mcp-client.js'
|
||||
);
|
||||
const { updateMCPServerStatus, MCPServerStatus } =
|
||||
await import('./mcp-client.js');
|
||||
mockMcpSuccess({ toolNames: ['t1'] });
|
||||
const pool = new McpTransportPool(
|
||||
cliConfig,
|
||||
|
|
@ -895,9 +895,8 @@ describe('McpTransportPool', () => {
|
|||
// `getLastTransportError()` returns undefined → caller falls back
|
||||
// to the synthetic-only string. This test pins the behavior
|
||||
// existing W120/W131 tests relied on pre-fix.
|
||||
const { updateMCPServerStatus, MCPServerStatus } = await import(
|
||||
'./mcp-client.js'
|
||||
);
|
||||
const { updateMCPServerStatus, MCPServerStatus } =
|
||||
await import('./mcp-client.js');
|
||||
mockMcpSuccess({ toolNames: ['t1'] });
|
||||
const pool = new McpTransportPool(cliConfig, mkPoolOptions());
|
||||
const cfg = new MCPServerConfig('node');
|
||||
|
|
@ -1014,9 +1013,8 @@ describe('McpTransportPool', () => {
|
|||
// silent-drop chain compares descendantsSignaled vs
|
||||
// descendantsFound and emits the same outer warn even though
|
||||
// sweepAndDisconnect itself didn't throw.
|
||||
const { listDescendantPids, sigtermPids } = await import(
|
||||
'./pid-descendants.js'
|
||||
);
|
||||
const { listDescendantPids, sigtermPids } =
|
||||
await import('./pid-descendants.js');
|
||||
const { createDebugLogger } = await import('../utils/debugLogger.js');
|
||||
const debugMock = createDebugLogger('McpPool:Entry');
|
||||
// The stub is a singleton across tests; clear prior call history
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue