|
| 1 | +# Azure Functions Smoke Tests |
| 2 | + |
| 3 | +This directory contains smoke tests for Azure Functions with Durable Task, designed to validate the SDK and Source Generator functionality in a real Azure Functions isolated .NET environment. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The smoke tests ensure that: |
| 8 | +- The Durable Task SDK works correctly with Azure Functions isolated worker |
| 9 | +- Source generators produce valid code |
| 10 | +- Orchestrations can be triggered and completed successfully |
| 11 | +- The complete end-to-end workflow functions as expected |
| 12 | + |
| 13 | +## Structure |
| 14 | + |
| 15 | +- **HelloCitiesOrchestration.cs** - Simple orchestration that calls multiple activities |
| 16 | +- **Program.cs** - Azure Functions host entry point |
| 17 | +- **host.json** - Azure Functions host configuration |
| 18 | +- **local.settings.json** - Local development settings |
| 19 | +- **Dockerfile** - Docker image configuration for the Functions app |
| 20 | +- **run-smoketests.ps1** - PowerShell script to run smoke tests locally or in CI |
| 21 | + |
| 22 | +## Running Smoke Tests Locally |
| 23 | + |
| 24 | +### Prerequisites |
| 25 | + |
| 26 | +- Docker installed and running |
| 27 | +- PowerShell Core (pwsh) installed |
| 28 | +- .NET 8.0 SDK or later |
| 29 | + |
| 30 | +### Run the Tests |
| 31 | + |
| 32 | +From the `test/AzureFunctionsSmokeTests` directory: |
| 33 | + |
| 34 | +```bash |
| 35 | +pwsh -File run-smoketests.ps1 |
| 36 | +``` |
| 37 | + |
| 38 | +The script will: |
| 39 | +1. Build and publish the Azure Functions project |
| 40 | +2. Create a Docker image |
| 41 | +3. Start Azurite (Azure Storage emulator) in a Docker container |
| 42 | +4. Start the Azure Functions app in a Docker container |
| 43 | +5. Trigger the HelloCities orchestration via HTTP |
| 44 | +6. Poll for orchestration completion |
| 45 | +7. Validate the result |
| 46 | +8. Clean up all containers |
| 47 | + |
| 48 | +### Parameters |
| 49 | + |
| 50 | +The script accepts the following optional parameters: |
| 51 | + |
| 52 | +```powershell |
| 53 | +pwsh -File run-smoketests.ps1 ` |
| 54 | + -ImageName "custom-image-name" ` |
| 55 | + -ContainerName "custom-container-name" ` |
| 56 | + -Port 8080 ` |
| 57 | + -Timeout 120 |
| 58 | +``` |
| 59 | + |
| 60 | +## CI Integration |
| 61 | + |
| 62 | +The smoke tests are automatically run in GitHub Actions via the `.github/workflows/azure-functions-smoke-tests.yml` workflow on: |
| 63 | +- Push to `main` or `feature/**` branches |
| 64 | +- Pull requests targeting `main` or `feature/**` branches |
| 65 | +- Manual workflow dispatch |
| 66 | + |
| 67 | +## Troubleshooting |
| 68 | + |
| 69 | +If the smoke tests fail: |
| 70 | + |
| 71 | +1. **Check container logs**: The script will display logs automatically on failure |
| 72 | +2. **Verify Azurite is running**: Ensure port 10000-10002 are available |
| 73 | +3. **Check Functions app port**: Ensure the configured port (default 8080) is available |
| 74 | +4. **Build errors**: Ensure all dependencies are restored with `dotnet restore` |
| 75 | + |
| 76 | +## Adding New Smoke Tests |
| 77 | + |
| 78 | +To add new orchestration scenarios: |
| 79 | + |
| 80 | +1. Create new function classes following the pattern in `HelloCitiesOrchestration.cs` |
| 81 | +2. Ensure proper XML documentation comments |
| 82 | +3. Add test logic to validate the new scenario |
| 83 | +4. Update this README with the new test case |
0 commit comments