Repository navigation
chore: add contract tests for test endpoints in pytransformer - #7147
Conversation
fracasula
left a comment
There was a problem hiding this comment.
Approving with some small asks 👍
| g.mu.Lock() | ||
| defer g.mu.Unlock() | ||
| g.fnURLs[name] = url | ||
| if container != nil { |
| return statusCode, respBody | ||
| } | ||
|
|
||
| decodeFlow := func(t *testing.T, body []byte) testFlowResponse { |
There was a problem hiding this comment.
Can we cleanup the TestPyTransformerTestEndpointsa bit? These can easily be helpers that live outside the TestPyTransformerTestEndpoints function. Also it'd be beneficial if we can start the test file with the actual tests. We don't care much about the setup so having to open a test file just to scroll until we get to what we need isn't ideal. The goal would be have the test as concise and readable as possible because these are already difficult to review.
| require.Equal(t, decodeError(t, oldBody), decodeError(t, newBody)) | ||
| }) | ||
|
|
||
| t.Run("should return the verbatim missing-events error", func(t *testing.T) { |
There was a problem hiding this comment.
Aren't we missing invalid code that shouldn't compile for "/transformation/testRun"?
| // never comes up ("connection refused"). A per-container namespace keeps | ||
| // each 8081 private. host.docker.internal (host-gateway) lets the function | ||
| // reach the host's config backend from inside the namespace. | ||
| container, err := pool.RunWithOptions(&dockertest.RunOptions{ |
There was a problem hiding this comment.
bc_helpers_test.go already centralizes the Linux-vs-macOS docker quirks:
newContainerConfig (host networking on Linux, bridge + host.docker.internal +
PortBindings on macOS), containerConfig.url(), portStr(), and toContainerURL() /
dockertesthelper.ToInternalDockerHost. The existing single-container startOpenFaasFlask (bc_helpers_test.go:409) uses them, and the pytransformer container solves its metrics-port collision by allocating a unique METRICS_PORT env (bc_helpers_test.go:503-508).
The new startOpenFaasFlaskFprocess instead hardcodes the macOS-style bridge config for all platforms, re-implementing newContainerConfig's darwin branch inline.
Fix: Give newContainerConfig a "force bridge networking regardless of GOOS" option and build startOpenFaasFlaskFprocess on top of it (reusing cfg.ExtraHosts, cfg.PortBindings, cfg.url()); route the fprocess host rewrite through the shared ToInternalDockerHost helper so
the address-rewriting rules live in one place.
There was a problem hiding this comment.
I asked specifially the agent to look into this because I remember that we already had helpers that differentiates between Darwin and Linux so we might be duplicating logic unnecessarily here.
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
…points 🔒 Scanned for secrets using gitleaks 8.28.0
…ints 🔒 Scanned for secrets using gitleaks 8.28.0
…t tests 🔒 Scanned for secrets using gitleaks 8.28.0
…sion 🔒 Scanned for secrets using gitleaks 8.28.0
…k-base 🔒 Scanned for secrets using gitleaks 8.28.0
…ntainers 🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
…ner networking for Flask tests 🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
…treamline test environment setup 🔒 Scanned for secrets using gitleaks 8.28.0
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7147 +/- ##
==========================================
- Coverage 79.65% 79.62% -0.04%
==========================================
Files 595 595
Lines 66095 66095
==========================================
- Hits 52649 52628 -21
- Misses 10331 10356 +25
+ Partials 3115 3111 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…n test 🔒 Scanned for secrets using gitleaks 8.28.0
🔒 Scanned for secrets using gitleaks 8.28.0
# Description Syncing release v1.80.0 to main branch **WARNING: Do NOT rewrite git history and ALWAYS use a "Merge Commit" for merging!** **↓↓ Please review and edit commit overrides before merging ↓↓** BEGIN_COMMIT_OVERRIDE chore: add contract tests for test endpoints in pytransformer (#7147) END_COMMIT_OVERRIDE
🤖 I have created a release *beep* *boop* --- ## [1.81.0-rc.1](v1.80.0...v1.81.0-rc.1) (2026-07-20) ### Features * run python transformation tests on ephemeral per-request pyt deployments ([#7177](#7177)) ([1008ae7](1008ae7)) * support partition migration job fanout per jobsdb ([#7141](#7141)) ([be42e48](be42e48)) ### Bug Fixes * abort snowpipe events on channel bad request ([#7118](#7118)) ([6c08584](6c08584)) * avoid redundant transformer statTags unmarshalling ([#7182](#7182)) ([c3c283c](c3c283c)) * classify reverse-ETL sources from config for MAR metering ([#7159](#7159)) ([fa7870f](fa7870f)) * detect server-side snowpipe channel failures via per-channel status at stuck threshold ([#7166](#7166)) ([581410c](581410c)) * kafkamanager compilation error ([#7189](#7189)) ([1fb7f6e](1fb7f6e)) * **kafka:** support insecure TLS skip verify config ([#7022](#7022)) ([d01574f](d01574f)) * preserve order when overflowing snowpipe insert batches ([#7178](#7178)) ([9c01fa0](9c01fa0)) * quote postgres warehouse ddl identifiers ([#7127](#7127)) ([5aeb481](5aeb481)) * **router:** emit invalid payload metric ([#7168](#7168)) ([6e2009a](6e2009a)) * update null to #N/A for salesforce bulk upload ([#7151](#7151)) ([1dffd93](1dffd93)) * **warehouse:** use pod identity for rudder-storage flow; keep S3-copy user fallback for user S3 destinations ([#7167](#7167)) ([3f9aa32](3f9aa32)) ### Miscellaneous * add contract tests for test endpoints in pytransformer ([#7147](#7147)) ([3b210ec](3b210ec)) * bump compose-test to v0.1.5 to remediate pgx CVE-2026-33815 ([#7162](#7162)) ([7672f96](7672f96)) * **deps:** bump actions/checkout from 6.0.3 to 7.0.0 ([#7132](#7132)) ([d453c93](d453c93)) * **deps:** bump actions/setup-go from 6.4.0 to 6.5.0 ([#7150](#7150)) ([75d9648](75d9648)) * **deps:** bump aws-actions/amazon-ecr-login from 2.1.5 to 2.1.6 ([#7109](#7109)) ([7b2a859](7b2a859)) * **deps:** bump aws-actions/configure-aws-credentials from 6.2.0 to 6.2.2 ([#7152](#7152)) ([c984268](c984268)) * **deps:** bump golangci/golangci-lint-action from 9.2.1 to 9.3.0 ([#7170](#7170)) ([4565d25](4565d25)) * **deps:** bump the frequent group across 1 directory with 4 updates ([#6891](#6891)) ([88a0ddf](88a0ddf)) * support compression in bqstream destinations ([#7142](#7142)) ([0694f12](0694f12)) --- 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>
🤖 I have created a release *beep* *boop* --- ## [1.81.0](v1.80.0...v1.81.0) (2026-07-20) ### Features * run python transformation tests on ephemeral per-request pyt deployments ([#7177](#7177)) ([1008ae7](1008ae7)) * support partition migration job fanout per jobsdb ([#7141](#7141)) ([be42e48](be42e48)) ### Bug Fixes * abort snowpipe events on channel bad request ([#7118](#7118)) ([6c08584](6c08584)) * avoid redundant transformer statTags unmarshalling ([#7182](#7182)) ([c3c283c](c3c283c)) * classify reverse-ETL sources from config for MAR metering ([#7159](#7159)) ([fa7870f](fa7870f)) * detect server-side snowpipe channel failures via per-channel status at stuck threshold ([#7166](#7166)) ([581410c](581410c)) * kafkamanager compilation error ([#7189](#7189)) ([1fb7f6e](1fb7f6e)) * **kafka:** support insecure TLS skip verify config ([#7022](#7022)) ([d01574f](d01574f)) * preserve order when overflowing snowpipe insert batches ([#7178](#7178)) ([9c01fa0](9c01fa0)) * quote postgres warehouse ddl identifiers ([#7127](#7127)) ([5aeb481](5aeb481)) * **router:** emit invalid payload metric ([#7168](#7168)) ([6e2009a](6e2009a)) * update null to #N/A for salesforce bulk upload ([#7151](#7151)) ([1dffd93](1dffd93)) * **warehouse:** use pod identity for rudder-storage flow; keep S3-copy user fallback for user S3 destinations ([#7167](#7167)) ([3f9aa32](3f9aa32)) ### Miscellaneous * add contract tests for test endpoints in pytransformer ([#7147](#7147)) ([3b210ec](3b210ec)) * bump compose-test to v0.1.5 to remediate pgx CVE-2026-33815 ([#7162](#7162)) ([7672f96](7672f96)) * **deps:** bump actions/checkout from 6.0.3 to 7.0.0 ([#7132](#7132)) ([d453c93](d453c93)) * **deps:** bump actions/setup-go from 6.4.0 to 6.5.0 ([#7150](#7150)) ([75d9648](75d9648)) * **deps:** bump aws-actions/amazon-ecr-login from 2.1.5 to 2.1.6 ([#7109](#7109)) ([7b2a859](7b2a859)) * **deps:** bump aws-actions/configure-aws-credentials from 6.2.0 to 6.2.2 ([#7152](#7152)) ([c984268](c984268)) * **deps:** bump golangci/golangci-lint-action from 9.2.1 to 9.3.0 ([#7170](#7170)) ([4565d25](4565d25)) * **deps:** bump the frequent group across 1 directory with 4 updates ([#6891](#6891)) ([88a0ddf](88a0ddf)) * support compression in bqstream destinations ([#7142](#7142)) ([0694f12](0694f12)) --- 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>
Description
Adds a contract-test suite that pins the wire contract of the four control-plane transformation-test endpoints, comparing the new architecture (
rudder-pytransformer) against the old architecture(
rudder-transformerin test mode) byte-for-byte.These tests guard the exact
usertransformer.Client→pytpath thatcpservice.Forwarduses in production, so any behavioral drift between the old and new architectures is caught before it reaches thecontrol plane.
Endpoints under contract
rudder-pytransformer)rudder-transformer)POST /testPOST /transformation/testPOST /testRunPOST /transformation/testRunPOST /test-libraryPOST /transformationLibrary/testPOST /extract-libsPOST /extractLibsHow it works
rudder-transformerruns withTRANSFORMER_TEST_MODE=true: it deploys a per-request OpenFaaS function whosefprocesscarries the inline code, invokes it, then deletes it. ASTroutes hit a long-lived
fn-astfunction.POST /system/functionsstarts a realopenfaas-flask-basecontainer so the inline code actuallyexecutes; invocations route to the per-function container and
DELETEpurges it.usertransformer.Client.Test/TestRun/TestLibrary/ExtractLibs— the same methodscpservice.Forwardcalls in production — covering the exact client →pytpath.
pytsurfaces the runtime's wording ("Import of 'os' is not allowed. ...") rather thanfn-ast's(
"Unpermitted import(s). ...") — the runtime is treated as the source of truth.Coverage
Roughly 35 subtests spanning the four endpoints, including:
/test— inline code with logs, library fetching from the config backend,getCredentialexposure, per-event errors kept inline at HTTP 200, duplicatemessageIds, metadata withoutmessageId,compile errors (HTTP 400), verbatim missing-code/missing-events errors, frame-introspection code, library-fetch failures.
/testRun— metadata echo per event, dependency/library/credential resolution, per-event errors kept inline with metadata, duplicatemessageIds, verbatim missing-code/missing-events errors./test-library— import maps for valid code, rejection of non-whitelisted /urllib.request/ relative imports (matching the old runtime), module-path keying, syntax errors, verbatim missing-codeerror.
/extract-libs— non-whitelisted extraction with validation off, additional libraries under validation, dotted imports, rejection of relative and non-whitelisted imports, verbatim missing-codeerror.
startRudderTransformernow accepts optional extra environment variables (e.g.TRANSFORMER_TEST_MODE=true).rudder-pytransformercontainer pinned to tagpr-109for this suite; to move tomainbefore merging this).Linear Ticket
pipe-3164
Security