Skip to content

feat: add bench diagnostics #682

feat: add bench diagnostics

feat: add bench diagnostics #682

Workflow file for this run

name: Integration Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
integration:
# 24.04 ships nginx 1.24; production deploys emit ssl_reject_handshake,
# which needs nginx >= 1.19.4 (22.04 only has 1.18 and fails nginx -t).
runs-on: ubuntu-24.04
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- uses: actions/setup-node@v4
with:
node-version: "24"
- name: Install system dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y mariadb-server redis-server git nginx openssl
sudo systemctl start mariadb redis-server
sudo mysql -e "SET PASSWORD FOR root@localhost = PASSWORD('admin'); FLUSH PRIVILEGES;"
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install yarn and bench
run: |
npm install -g yarn
pip install -e ".[test,admin]"
- name: Create bench
run: |
mkdir -p benches/ci-bench
cp tests/fixtures/ci_bench.toml benches/ci-bench/bench.toml
- name: bench init
run: bench init -b ci-bench
timeout-minutes: 45
- name: Create sites
run: |
bench new-site site1.localhost --admin-password admin
bench new-site site2.localhost --admin-password admin
- name: Verify sites exist
run: |
test -f benches/ci-bench/sites/site1.localhost/site_config.json
test -f benches/ci-bench/sites/site2.localhost/site_config.json
- name: Start Redis services
run: |
redis-server benches/ci-bench/config/redis_cache.conf --daemonize yes
redis-server benches/ci-bench/config/redis_queue.conf --daemonize yes
sleep 2
- name: Migrate both sites
run: |
PYTHON=$GITHUB_WORKSPACE/benches/ci-bench/env/bin/python
cd $GITHUB_WORKSPACE/benches/ci-bench/sites
$PYTHON -m frappe.utils.bench_helper frappe --site site1.localhost migrate
$PYTHON -m frappe.utils.bench_helper frappe --site site2.localhost migrate
- name: Clear cache on both sites
run: |
PYTHON=$GITHUB_WORKSPACE/benches/ci-bench/env/bin/python
cd $GITHUB_WORKSPACE/benches/ci-bench/sites
$PYTHON -m frappe.utils.bench_helper frappe --site site1.localhost clear-cache
$PYTHON -m frappe.utils.bench_helper frappe --site site2.localhost clear-cache
- name: bench update
run: bench --yes update
- name: bench build
run: bench build
# Non-production tests rely on the redis started above. Production tests
# manage their own redis, so they run separately after that redis is
# stopped to avoid a port clash.
- name: Run integration tests (non-production)
run: pytest tests/integration/ -v -m "not production"
env:
BENCH_TEST_ROOT: ${{ github.workspace }}/benches/ci-bench
- name: Stop manually-started redis
if: ${{ !cancelled() }}
run: |
redis-cli -p 13000 shutdown nosave || true
redis-cli -p 11000 shutdown nosave || true
# Run regardless of the non-production result so the production signal
# isn't masked by an unrelated failure in the first group.
- name: Run production e2e tests
if: ${{ !cancelled() }}
run: pytest tests/integration/ -v -m "production"
env:
BENCH_TEST_ROOT: ${{ github.workspace }}/benches/ci-bench
# Opt in to the destructive production + self-signed SSL e2e
# (installs services, rewrites the machine's nginx config).
BENCH_E2E_PRODUCTION: "1"
- name: Diagnostics on failure
if: failure()
run: |
export XDG_RUNTIME_DIR=/run/user/$(id -u)
echo "::group::systemd --user units"
systemctl --user list-units --all --no-pager | grep -i ci-bench || true
echo "::endgroup::"
echo "::group::failed unit status"
systemctl --user --no-pager status 'ci-bench-*' 'ci-bench.target' || true
echo "::endgroup::"
echo "::group::journal (user)"
journalctl --user -n 300 --no-pager || true
echo "::endgroup::"
echo "::group::bench logs"
tail -n 80 benches/ci-bench/logs/*.log 2>/dev/null || true
echo "::endgroup::"