Skip to content

refactor(test): mutate test manifests structurally instead of using sed#896

Open
chw120 wants to merge 2 commits into
kubernetes-sigs:mainfrom
chw120:fix-router-yaml-mutation
Open

refactor(test): mutate test manifests structurally instead of using sed#896
chw120 wants to merge 2 commits into
kubernetes-sigs:mainfrom
chw120:fix-router-yaml-mutation

Conversation

@chw120

@chw120 chw120 commented May 30, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it

This PR addresses feedback from Barney in PR 755 by replacing fragile string replacements and sed mutations with robust structural YAML parsing and path-based updates.

Specifically, the following changes were made:

  • Added a Python utility: A new utility dev/tools/mutate_yaml.py has been introduced to parse and update template and router manifests structurally.
  • Updated shell script: run-test-kind.sh now uses mutate_yaml.py to modify manifests on the fly without changing source files in-place.
  • Improved E2E tests: test_e2e_python_sdk.py has been updated to use yaml.safe_load_all for structured path-based updates.

Which issue(s) this PR is related to

Follow up on #755 (comment)

Release Note

Refactored manifest mutation in tests to use structural YAML parsing instead of string-based replacements for better robustness.

Address Barney's feedback in PR 755 by replacing fragile string replacements/sed mutations with structured structural YAML parsing and path-based updates.
Specifically:
- Add a robust Python utility dev/tools/mutate_yaml.py to parse and update template and router manifests structurally.
- Modify run-test-kind.sh to use mutate_yaml.py on the fly without modifying the source files in-place.
- Update test_e2e_python_sdk.py to use structured yaml.safe_load_all and path-based updates.
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: chw120
Once this PR has been reviewed and has the lgtm label, please assign janetkuo for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from barney-s and igooch May 30, 2026 01:23
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 30, 2026
@netlify

netlify Bot commented May 30, 2026

Copy link
Copy Markdown

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit bdb992b
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/6a1a56b8b0460300089ccc61

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 30, 2026
@janetkuo janetkuo requested a review from Copilot May 30, 2026 02:00

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.

Pull request overview

This PR refactors test manifest mutation to use structured YAML parsing rather than string replacement, improving robustness for Python SDK E2E and kind gateway test setup.

Changes:

  • Adds dev/tools/mutate_yaml.py for path-based YAML manifest mutation.
  • Updates run-test-kind.sh to pipe mutated manifests directly to kubectl apply.
  • Updates Python E2E router deployment setup to mutate YAML documents structurally.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
dev/tools/mutate_yaml.py Adds a CLI helper for mutating SandboxTemplate and sandbox-router manifests.
clients/python/agentic-sandbox-client/gateway-kind/run-test-kind.sh Replaces in-place sed mutations with the new YAML mutator during kind setup.
test/e2e/clients/python/test_e2e_python_sdk.py Replaces router manifest string replacements with structured YAML updates.

Comment thread clients/python/agentic-sandbox-client/gateway-kind/run-test-kind.sh Outdated
Comment thread dev/tools/mutate_yaml.py
Comment thread dev/tools/mutate_yaml.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ready-for-review size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

4 participants