test_runs_getTestRunResults
Retrieve detailed test run results from LoadRunner Cloud using the specified run ID. Access performance test data for analysis and integration into engineering workflows.
Instructions
Get test run results from LoadRunner Cloud.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| runId | Yes | The ID of the test run. |
Implementation Reference
- Handler function that executes the tool logic: makes a GET request to LoadRunner Cloud API endpoint `/test-runs/{runId}/results` to retrieve test run results.const executeFunction = async ({ runId }) => { const baseUrl = process.env.LRC_BASE_URL; const tenantId = process.env.LRC_TENANT_ID; const token = await getAuthToken(); try { // Construct the URL with query parameters const url = new URL(`${baseUrl}/test-runs/${runId}/results`); url.searchParams.append('TENANTID', tenantId); // Set up headers for the request const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }; // Perform the fetch request const response = await fetch(url.toString(), { method: 'GET', headers }); // Check if the response was successful if (!response.ok) { const text = await response.text(); try { const errorData = JSON.parse(text); throw new Error(JSON.stringify(errorData)); } catch (jsonErr) { // Not JSON, log the raw text console.error('Non-JSON error response:', text); throw new Error(text); } } // Parse and return the response data const text = await response.text(); try { const data = JSON.parse(text); return data; } catch (jsonErr) { // Not JSON, log the raw text console.error('Non-JSON success response:', text); return { error: 'Received non-JSON response from API', raw: text }; } } catch (error) { console.error('Error retrieving test run results:', error); return { error: 'An error occurred while retrieving test run results.' }; } };
- Tool definition object including schema for parameters (runId: string, required), description, and name 'test_runs_getTestRunResults', referencing the handler.const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'test_runs_getTestRunResults', description: 'Get test run results from LoadRunner Cloud.', parameters: { type: 'object', properties: { runId: { type: 'string', description: 'The ID of the test run.' } }, required: ['runId'] } } } };
- lib/tools.js:7-16 (registration)Generic registration/discovery function that dynamically imports all apiTool objects from files listed in toolPaths, including this tool.export async function discoverTools() { const toolPromises = toolPaths.map(async (file) => { const module = await import(`../tools/${file}`); return { ...module.apiTool, path: file, }; }); return Promise.all(toolPromises); }
- tools/paths.js:1-11 (registration)Lists the relative path to this tool's file for inclusion in dynamic tool discovery.export const toolPaths = [ 'loadrunner-cloud/load-runner-cloud-api/projects-get-projects.js', 'loadrunner-cloud/load-runner-cloud-api/test-runs-get-active-test-runs.js', 'loadrunner-cloud/load-runner-cloud-api/test-runs-get-test-run-transactions.js', 'loadrunner-cloud/load-runner-cloud-api/test-runs-get-test-run-summary.js', 'loadrunner-cloud/load-runner-cloud-api/test-runs-get-http-responses.js', 'loadrunner-cloud/load-runner-cloud-api/test-runs-get-test-run-recent.js', 'loadrunner-cloud/load-runner-cloud-api/projects-get-load-tests.js', 'loadrunner-cloud/load-runner-cloud-api/projects-get-load-test-scripts.js', 'loadrunner-cloud/load-runner-cloud-api/projects-get-load-test-runs.js' ];