-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathtest-retry-quick.js
More file actions
99 lines (82 loc) · 3.12 KB
/
test-retry-quick.js
File metadata and controls
99 lines (82 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env node
/**
* Quick Test: retry_execution tool
* Tests against n8n v2.1.4 platform
*/
const axios = require('axios');
const config = {
mcpServerUrl: 'http://localhost:3456/mcp',
healthCheckUrl: 'http://localhost:3456/health'
};
let requestId = 1;
async function sendMcpRequest(method, params = {}) {
const response = await axios.post(config.mcpServerUrl, {
jsonrpc: '2.0',
id: requestId++,
method,
params
});
return response.data.result;
}
async function callTool(name, args = {}) {
const result = await sendMcpRequest('tools/call', { name, arguments: args });
if (result.isError) {
const errorMessage = result.content && result.content[0] && result.content[0].text
? result.content[0].text
: 'Unknown error';
throw new Error(errorMessage);
}
return result;
}
async function main() {
console.error('=== Quick Test: retry_execution ===\n');
try {
// Check server health
const health = await axios.get(config.healthCheckUrl);
console.error(`✓ Server health: ${health.data.status}\n`);
// Step 1: List executions to find a failed one
console.error('Looking for failed executions...');
const listResult = await callTool('list_executions', {
status: 'error',
limit: 5
});
const executions = JSON.parse(listResult.content[0].text);
if (!executions.data || executions.data.length === 0) {
console.error('\n⚠️ No failed executions found.');
console.error('To test retry_execution:');
console.error('1. Create a workflow that will fail');
console.error('2. Execute it to generate a failed execution');
console.error('3. Run this test again\n');
process.exit(0);
}
const failedExecution = executions.data[0];
console.error(`✓ Found failed execution: ${failedExecution.id}`);
console.error(` Workflow: ${failedExecution.workflowId}`);
console.error(` Status: ${failedExecution.status}`);
console.error(` Started: ${failedExecution.startedAt}\n`);
// Step 2: Retry the failed execution
console.error('Retrying failed execution...');
const retryResult = await callTool('retry_execution', {
id: failedExecution.id
});
const newExecution = JSON.parse(retryResult.content[0].text);
console.error(`✓ Retry initiated successfully!`);
console.error(` New execution ID: ${newExecution.id}`);
console.error(` Retry of: ${newExecution.retryOf || failedExecution.id}`);
console.error(` Mode: ${newExecution.mode}`);
console.error(` Status: ${newExecution.status || 'running'}\n`);
// Verify it's a different execution
if (newExecution.id === failedExecution.id) {
console.error('⚠️ WARNING: New execution has same ID as original');
} else {
console.error('✓ Verified: New execution has different ID');
}
console.error('\n=== Test Result: ✓ SUCCESS ===');
console.error('retry_execution tool is working correctly!\n');
} catch (error) {
console.error(`\n✗ Test failed: ${error.message}`);
console.error('\nError details:', error.response?.data || error.stack);
process.exit(1);
}
}
main();