Skip to content

chore: pyt contract tests for candidate releases - #7252

Merged
fracasula merged 10 commits into
masterfrom
pyt-contract-tests-v1-v2
Aug 14, 2026
Merged

fracasula merged 10 commits into
masterfrom
pyt-contract-tests-v1-v2

Conversation

@fracasula

@fracasula fracasula commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Repurposes the integration_test/pytransformer_contract suite from "old architecture vs new architecture" to "baseline rudder-pytransformer vs candidate rudder-pytransformer", and fixes the retry classification that the new routing exposed.

The suite previously compared rudder-transformer + a per-subtest openfaas-flask-base container against rudder-pytransformer. That comparison is obsolete now that PyT is the only implementation, so both sides are now PyT images at two different tags and the openfaas/rudder-transformer scaffolding is deleted. Because both sides fetch transformation code per request, one container per version serves every versionID instead of one container per subtest — roughly 90 fewer container starts per run.

Which two images are compared is the caller's decision: PYT_CANDIDATE_TAG and PYT_BASELINE_TAG are both required and neither has a default, so TestMain fails the package before any container starts if either is missing. CI resolves the two most recent released tags from ECR and exports them, so a new release is picked up automatically; locally you build your image (make build-ecr-latest tags it main) and point the candidate at it. This also replaces the floating main/latest tags the suite used to pull, so runs are reproducible. If both tags resolve to the same value the suite refuses to run rather than compare an image against itself.

Running it against your own PyT build

In the rudder-pytransformer repo, build the image — make build-ecr-latest, which tags it main — then from rudder-server point the candidate at that build and the baseline at the release you want to compare against:

PYT_CANDIDATE_TAG=main PYT_BASELINE_TAG=<last released tag> make test package=integration_test/pytransformer_contract
# or, for one suite while iterating:
PYT_CANDIDATE_TAG=main PYT_BASELINE_TAG=<last released tag> go test ./integration_test/pytransformer_contract/ -run TestBackwardsCompatibility -count=1 -timeout=30m

The rudder-pytransformer Makefile recipe sets both for you and takes the baseline tag as a required argument. You need to be able to pull from ECR for the baseline image (see the Notion docs); the candidate comes from your local build. Two things to know:

  • Docker only pulls a tag it doesn't already have. If you skip the rebuild, main is whatever you last pulled or built, and the suite will happily compare that instead — with no warning. Rebuild before you trust a green run.
  • Omitting either tag fails the whole package with a message naming the missing one, before any container starts. Setting both to the same value is refused too, rather than passing every parity assertion vacuously.

Behaviour change (not test-only)

The suite now routes through the per-workspace PyT path, which activates cold-start classification and made an existing bug reachable:

  • isColdStartError no longer treats a 503 as a PyT cold start when the response carries X-Rudder-Should-Retry: true. A labelled 503 means PyT is up and reporting a transient downstream failure (e.g. a geolocation timeout), not that the pod is missing; anything else, including a bare 502 from kube-proxy with no endpoints, still means "not ready yet". Without this, Transformer.Client.UserTransformer.retryRudderErrors.maxRetry is unenforceable, because the endless cold-start loop resumes retrying what the transport was just told to stop.
  • X-Rudder-Should-Retry and X-Rudder-Error-Reason are lifted into exported constants in internal/transformer-client, documented as a wire format shared with rudder-pytransformer: renaming the constants is free, changing their values is a breaking change on both sides. The signal itself is defined once, as transformerclient.IsRetryableResponse, and both consumers — the retryable transport and the cold-start classifier — call it, so they cannot disagree about which responses carry the contract. The status set is 503-only, matching what PyT emits: it normalises downstream failures (a downstream 502 included) into its own 503 plus these headers.
  • An exhausted retry budget still crashes the processor, deliberately, and there is now a test pinning that. Retries are effectively infinite in production (maxRetry=-1, maxElapsedTime=0); maxRetry exists so the contract tests terminate. A bounded budget in production is a misconfiguration, and crashing is the safe response: the jobs stay in jobsdb and are retried after the restart, whereas failing the events would abort them into proc-errors and lose customer data.
  • internal/transformer-client no longer closes the response body inside its retry strategy. retryablehttp already drains and closes between attempts; our close also fired on the attempt that exhausts the budget, and that response is the one handed back to the caller — so forwardTest (the control-plane "test a transformation" path) got http: read on closed response body instead of PyT's real status and body. Removing it also restores the 2KB drain that keep-alive reuse depends on.
  • forwardTest now reports the status code and X-Rudder-Error-Reason when a body read fails, so a lost body still says whether PyT answered and why.

