Skip to content

test(e2e): run the Python SDK contract suite against the gateway - #2778

Merged
thiras merged 8 commits into
mainfrom
feat/python-sdk-harness
Oct 30, 2026
Merged

thiras merged 8 commits into
mainfrom
feat/python-sdk-harness

Conversation

@thiras

@thiras thiras commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

What

Runs the Python SDK's contract suite (decdn/sdk-python) against a real decdn gateway in CI, the way the TypeScript suite already runs, at the commit .github/sdk-python.sha pins.

  • decdn_e2e::sdk_contract: the setup that lived in crates/e2e/tests/gateway_sdk.rs moves into the library behind a Suite trait (Mode, Outcome, run). TypeScript keeps today's vitest invocation; Python runs uv run --frozen --no-sync pytest … --junit-xml and reads the JUnit counts with a dependency-free attribute scanner. tests/gateway_sdk.rs and the new tests/gateway_sdk_python.rs are thin test targets behind anvil-e2e + sdk-e2e.
  • Fixture extension (additive; the TypeScript suite ignores it): the public run creates two namespaces and writes pointer.namespaces; the loopback run mints two delegates on example.com and example.net and writes capabilities. Index 0 equals the legacy pointer.namespace / host / capability. The Python suite runs every contract test for both Client and AsyncClient against the one gateway, each flavour on its own state; the post-suite checks cover each flavour the suite ran.
  • CI: a second job, anvil e2e (sdk contract, python), in .github/workflows/sdk-contract.yml, with the same restore-only caching as the TypeScript job; .config/nextest.toml gives the new binary the same no-retry override.
  • Docs: CONTRIBUTING.md § SDK contract runs (both SDKs), CLAUDE.md, rustdoc.

No issue to close: this is the decdn half of the Python SDK work tracked in decdn/sdk-python.

Reviewer notes

Read crates/e2e/src/sdk_contract.rs first: public/loopback are the old test bodies moved verbatim (git diff --color-moved shows it; the only rewrites are hashes[0]/[len-1] → first()/last() and Value indexing → get, for the library lint policy), then the Suite impls at the top. The fixture JSON written for the TypeScript suite is unchanged apart from the two added fields, so sdk-typescript needs no change. Risk: the loopback run now mints two delegates and the public run creates two namespaces for both suites; the TypeScript run pays for one unused entry each (≈1 s).

Follow-ups outside this repo: both SDK repos link crates/e2e/tests/gateway_sdk.rs as the fixture writer; after this merges, the writer is crates/e2e/src/sdk_contract.rs, so each gets a one-line docs PR. On a timed-out run, kill_on_drop kills uv run but not the pytest it spawned (it exits on its own 60 s test timeout); spawning .venv/bin/python -m pytest directly would close that, a small follow-up.

Verification

Commands run locally (each with the workspace build cache):

  • cargo nextest run -p decdn-e2e: 67 passed (JUnit scanner, fixture shape, Python::from_dir checks).
  • Real runs: DECDN_SDK_PYTHON_DIR=… cargo nextest run -p decdn-e2e --features anvil-e2e,sdk-e2e --test gateway_sdk_python → 2 passed (pytest 28 public + 22 loopback, all passed); DECDN_SDK_DIR=… … --test gateway_sdk → 2 passed, unchanged.
  • cargo fmt -- --check, CARGO_BUILD_WARNINGS=deny cargo doc -p decdn-e2e --no-deps --document-private-items, actionlint: clean.

Always:

  • pre-commit run --all-files
  • CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features
  • cargo nextest run (the decdn-e2e crate; the rest of the workspace is untouched and CI runs it)
  • PR title uses an allowed type and a lowercase subject

Only if touched: none of the listed areas. Not a user-visible change, so no CHANGELOG.md entry.

After merge

  • Add anvil e2e (sdk contract, python) as a required check in the main branch ruleset.
  • The next decdn release becomes sdk-python's harness-floor, which turns on its weekly released-gateway run.

🤖 Generated with Claude Code

thiras and others added 8 commits October 30, 2026 19:17
The chain, node, publisher/owner and gateway setup of the TypeScript SDK
contract run moves from tests/gateway_sdk.rs into the always-compiled
decdn_e2e::sdk_contract module. A Suite trait names one SDK's contract
suite and how to run it against a fixture file; TypeScript implements it
with the same vitest invocation and JSON report as before. run() wraps
the heavy timeout tier and enforces that every collected test passed.

