Skip to content

test(tes/data/crypt4gh): add an end-to-end test - #76

Merged
uniqueg merged 4 commits into
devfrom
test/68-crypt4gh-e2e
Nov 12, 2026
Merged

uniqueg merged 4 commits into
devfrom
test/68-crypt4gh-e2e

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds an end-to-end test of tes.data.crypt4gh against a real TES backend (plugins/tes/data/crypt4gh/e2e/).

  • Stack (compose.yaml): proTES 0.6.0 (the release image by digest, with the plugin's wheel built from the checkout, Dockerfile.protes), its Celery worker, MongoDB, RabbitMQ, and Funnel 0.11.14 (Dockerfile.funnel, funnel.yaml). Funnel runs the executors as sibling containers through the Docker socket, as in proTES's Integration job. It keeps the work directories (LeaveWorkDir), so the test can look at the volume on the host. services.py is a small OIDC identity provider for proTES (proTES needs tokens) and a file server for the task inputs.
  • Inputs: a Crypt4GH file and a secret key. The test makes them with the decryption image's crypt4gh tools, so the repository holds no keys. They are served over HTTP, and Funnel downloads them by URL. The decryption image is built from the checkout as foca-plugin-tes-data-crypt4gh-decrypt:e2e. Funnel's pull of it fails, and Funnel then runs the local image.
  • Checks (check.sh):
    1. A task completes. Funnel has the decryption executor first and the --clear teardown last, and the task's executor (cat /in/hello.txt.c4gh, rewritten to /vol/crypt4gh/hello.txt) prints the decrypted content. The volume is empty afterwards.
    2. A failing decryption (no key for one of two files) ends the task with EXECUTOR_ERROR after the decryption executor, and the volume is empty.
    3. With the default settings (no teardown_on_error), a failing task executor stops the task before the teardown, so the decrypted file stays in the volume. This is the documented limit.
    4. proTES is restarted with config-on-error.yaml (teardown_on_error: true). The failing executor gets ignore_error: true, the teardown still runs (exit 0), and the volume is empty.
  • CI: new job e2e ("End-to-end test"). It runs when the plugin is affected (job changes) and is in the gate's needs. The gate allows the skip only when the plugin isn't affected. It needs no credentials, so it runs the same for pull requests from forks: nothing has to be skipped.
  • Dependabot: docker and docker-compose entries for the e2e directory. Major updates of the compose images are left out, as in proTES (MongoDB 8).
  • Robustness:
    • The Compose project is named after E2E_PORT.
    • Cleanup removes only the task containers whose mounts are in this run's work directory.
    • The work directory has to be one the test created: a marker file, owned by the runner, not a symbolic link, no : in its path. Paths such as // are refused.
    • If tools are missing, the test exits with status 2 before it starts anything.
    • The final state with teardown_on_error is the backend's, so EXECUTOR_ERROR and COMPLETE both pass. The executor logs and the volume decide the result.
  • Docs:
    • Plugin README: a new section "End-to-end test", and a corrected teardown_on_error note. Funnel 0.11.14 ends such tasks with EXECUTOR_ERROR even though the teardown ran. The README said COMPLETE, which is what the current Funnel sources do.
    • Contributing guide: a new section "End-to-end tests" (how to run it, settings, updates).
    • Changelog: updated.

Scope notes

  • HTTP instead of MinIO: the issue mentions MinIO. Inputs are served over HTTP instead, as requested for this implementation. The plugin doesn't touch input URLs, so S3 storage would test Funnel rather than the plugin.
  • TESK: TESK refuses ignore_error: true (400), so teardown_on_error is tested with Funnel only, and there is no TESK variant.
  • In the gate: unlike proTES's Integration job, this job is a required part of the gate. It is the plugin's only test against a backend and runs only for changes that affect the plugin. If the public registries (Docker Hub, quay.io, ghcr.io) are down, those PRs wait.

Closes #68

Verification

  • plugins/tes/data/crypt4gh/e2e/check.sh (locally, with E2E_WORK_DIR in the clone): passed 4 times, the last run after both review rounds, with E2E_PORT=18081 and a trailing slash on E2E_WORK_DIR. Each time, the stack, the task containers and the work directory were removed afterwards.
  • The work-directory guards exit with status 2 for //, /., /tmp/a:b, an existing directory without the marker, and a symbolic link.
  • Mutation run with teardown: false in config.yaml, and the executor check relaxed so the run reaches the volume check: failed as expected with The teardown left files: hello.txt.
  • pre-commit run --all-files (ruff, mypy, semgrep, gitleaks, actionlint, ast-grep, package conventions): passed.
  • shellcheck 0.10.0 on check.sh: clean (two intentional SC2016 disabled inline, with reasons).
  • Gate filter tested with jq on 5 cases (e2e skipped/success/failure, plugin affected or not): it fails only on an unintended skip or a failure.
  • coverage run --source scripts,docs -m pytest tests: 142 passed, 100%. Plugin tests: 130 passed, 100%.
  • mkdocs build --strict: OK.
  • CI: all checks passed on the first push, including End-to-end test (1m51s on the hosted runner), Smoke test and CI passed. They passed again after the Sourcery fixes (5fdc19e): 96 of 96, including Sourcery review.
  • After the Sourcery fixes: the full local run passed. While the stack ran, a host request to Funnel's container address timed out, because the internal network is not reachable from the host. The guards refused /tmp/not-yet-created/.., /tmp/a/./b, /tmp//a and a directory inside another run's work directory.

Automated review

Sourcery opened 5 threads. All were answered and resolved:

  • Funnel's API reachable from the host: the stack is now on an internal network.
  • A .. path could empty /tmp: only normalized paths are accepted now.
  • Nested work directories: refused.
  • A cleanup failure after a passed test: the test now fails.
  • MinIO: answered; HTTP is the requested scope (see Scope notes).

Declined review findings

Two rounds each of adversarial and quality review. All high and medium findings, and the cheap low ones, were fixed. Declined:

  • Deduplicate the build block of the services service in compose.yaml (low): each service stays self-contained, so that it can be started on its own. Compose builds the shared tag once per up.
  • Read the decrypted file in check 3 through a root container (low): the decryption script writes 0644 files, which the image's smoke test asserts. If that changed, the cat would fail loudly, not pass vacuously.
  • Per-run image tags, so that runs of different checkouts can run side by side (medium, round 2): the docs and the script now say that only runs of the same checkout can. Unique tags would mean templating the plugin's image setting in the proTES overlay, which isn't worth it for a test that CI runs on fresh runners.
  • The default work directory in shared /tmp is open to a symlink swap by another local user between check and use (low): symbolic links and directories of other users are now refused. The remaining race window only matters on shared multi-user hosts. CI runners are single-user, and E2E_WORK_DIR can point elsewhere.

Open questions

None.

🤖 Generated with Claude Code

https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV

uniqueg and others added 3 commits November 12, 2026 09:56
Run tes.data.crypt4gh end to end against a real TES backend:
e2e/check.sh starts proTES 0.6.0 (its release image, with the plugin's
wheel built from the checkout) and Funnel 0.11.14 in Docker Compose, and
sends tasks whose Crypt4GH file and secret key are served over HTTP.
It checks that a task completes with the decrypted content and an empty
volume after the teardown, that a failing decryption fails the task
without decrypted files, that a failing executor stops the task before
the teardown by default, and that the teardown runs after it with
teardown_on_error.

CI runs it in the new job e2e (End-to-end test) when the plugin is
affected; the gate allows the skip otherwise. Dependabot covers the
test's images. The plugin README, the contributing guide and the
changelog describe it; the README now says that Funnel 0.11.14 ends
such tasks with EXECUTOR_ERROR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
From the review of the end-to-end test:

- Name the Compose project after E2E_PORT and remove only the task
  containers with mounts in this run's work directory, so that runs
  with different ports and work directories don't interfere.
- Refuse a work directory that the test didn't create (marker file),
  and paths such as // or /.; empty it with find in a container.
- Keep the cleanup going after errors (set +e in the EXIT trap).
- Exit with status 2 before starting anything if a tool is missing.
- Fail if the volume can't be listed, instead of counting it as empty.
- Accept COMPLETE as well as EXECUTOR_ERROR with teardown_on_error, as
  the final state is the backend's; assert the decryption executor's
  arguments for the failing decryption.
- Share one helper for requests in the Compose network.
- Docs: point to the pinned versions instead of naming them, re-wrap
  the README, describe the new behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
From the second review round:

- Strip trailing slashes from E2E_WORK_DIR and refuse paths with ':',
  symbolic links and directories of other users.
- Match task containers by mount sources that start with the work
  directory, from captured output (no grep -q with pipefail).
- Docs: runs side by side only from the same checkout, as the image
  tags are shared; status 2 also for a bad work directory; which
  images Dependabot updates. Drop the changelog entry that documented
  unreleased behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Configure dependency updates for the e2e images and add the CI job and gate logic that runs the test when the Crypt4GH plugin is affected.

  • .github/dependabot.yml L49-75
  • .github/workflows/ci.yml L348-385 (+3 small edits)

Define the Compose stack, pinned service images, Funnel settings, proTES overlays, and Docker build contexts used by the e2e test.

  • plugins/tes/data/crypt4gh/e2e/.dockerignore L1-4
  • plugins/tes/data/crypt4gh/e2e/Dockerfile.funnel L1-7
  • plugins/tes/data/crypt4gh/e2e/Dockerfile.protes L1-19
  • plugins/tes/data/crypt4gh/e2e/compose.yaml L1-146
  • plugins/tes/data/crypt4gh/e2e/config-on-error.yaml L1-11
  • plugins/tes/data/crypt4gh/e2e/config.yaml L1-47
  • plugins/tes/data/crypt4gh/e2e/funnel.yaml L1-35

Documentation

Document how to run and configure the e2e test, its behavior and backend limitations, and clarify Funnel’s teardown-on-error task state.

  • docs/contributing/index.md L65-113
  • plugins/tes/data/crypt4gh/CHANGELOG.md L29-35
  • plugins/tes/data/crypt4gh/README.md L156-162, L338-374

Tests

Implement the end-to-end test that builds inputs, drives tasks through proTES and Funnel, checks outcomes and cleanup, and provides the test identity and file services.

  • plugins/tes/data/crypt4gh/e2e/check.sh L1-383
  • plugins/tes/data/crypt4gh/e2e/services.py L1-125

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 foca-plugins | 🛠️ Build #35835334 | 📁 Comparing 5fdc19e against latest (c57c78e)

  🔍 Preview build  

1 file changed
± contributing/index.html

@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c57c78e) to head (5fdc19e).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev       #76   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          886       886           
  Branches       125       125           
