|
| 1 | +# Azure AI Agents Smoke Test for Python |
| 2 | + |
| 3 | +This directory contains the **live-service and recorded tests** for the Azure AI Agents client library. |
| 4 | + |
| 5 | +## Getting started |
| 6 | + |
| 7 | +These instructions assume you are working on Windows, have |
| 8 | +Python 3.9 or later, and want to run the tests against **live service |
| 9 | +end-points** using a locally built wheel. |
| 10 | + |
| 11 | +### Clone and prepare the SDK repo |
| 12 | + |
| 13 | +```bash |
| 14 | +git clone https://github.com/Azure/azure-sdk-for-python.git |
| 15 | +cd azure-sdk-for-python/sdk/ai/azure-ai-agents |
| 16 | +``` |
| 17 | + |
| 18 | +### Install development dependencies |
| 19 | + |
| 20 | +```bash |
| 21 | +pip install -r dev_requirements.txt |
| 22 | +``` |
| 23 | + |
| 24 | +### Build and install the library locally |
| 25 | + |
| 26 | +```bash |
| 27 | +pip install wheel |
| 28 | +python setup.py bdist_wheel |
| 29 | +pip install dist/azure_ai_agents-*.whl --force-reinstall --user |
| 30 | +``` |
| 31 | + |
| 32 | +### Authenticate to Azure |
| 33 | + |
| 34 | +```bash |
| 35 | +az login |
| 36 | +``` |
| 37 | + |
| 38 | +### Set required environment variables |
| 39 | + |
| 40 | +Edit **`azure_ai_agents_tests.env`** one level above this folder and populate |
| 41 | +it with the IDs / endpoints of the Azure AI Foundry project you will test |
| 42 | +against. |
| 43 | + |
| 44 | +## Key concepts |
| 45 | + |
| 46 | +* **Live vs Recorded tests** by default tests run through the test-proxy so |
| 47 | + recordings can be created/replayed. |
| 48 | + Set the variables below to force **live** execution: |
| 49 | + |
| 50 | + |
| 51 | +```bash |
| 52 | + set AZURE_TEST_RUN_LIVE=true |
| 53 | + set AZURE_SKIP_LIVE_RECORDING=true |
| 54 | + set PROXY_URL=http://localhost:5000 |
| 55 | + set AZURE_TEST_USE_CLI_AUTH=true |
| 56 | +``` |
| 57 | + |
| 58 | + |
| 59 | +* **Authentication** tests rely on `DefaultAzureCredential`. |
| 60 | + When `AZURE_TEST_USE_CLI_AUTH=true`, the credential falls back to the Azure |
| 61 | + CLI token obtained via `az login`. |
| 62 | + |
| 63 | +## Examples |
| 64 | + |
| 65 | +Run **all** tests: |
| 66 | + |
| 67 | +```bash |
| 68 | +pytest |
| 69 | +``` |
| 70 | + |
| 71 | +Run a **single** test file: |
| 72 | + |
| 73 | +```bash |
| 74 | +pytest tests/test_agents_basic.py |
| 75 | +``` |
| 76 | + |
| 77 | +Run tests **with HTTP logging**: |
| 78 | + |
| 79 | +```bash |
| 80 | +pytest -s -o log_cli=true -o log_cli_level=INFO |
| 81 | +``` |
| 82 | + |
| 83 | +## Troubleshooting |
| 84 | + |
| 85 | +| Symptom | Fix | |
| 86 | +| ------- | ---- | |
| 87 | +| `azure.core.exceptions.ClientAuthenticationError` | Ensure `az login` was executed and the correct subscription is selected. | |
| 88 | +| Resource not found | Verify the endpoint / project IDs in `azure_ai_agents_tests.env`. | |
| 89 | +| Tests appear to hang | Make sure the **test-proxy** is running or unset `PROXY_URL`. | |
| 90 | + |
| 91 | +Enable debug logging to get raw HTTP traces: |
| 92 | + |
| 93 | +```bash |
| 94 | +set AZURE_LOG_LEVEL=debug |
| 95 | +``` |
| 96 | + |
| 97 | +## Next steps |
| 98 | + |
| 99 | +1. Review the test documentation to learn about the proxy recorder and test matrix. |
| 100 | +2. Explore the main package README for feature-level samples and usage |
| 101 | + guidance. |
| 102 | + |
| 103 | +## Contributing |
| 104 | + |
| 105 | +We welcome pull requests that add new scenarios, improve coverage, or refine |
| 106 | +the test infrastructure. Follow the same contribution guidelines as the main |
| 107 | +repo: |
| 108 | + |
| 109 | +1. Fork the repository and create a feature branch. |
| 110 | +2. Write or update tests **and** recordings. |
| 111 | +3. Ensure `pytest` passes and `python -m pip install .` still succeeds. |
| 112 | +4. Submit a PR and sign the CLA when prompted. |
0 commit comments