-
Notifications
You must be signed in to change notification settings - Fork 69
feat: Add Hercules AI test agent example (do not merge) #861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # Hercules AI Test Agent for PyAirbyte | ||
|
|
||
| This example demonstrates how to use [Hercules](https://github.com/test-zeus-ai/testzeus-hercules), an open-source AI testing agent, to test PyAirbyte functionality. | ||
|
|
||
| ## About Hercules | ||
|
|
||
| Hercules is the world's first open-source testing agent that uses Gherkin format for test scenarios. It can perform UI, API, and other types of testing without requiring manual scripting. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 1. Python 3.11 or higher | ||
| 2. Hercules installed in a separate virtual environment (due to dependency conflicts with PyAirbyte) | ||
| 3. OpenAI API key or other LLM provider credentials | ||
|
|
||
| ## Installation | ||
|
|
||
| Since Hercules has a dependency conflict with PyAirbyte's airbyte-cdk (psutil version), it should be installed in a separate virtual environment: | ||
|
|
||
| ```bash | ||
| # Create a separate virtual environment for Hercules | ||
| python -m venv hercules-env | ||
| source hercules-env/bin/activate # On Windows: hercules-env\Scripts\activate | ||
|
|
||
| # Install Hercules | ||
| pip install testzeus-hercules | ||
|
|
||
| # Install Playwright (required by Hercules) | ||
| playwright install --with-deps | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| 1. Set your LLM API key: | ||
| ```bash | ||
| export OPENAI_API_KEY="your-api-key-here" | ||
| ``` | ||
|
|
||
| 2. Run Hercules with the test feature file: | ||
| ```bash | ||
| testzeus-hercules --input-file test_pyairbyte.feature \ | ||
| --output-path ./output \ | ||
| --test-data-path ./test_data \ | ||
| --llm-model gpt-4o \ | ||
| --llm-model-api-key $OPENAI_API_KEY | ||
| ``` | ||
|
|
||
| ## Test Scenario | ||
|
|
||
| The included `test_pyairbyte.feature` file contains a simple Gherkin scenario that tests basic PyAirbyte functionality: | ||
|
|
||
| - Installing PyAirbyte | ||
| - Creating a source connector | ||
| - Reading data from the source | ||
| - Validating the data | ||
|
|
||
| ## Output | ||
|
|
||
| Hercules will generate: | ||
| - JUnit XML test results in `./output/` | ||
| - HTML test report in `./output/` | ||
| - Execution proofs (screenshots, videos, network logs) in `./proofs/` | ||
| - Detailed logs in `./log_files/` | ||
|
|
||
| ## Limitations | ||
|
|
||
| Due to dependency conflicts (specifically psutil version requirements), Hercules cannot be installed in the same environment as PyAirbyte. This example demonstrates using Hercules in a separate environment to test PyAirbyte functionality. | ||
|
|
||
| ## Alternative Approach | ||
|
|
||
| For integrated testing, consider: | ||
| 1. Using Docker to run Hercules in an isolated container | ||
| 2. Creating a CI/CD pipeline that runs Hercules tests separately | ||
| 3. Using Hercules to test PyAirbyte's CLI or API endpoints rather than importing it directly | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Requirements for running Hercules AI test agent | ||
| # Note: Install these in a separate virtual environment due to dependency conflicts with PyAirbyte | ||
|
|
||
| testzeus-hercules>=0.2.0 | ||
| playwright>=1.40.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| Feature: PyAirbyte Basic Functionality Test | ||
|
|
||
| Scenario: Test PyAirbyte source connector with faker | ||
| Given I have Python installed on my system | ||
| When I install PyAirbyte using "pip install airbyte" | ||
| And I create a Python script with the following code: | ||
| """ | ||
| import airbyte as ab | ||
|
|
||
| # Create a source connector | ||
| source = ab.get_source( | ||
| "source-faker", | ||
| config={"count": 10}, | ||
| install_if_missing=True | ||
| ) | ||
|
|
||
| # Check the connection | ||
| source.check() | ||
|
|
||
| # Read data into a local cache | ||
| cache = ab.new_local_cache() | ||
| result = source.read(cache) | ||
|
|
||
| # Get data from a stream | ||
| df = cache["users"].to_pandas() | ||
|
|
||
| # Validate we got data | ||
| assert len(df) > 0, "No data was read from source" | ||
| assert "id" in df.columns, "Expected 'id' column not found" | ||
|
|
||
| print(f"Successfully read {len(df)} records from source-faker") | ||
| """ | ||
| And I run the Python script | ||
| Then the script should execute successfully | ||
| And I should see output containing "Successfully read" | ||
| And I should see output containing "records from source-faker" | ||
|
|
||
| Scenario: Test PyAirbyte connector discovery | ||
| Given I have PyAirbyte installed | ||
| When I create a Python script to discover available connectors: | ||
| """ | ||
| import airbyte as ab | ||
| from airbyte.registry import get_available_connectors | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify the registry import path. Is 🏁 Script executed: #!/bin/bash
# Search for registry module and get_available_connectors function
ast-grep --pattern $'def get_available_connectors($$$) {
$$$
}'Length of output: 0 Let me try different approaches to verify the registry import: Length of output: 113 🏁 Script executed: #!/bin/bash
# Find files related to registry module
fd -e py '.*registry.*' | head -20Length of output: 185 🏁 Script executed: #!/bin/bash
# Search for imports of get_available_connectors to see how it's used
rg -nP 'from\s+airbyte\.registry\s+import|import.*get_available_connectors' --type=pyLength of output: 923 🏁 Script executed: #!/bin/bash
# Look for airbyte module structure
fd -type d -name 'airbyte' | head -5Length of output: 170 Let me check the actual test file to see the full context: Length of output: 1153 🏁 Script executed: #!/bin/bash
# Search for connector_type parameter usage in the codebase
rg -nP 'connector_type\s*=' --type=py -A2 -B2Length of output: 3502 🏁 Script executed: #!/bin/bash
# Search for how get_available_connectors is called in actual code
rg -nP 'get_available_connectors\(' --type=py -A2 -B1 | head -50Length of output: 3141 The import is correct, but the test script has critical bugs in how it uses the function. The import path
Wdyt on addressing these two issues in the test script? 🤖 Prompt for AI Agents |
||
|
|
||
| # Get list of available source connectors | ||
| sources = get_available_connectors(connector_type="source") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify the get_available_connectors API. Could you verify that 🏁 Script executed: #!/bin/bash
# Find the get_available_connectors function definition
rg -n "def get_available_connectors" --type=py -A 10Length of output: 850 I found the issue! The function definition shows Fix the parameter name in The function signature uses 🤖 Prompt for AI Agents |
||
|
|
||
| # Validate we have connectors | ||
| assert len(sources) > 0, "No source connectors found" | ||
|
|
||
| # Check that source-faker is available | ||
| faker_found = any(c.name == "source-faker" for c in sources) | ||
| assert faker_found, "source-faker not found in available connectors" | ||
|
|
||
| print(f"Found {len(sources)} source connectors") | ||
| print("source-faker is available") | ||
| """ | ||
| And I run the Python script | ||
| Then the script should execute successfully | ||
| And I should see output containing "source connectors" | ||
| And I should see output containing "source-faker is available" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Update to reflect both test scenarios.
The README says "Test Scenario" (singular) but the feature file actually contains TWO scenarios:
Would you mind updating this section to mention both scenarios? Something like:
WDYT?
🤖 Prompt for AI Agents