Tests

  • TestIsColdStartError — new table test pinning which 5xx responses mean "pod isn't up yet", including the case-insensitive header match and the bare-5xx cold-start cases.
  • TestRetryableResponseExhaustedPanics — drives a permanently-failing 503 + X-Rudder-Should-Retry through Transform() and asserts the process dies rather than dropping the events. The panic happens in a wg.Go goroutine so it cannot be recovered in-process; the test re-execs itself in a child and asserts the child died on the transformer error. Verified to fail if the events are made to fail instead.
  • The geolocation and backwards-compatibility contract subtests that called the baseline and then asserted nothing on it now assert both sides and compare them, so a divergence between two PyT releases fails the suite instead of being logged and ignored.
  • TestClient_ResponseBodyReadableAfterRetriesExhausted — pins that Do returns a readable body once retries are exhausted. Its second case documents a limitation we cannot fix here: when the context ends the retries mid-backoff, retryablehttp returns the last completed attempt's response, already closed, paired with a nil error.

Linear Ticket

< Fixes PIPE-3256 >

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@codecov

codecov Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.72%. Comparing base (9e62d0c) to head (f257660).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...l/transformer/user_transformer/user_transformer.go 88.46% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7252      +/-   ##
==========================================
- Coverage   80.27%   79.72%   -0.55%     
==========================================
  Files         600      601       +1     
  Lines       67034    67177     +143     
==========================================
- Hits        53811    53560     -251     
- Misses      10070    10449     +379     
- Partials     3153     3168      +15     

☔ 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.

@fracasula
fracasula merged commit 149e91a into master Aug 14, 2026
76 checks passed
@fracasula
fracasula deleted the pyt-contract-tests-v1-v2 branch August 14, 2026 09:48
mihir20 pushed a commit that referenced this pull request Aug 17, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.83.0-rc.1](v1.82.0...v1.83.0-rc.1)
(2026-08-17)


### Features

* add OriginalID and OriginalDestinationID to support replay event
transformations
([#7274](#7274))
([28d38e9](28d38e9))
* bingads integration tests
([#7253](#7253))
([fdb8c0a](fdb8c0a))
* **processor:** fork event processing for rsources pipelines
([#7235](#7235))
([707ea06](707ea06))


### Bug Fixes

* pyt contract tests data race
([#7247](#7247))
([9e62d0c](9e62d0c))


### Miscellaneous

* bump sqlconnect-go to v1.30.2
([#7251](#7251))
([f5d6175](f5d6175))
* **jobsdb:** multi-consumer compaction improvements
([#7248](#7248))
([b4af86c](b4af86c))
* pyt contract tests for candidate releases
([#7252](#7252))
([149e91a](149e91a))
* pyt contract tests for transformations auth
([#7239](#7239))
([ac4a859](ac4a859))
* **router:** support per-partition noOfWorkers override
([#7270](#7270))
([9d6f7cf](9d6f7cf))
* sync release v1.82.0 to main branch
([#7243](#7243))
([a6e29f2](a6e29f2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
mihir20 pushed a commit that referenced this pull request Aug 18, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.83.0](v1.82.0...v1.83.0)
(2026-08-17)


### Features

* add OriginalID and OriginalDestinationID to support replay event
transformations
([#7274](#7274))
([28d38e9](28d38e9))
* bingads integration tests
([#7253](#7253))
([fdb8c0a](fdb8c0a))
* **processor:** fork event processing for rsources pipelines
([#7235](#7235))
([707ea06](707ea06))


### Bug Fixes

* pyt contract tests data race
([#7247](#7247))
([9e62d0c](9e62d0c))


### Miscellaneous

* bump sqlconnect-go to v1.30.2
([#7251](#7251))
([f5d6175](f5d6175))
* **jobsdb:** multi-consumer compaction improvements
([#7248](#7248))
([b4af86c](b4af86c))
* pyt contract tests for candidate releases
([#7252](#7252))
([149e91a](149e91a))
* pyt contract tests for transformations auth
([#7239](#7239))
([ac4a859](ac4a859))
* **router:** support per-partition noOfWorkers override
([#7270](#7270))
([9d6f7cf](9d6f7cf))
* sync release v1.82.0 to main branch
([#7243](#7243))
([a6e29f2](a6e29f2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
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