Testing with Kubiya CLI¶
This guide explains how to use the Kubiya CLI to test tools built with the Kubiya SDK. The CLI provides capabilities to verify that your tools work as expected before they're used in production environments.
Prerequisites¶
Before you begin, make sure you have:
- Installed the Kubiya CLI
- Set up authentication with your Kubiya environment
- Added at least one source containing tools (see Managing Sources)
- Familiarized yourself with tool management (see Managing Tools)
Testing Individual Tools¶
The primary way to test tools with the Kubiya CLI is through the tool test command:
For example, to test a deployment tool:
Interactive Mode¶
You can also test tools in interactive mode, which will prompt you for each parameter:
Testing from Specific Sources¶
If you have multiple sources with the same tool ID, you can specify the source:
Working with Environment Variables¶
Many tools require environment variables. To use them with the tool test command:
export API_KEY=your-api-key
export AWS_SECRET=your-secret
kubiya tool test tool-requiring-secrets
Validating Tool Definitions¶
Before testing, you can validate tool definitions to ensure they're properly structured:
This checks all tool definitions in the current directory for structural validity and required fields.
Debugging Tool Execution¶
To help debug issues with tool execution, you can use verbose mode:
This will provide more detailed output about the tool's execution, including: - Parameter validation - Docker container setup - Tool execution steps - Error details
Checking Tool Logs¶
After running a tool, you can check its logs:
If you're testing a specific run of a tool:
Docker Container Inspection¶
Since tools run in Docker containers, you can inspect the underlying containers:
To see logs from a specific container:
Best Practices for Testing¶
-
Test in development first: Always test tools in development before deploying to production.
-
Use realistic data: Test with data that closely resembles your production data.
-
Test with correct permissions: Ensure the CLI has the same permissions as would be used in production.
-
Version your tools: Keep tool definitions under version control and test specific versions.
-
Document test cases: Maintain documentation of test cases for each tool.
Troubleshooting¶
Tool Not Found¶
If you encounter a "Tool not found" error:
- Verify the tool ID is correct
- Check if the tool exists with
kubiya tool list - Ensure the source containing the tool is properly synced
Parameter Validation Errors¶
If parameters fail validation:
- Check the parameter types match the tool's expectations
- Verify required parameters are provided
- Ensure enum parameters have valid values
Runtime Errors¶
If a tool fails during execution:
- Check that any required environment variables are set
- Verify external services the tool depends on are accessible
- Look for specific error messages in the tool output
- Use
kubiya container logsto view detailed logs
Next Steps¶
Now that you know how to test tools, learn how to: