get_active_test_runs
Retrieve active test runs from LoadRunner Cloud, filtering by status or project IDs. Utilize this tool to monitor and manage ongoing performance tests efficiently.
Instructions
Get active test runs from LoadRunner Cloud.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectIds | No | The project IDs to filter the test runs (empty means all). | |
| status | No | The status of the test runs (RUNNING, INITIALIZING, CHECKING_STATUS, STOPPING, DELAYED). |
Implementation Reference
- The main handler function `executeFunction` that fetches active test runs from the LoadRunner Cloud API using authentication and query parameters.const executeFunction = async ({ status = '', projectIds = '' } = {}) => { 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/active`); url.searchParams.append('TENANTID', tenantId); if (status) url.searchParams.append('status', status); if (projectIds) url.searchParams.append('projectIds', projectIds); // 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 fetching active test runs:', error); return { error: 'An error occurred while fetching active test runs.' }; } };
- The JSON schema definition for the tool, including name, description, and input parameters for status and projectIds.name: 'get_active_test_runs', description: 'Get active test runs from LoadRunner Cloud.', parameters: { type: 'object', properties: { status: { type: 'string', description: 'The status of the test runs (RUNNING, INITIALIZING, CHECKING_STATUS, STOPPING, DELAYED).' }, projectIds: { type: 'string', description: 'The project IDs to filter the test runs (empty means all).' } }, required: [] } }
- lib/tools.js:7-16 (registration)Dynamic tool registration via `discoverTools()` which loads `apiTool` from each path in `toolPaths`, including the get_active_test_runs 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)The `toolPaths` array that includes the path to the get_active_test_runs implementation for dynamic loading.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' ];