=========================================
  Hits           886       886           
Flag Coverage Δ
foca-plugin-generic-example-noop 100.00% <ø> (ø)
foca-plugin-generic-routing-random 100.00% <ø> (ø)
foca-plugin-tes-data-crypt4gh 100.00% <ø> (ø)
foca-plugin-tes-routing-distance 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 12, 2026 09:37
@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit 5fdc19e

#68 test(tes/data/crypt4gh): run end to end with TES · 2 of 3 met

# Requirement Status Notes
1 Run an end-to-end test in CI with proTES, the plugin, Funnel and MinIO, and verify an executor reads the decrypted input. 🟡 Partly met CI runs the test against proTES and Funnel, and checks the decrypted content, but the inputs are served by an HTTP file server rather than MinIO.
2 Verify that a failing decryption fails the task without leaving decrypted files. ✅ Met The test checks for the expected task error and an empty volume after decryption fails.
3 Document the test in the plugin README and contributing guide, and skip it with a reason where it cannot run, such as on forks. ✅ Met Both guides document the test. It runs without credentials, including on forks, so no fork-specific skip is needed.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 5 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="plugins/tes/data/crypt4gh/e2e/compose.yaml" line_range="91" />
<code_context>
+    volumes:
+      - ./funnel.yaml:/etc/funnel.yaml:ro
+      - ${E2E_WORK_DIR:?}/funnel:${E2E_WORK_DIR:?}/funnel
+      - /var/run/docker.sock:/var/run/docker.sock
+    healthcheck:
+      test: ["CMD", "/app/funnel", "task", "list", "--server", "http://localhost:8000"]
</code_context>
<issue_to_address>
**Unauthenticated users can submit tasks**

