Repository navigation
Improve trace spans #150
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| env: | |
| COLUMNS: 140 # Avoid narrow or even truncated output from pytest and rich | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "*" | |
| paths-ignore: | |
| - "**.md" | |
| pull_request: | |
| paths-ignore: | |
| - "**.md" | |
| jobs: | |
| ruff-pyright-pytestlinux-and-mitmproxy-recording: | |
| timeout-minutes: 5 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: set up python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: ruff lint and format | |
| run: | | |
| uv run ruff check | |
| uv run ruff format --check | |
| - name: pyright type check | |
| run: | | |
| uv sync --all-extras | |
| uv run pyright | |
| - name: pytest | |
| run: uv run pytest -v --timeout 90 tests | |
| - name: install mitmproxy | |
| run: | | |
| sudo apt-get install -y mitmproxy | |
| - name: generate locustfile using mitmproxy and execute recording | |
| run: | | |
| LOCUST_LOCUSTFILE=asdf.py LOCUST_EXTRA_IGNORED_HEADERS=Proxy-Connection LOCUST_IGNORED_URLS=https://www.google.com/?FOO mitmdump -s src/aiolocust/mitmproxy_addon.py & | |
| timeout 10s bash -c 'until lsof -i:8080; do sleep 1; done' | |
| grep "This file was generated using mitmproxy" asdf.py | |
| curl -x http://localhost:8080 -k https://www.google.com | |
| curl -x http://localhost:8080 -k https://www.google.com/?FOO | |
| grep https://www.google.com asdf.py | |
| grep -v Proxy-Connection asdf.py | |
| grep -v FOO asdf.py | |
| uv run aiolocust -i 1 asdf.py | tee locust_output.txt | |
| echo | |
| grep https://www.google.com locust_output.txt | |
| echo | |
| grep "0 (0.0%)" locust_output.txt | |
| examples: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 4 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Start Server | |
| run: | | |
| cd tests/performance && nginx -p $PWD -c $PWD/nginx.conf | |
| # timeout 10s sh -c 'until curl -s localhost:8080; do sleep 1; done' | |
| - name: set up python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| - name: --instrument | |
| env: | |
| OTEL_TRACES_EXPORTER: console | |
| run: | | |
| uv run aiolocust --instrument -d 1 | tee locust_output.txt | |
| grep -E '"name": "GET"' locust_output.txt | |
| - name: events_ex.py | |
| env: | |
| OTEL_TRACES_EXPORTER: console | |
| run: | | |
| set -x | |
| uv run aiolocust examples/events_ex.py --iterations 1 | tee locust_output.txt | |
| grep -E 'Request: GET http://localhost:8080/, TTLB:' locust_output.txt | |
| grep -E 'Shutdown requested, 1 iterations' locust_output.txt | |
| grep -E 'Shutdown completed, no new requests can ever happen after this point' locust_output.txt | |
| grep -E 'http://localhost:8080/,' requests.csv | |
| - name: threshold_validation.py | |
| env: | |
| OTEL_TRACES_EXPORTER: console | |
| run: | | |
| set +e # dont exit on error | |
| set -o pipefail # preserve exit code from uv run instead of using tee's exit code | |
| uv run aiolocust examples/threshold_validation.py --iterations 1 | tee locust_output.txt | |
| exit_code=$? | |
| echo "exit_code=$exit_code" >> "$GITHUB_OUTPUT" | |
| if [ "$exit_code" -ne 42 ]; then | |
| echo "Expected exit code 42, got $exit_code" | |
| exit 1 | |
| fi | |
| perftest: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 4 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Start Server | |
| run: | | |
| cd tests/performance && nginx -p $PWD -c $PWD/nginx.conf | |
| # timeout 10s sh -c 'until curl -s localhost:8080; do sleep 1; done' | |
| - name: set up python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| - name: Run Tests | |
| run: | | |
| uv run aiolocust examples/advanced.py --users 100 --duration 30 --rate 10 --log-level debug | tee locust_output.txt | |
| grep -E 'Total.*[0-9]{4}.[0-9]{2}/s' locust_output.txt # ensure >1000 RPS | |
| bash -ec '! grep Traceback locust_output.txt' # ensure no callstacks | |
| windows: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: set up python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: pytest | |
| run: uv run pytest --timeout 180 --full-trace tests | |
| macos: | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: set up python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: pytest | |
| run: uv run pytest --timeout 90 tests | |
| publish_pypi: | |
| name: Publish to PyPI | |
| needs: | |
| - ruff-pyright-pytestlinux-and-mitmproxy-recording | |
| - macos | |
| - windows | |
| if: github.repository_owner == 'locustio' && startsWith(github.event.ref, | |
| 'refs/tags') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Build package | |
| run: | | |
| uv version ${{ github.ref_name }} | |
| uv build | |
| - name: Publish to PyPI | |
| run: uv publish | |
| docker_image: | |
| needs: [ruff-pyright-pytestlinux-and-mitmproxy-recording, macos] | |
| if: github.repository_owner == 'locustio' && startsWith(github.event.ref, | |
| 'refs/tags') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - id: set_is_tag_build | |
| run: echo "is_tag_build=${{ startsWith(github.event.ref, 'refs/tags') }}" | tee -a "$GITHUB_OUTPUT" | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: cyberw | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Docker meta | |
| id: docker_meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: locustio/aiolocust | |
| tags: | | |
| type=raw,value=latest,enable=${{ steps.set_is_tag_build.outputs.is_tag_build }} | |
| type=raw,value=${{ github.ref_name }},enable=${{ steps.set_is_tag_build.outputs.is_tag_build }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Build package | |
| run: | | |
| uv version ${{ github.ref_name }} # ensure version is set inside the package too | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and (optionally) push docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.docker_meta.outputs.tags }} |