tests/gateway_sdk.rs keeps its two tests, each now one call to
sdk_contract::run. blake3 moves to [dependencies] for Content::new.
Indexing that clippy flags in library code becomes Value::get /
Map::insert and hashes.first()/last().

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Python SDK's contract suite runs under pytest, which reports its counts as JUnit XML. sdk_contract::junit reads the tests, failures, errors and skipped counts from the report's first <testsuite> start tag with no XML parser and no new crate, and fails naming a missing tag or attribute or a non-numeric value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
sdk_contract::Python runs decdn/sdk-python's tests/contract/test_*.py files with pytest under uv, from the checkout DECDN_SDK_PYTHON_DIR names, and reads its counts from the JUnit report. Python::from_dir requires an absolute checkout with a uv.lock and a synced .venv, and a uv that runs. The gateway_sdk_python target runs both modes with it, behind the anvil-e2e and sdk-e2e features.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Python suite runs every contract test once per client flavour (sync
and async) against one gateway. The flavours must not share a namespace
pointer or a delegate's capability, or one flavour sees the other's
state.

The public run now creates two namespaces for the publisher key and
writes them as `pointer.namespaces` (decimal strings);
`pointer.namespace` stays the first. The loopback run mints two
delegates, assigns each a capability from the one pool, and writes
`capabilities: [{host, capability}]` for example.com and example.net;
`host` and `capability` stay the first. The post-suite checks now
require the state of each flavour the suite runs. The fixture assembly
moves into pure helpers with unit tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add the anvil-e2e-sdk-python job, the .github/sdk-python.sha pin, and
extend the no-retry nextest override to gateway_sdk_python.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Rename the CONTRIBUTING section to SDK contract runs, add the Python
block, and name both targets in CLAUDE.md and the e2e rustdoc.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 30, 2026 17:05

Copilot AI 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.

🟢 Approval recommended

No active review issues block the Python SDK contract-testing changes.

No open issues 🎉

What changed in this PR

Adds Python SDK contract testing against a real decdn gateway, alongside the existing TypeScript suite, to catch differences between SDK expectations and gateway behavior.

Changes:

  • Extracts shared gateway setup into a reusable harness with TypeScript and Python runners.
  • Adds separate namespaces and capabilities for Python’s synchronous and asynchronous clients, plus fixture and report-validation tests.
  • Adds a pinned Python SDK CI job, no-retry configuration, and documentation for both SDK runs.
File Description
crates/​e2e/​tests/​gateway_sdk.rs Delegates TypeScript tests to the shared harness.
crates/​e2e/​tests/​gateway_sdk_python.rs Adds Python public and loopback gateway tests.
crates/​e2e/​src/​timeout.rs Documents the Python suite’s timeout tier.
crates/​e2e/​src/​sdk_contract/​tests.rs Tests fixture shapes, report counts, and harness validation.
crates/​e2e/​src/​sdk_contract/​junit.rs Reads pytest’s JUnit result counts.
crates/​e2e/​src/​sdk_contract.rs Implements shared setup, SDK runners, and post-suite checks.
crates/​e2e/​src/​lib.rs Exports and documents the shared harness.
crates/​e2e/​Cargo.toml Registers the Python target and promotes the shared hash dependency.
CONTRIBUTING.md Documents setup, execution, and pin updates for both SDKs.
CLAUDE.md Updates the project overview for both SDK contract suites.
.github/​workflows/​sdk-contract.yml Adds the Python SDK job with cache saving disabled.
.github/​sdk-python.sha Pins the Python SDK revision used in CI.
.config/​nextest.toml Applies the contract-suite timeout and no-retry policy to Python.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main d96e78d feat/python-sdk-harn... 9f190f5 +/-
77% 77% 0%
View coverage of the 4 most impacted files.
File main d96e78d feat/python-sdk-harn... 9f190f5 +/-
crates/client/src/lib.rs 89% 89% 0%
crates/client/src/scheduler.rs 94% 95% +1%
crates/e2e/src/sdk_contract.rs 0% 22% +22%
crates/e2e/src/...ntract/junit.rs 0% 94% +94%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@thiras
thiras merged commit 8f126d1 into main Oct 30, 2026
41 checks passed
@thiras
thiras deleted the feat/python-sdk-harness branch October 30, 2026 17:22
thiras added a commit to decdn/sdk-typescript that referenced this pull request Oct 30, 2026
decdn/decdn#2778 moved the SDK contract harness into
`crates/e2e/src/sdk_contract.rs`; `crates/e2e/tests/gateway_sdk.rs` is
now a thin caller, so `scripts/decdn-contract.sh` keeps its existence
check and only its comment changes. This updates the README,
CONTRIBUTING and the contract suite comments that named the old file as
the fixture writer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <[email protected]>
thiras added a commit to decdn/sdk-python that referenced this pull request Oct 30, 2026
decdn/decdn#2778 moved the SDK contract harness into
`crates/e2e/src/sdk_contract.rs`; the `gateway_sdk*` test targets are
thin callers. This updates the README and the contract suite docstrings
that named the old file as the fixture writer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <[email protected]>
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.

2 participants