When an unprivileged process on a Linux host can reach the Compose bridge address while the test stack is running, a caller can bypass proTES authentication and submit arbitrary TES tasks directly to Funnel's HTTP API; Funnel runs task executors as root with access to the Docker socket, giving that caller control over workloads in the test stack.

Require authentication for Funnel's HTTP API or isolate and firewall the stack so untrusted host processes cannot reach it.

Also at `plugins/tes/data/crypt4gh/e2e/funnel.yaml:16`.
</issue_to_address>

### Comment 2
<location path="plugins/tes/data/crypt4gh/e2e/check.sh" line_range="74" />
<code_context>
+    echo "E2E_WORK_DIR must not contain ':', not ${E2E_WORK_DIR}" >&2
+    exit 2
+    ;;
+  /*[!/.]*) ;;
+  *)
+    echo "E2E_WORK_DIR must be an absolute path below /, not ${E2E_WORK_DIR}" >&2
</code_context>
<issue_to_address>
**Unrelated `/tmp` contents are erased**

When `E2E_WORK_DIR` is set to a path such as `/tmp/not-yet-created/..`, the path glob accepts this spelling, and the existing-path guard skips it because the leading component is missing. `mkdir -p` then creates that component and resolves the work directory to `/tmp`; cleanup mounts `/tmp` and `find /work -mindepth 1 -delete` erases its contents.

Canonicalize the work-directory path and reject paths containing `..` components or resolving to an unsafe ancestor before creating anything.
</issue_to_address>

### Comment 3
<location path="plugins/tes/data/crypt4gh/e2e/check.sh" line_range="111-112" />
<code_context>
+remove_work_dir() {
+  if [[ -f "${marker}" ]]; then
+    docker run --rm -v "${E2E_WORK_DIR}:/work" "${image}" \
+      find /work -mindepth 1 -delete || true
+    rm -rf "${E2E_WORK_DIR}" || true
+  fi
+}
</code_context>
<issue_to_address>
**Nested runs delete each other**

When two runs use different ports but one run’s `E2E_WORK_DIR` is nested inside the other’s, the outer run’s `remove_work_dir` recursively empties and removes its work directory, including a nested run’s directory; its `task_containers` prefix match also selects the nested run’s containers. The inner run loses its files and containers and fails.

Canonicalize work-directory paths and refuse overlapping paths, or isolate cleanup and container selection with a per-run identity.

Also at `plugins/tes/data/crypt4gh/e2e/check.sh:124`.
</issue_to_address>

### Comment 4
<location path="plugins/tes/data/crypt4gh/e2e/compose.yaml" line_range="55" />
<code_context>
+      condition: service_healthy
+    rabbitmq:
+      condition: service_healthy
+    services:
+      condition: service_healthy
+
</code_context>
<issue_to_address>
**Use MinIO for inputs**

The issue asks for MinIO as the object storage in the end-to-end test. This change serves inputs through the `services` HTTP file server instead.
</issue_to_address>

### Comment 5
<location path="plugins/tes/data/crypt4gh/e2e/check.sh" line_range="137" />
<code_context>
+  if [[ "${status}" != 0 ]]; then
+    docker compose logs --no-color protes protes-worker funnel
+  fi
+  docker compose down --volumes --remove-orphans
+  task_containers | xargs -r docker rm -f
+  remove_work_dir
</code_context>
<issue_to_address>
**Cleanup failures still pass**

When a cleanup command fails after all test checks passed, `set +e` lets cleanup continue after `docker compose down` fails, and `remove_work_dir` suppresses its cleanup errors with `|| true`; the trap then exits with the original status 0, so the test reports success while resources remain.

Record and report cleanup failures, and return a failure status when the test passed but cleanup did not.

Also at `plugins/tes/data/crypt4gh/e2e/check.sh:112`.
</issue_to_address>

Sourcery assessment

Approval pending. 5 findings to address first.

Blocking findings: plugins/tes/data/crypt4gh/e2e/compose.yaml:91, plugins/tes/data/crypt4gh/e2e/check.sh:74, plugins/tes/data/crypt4gh/e2e/check.sh:112, plugins/tes/data/crypt4gh/e2e/compose.yaml:55, plugins/tes/data/crypt4gh/e2e/check.sh:137


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread plugins/tes/data/crypt4gh/e2e/check.sh Resolved
Comment thread plugins/tes/data/crypt4gh/e2e/check.sh Resolved
Comment thread plugins/tes/data/crypt4gh/e2e/check.sh Resolved
From Sourcery's review:

- Put the services on an internal Compose network, so that the host
  can't reach Funnel's API, which has no authentication; only proTES
  is on a second network, for its published port.
- Refuse work directories that aren't normalized paths (e.g.
  /tmp/x/..), and ones inside the work directory of another run.
- Fail a passed test if its cleanup leaves something behind.
- Contributing guide: describe the network and the work directory
  rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMpmDCfbACLj3uy6xV
@uniqueg
uniqueg merged commit 103aeed into dev Nov 12, 2026
256 checks passed
@uniqueg
uniqueg deleted the test/68-crypt4gh-e2e branch November 12, 2026 10:13
uniqueg added a commit that referenced this pull request Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(tes/data/crypt4gh): run end to end with TES

1 participant