Skip to content

Conversation

@shrutiyam-glitch
Copy link
Contributor

@shrutiyam-glitch shrutiyam-glitch commented Nov 14, 2025

Adds e2e test for the python runtime sandbox example.
Test file: test/e2e/pythonruntime_test.go
Scenarios covered -

  • applies sandbox(python-runtime-sandbox) manifest directly
  • Applies sandbox template and sandbox claim and creates a python runtime sandbox
  • Applies sandbox warmpool and creates a python runtime

Test cases -

  • Tests port forwarding to the sandbox - general health check
  • ​​executes “hello world”

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 14, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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

@netlify
Copy link

netlify bot commented Nov 14, 2025

Deploy Preview for agent-sandbox ready!

Name Link
🔨 Latest commit 92a38e0
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/6924d2ab47649e000868356a
😎 Deploy Preview https://deploy-preview-161--agent-sandbox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Nov 14, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @shrutiyam-glitch!

It looks like this is your first PR to kubernetes-sigs/agent-sandbox 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/agent-sandbox has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 14, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @shrutiyam-glitch. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 14, 2025
@shrutiyam-glitch shrutiyam-glitch marked this pull request as draft November 14, 2025 18:34
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 14, 2025
@tomergee
Copy link
Contributor

tomergee commented Nov 17, 2025

Thank you @shrutiyam-glitch for the PR, can you also add a test for python-runtime using gVisor? It can be based on "e2e-pytest-template" by changing the runtime in the template. This depends on other open PRs for the test to check if it works (#150 and #159)

@janetkuo
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 17, 2025
@janetkuo
Copy link
Member

@shrutiyam-glitch please sign the CLA, ref #161 (comment)

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 17, 2025
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 18, 2025
}

portForwardCtx, portForwardCancel := context.WithCancel(ctx)
h.PortForward(portForwardCtx, podID, 8888, 8888)
Copy link
Contributor

Choose a reason for hiding this comment

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

Check if the runtime is set so runsc or kata-qemu and if so skip the port forwarding part. TODO - After the python e2e tests are merged test via gateway

@shrutiyam-glitch shrutiyam-glitch marked this pull request as ready for review November 19, 2025 18:56
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 19, 2025
Copy link
Contributor

@igooch igooch left a comment

Choose a reason for hiding this comment

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

Good work, left a new comments.

spec:
containers:
- name: python-sandbox
image: kind.local/python-runtime-sandbox:%s
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above on hard-coding the registry.

spec:
containers:
- name: python-sandbox
image: kind.local/python-runtime-sandbox:%s
Copy link
Contributor

Choose a reason for hiding this comment

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

This works for the CI test, however if someone tests locally with their own registry for the image this will break the test. I'd recommend if possible passing through the IMAGE_PREFIX instead of hard coded kind.local.

"sigs.k8s.io/agent-sandbox/test/e2e/framework"
)

const sandboxManifest = `
Copy link
Contributor

Choose a reason for hiding this comment

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

For a few manifests this is fine. If we have more than that you'll want to pull these out into separate .yaml files.

cl.Helper()
// Static 30 second timeout, this can be adjusted if needed
timeoutCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
timeoutCtx, cancel := context.WithTimeout(ctx, 60*time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should update this from be configurable, and make the default timeout a constant defined at the top of the file. That way each tests can have an appropriate timeout. So something like:

    var cancel context.CancelFunc
	if _, ok := ctx.Deadline(); !ok {
		ctx, cancel = context.WithTimeout(ctx, DefaultTimeout)
		defer cancel()
	}

And then tests either use the default timeout, or pass a context with a longer timeout:

// Uses default timeout
cl.WaitForObject(ctx, sandbox, predicates.ReadyConditionIsTrue)
// Custom timeout case for slower operations like warmPool
timeoutCtx, cancel := context.WithTimeout(ctx, 1*time.Minute)
defer cancel()
cl.WaitForObject(timeoutCtx, warmPool, predicates.ReadyConditionIsTrue)

Comment on lines 332 to 333
for {
select {
Copy link
Contributor

Choose a reason for hiding this comment

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

The outer for loop + select with cases can be replaced by a wait from the package k8s.io/apimachinery/pkg/util/wait similar to:

return wait.PollUntilContextTimeout(ctx, 2*time.Second, 1*time.Minute, true, func(ctx context.Context) (bool, error) {

return fmt.Errorf("non-200 response from execute endpoint: %d", response.StatusCode)
}

b, err := io.ReadAll(response.Body)
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to avoid one letter variables.

return fmt.Errorf("error reading response body from execute endpoint: %w", err)
}

// Basic check for stdout - more robust JSON parsing could be added if needed
Copy link
Contributor

Choose a reason for hiding this comment

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

Like you mention here, it's a bit more code, but I'd recommend unmarshalling the response into a struct.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 24, 2025
@k8s-ci-robot
Copy link
Contributor

@shrutiyam-glitch: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
presubmit-agent-sandbox-e2e-test 92a38e0 link true /test presubmit-agent-sandbox-e2e-test

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants