-
Notifications
You must be signed in to change notification settings - Fork 54
Python runtime sandbox and Python sdk e2e test #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Python runtime sandbox and Python sdk e2e test #161
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: shrutiyam-glitch 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 |
✅ Deploy Preview for agent-sandbox ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Welcome @shrutiyam-glitch! |
|
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 Once the patch is verified, the new status will be reflected by the 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. |
|
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) |
|
/ok-to-test |
|
@shrutiyam-glitch please sign the CLA, ref #161 (comment) |
4806373 to
f1be5f0
Compare
| } | ||
|
|
||
| portForwardCtx, portForwardCancel := context.WithCancel(ctx) | ||
| h.PortForward(portForwardCtx, podID, 8888, 8888) |
There was a problem hiding this comment.
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
igooch
left a comment
There was a problem hiding this 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.
test/e2e/pythonruntime_test.go
Outdated
| spec: | ||
| containers: | ||
| - name: python-sandbox | ||
| image: kind.local/python-runtime-sandbox:%s |
There was a problem hiding this comment.
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.
test/e2e/pythonruntime_test.go
Outdated
| spec: | ||
| containers: | ||
| - name: python-sandbox | ||
| image: kind.local/python-runtime-sandbox:%s |
There was a problem hiding this comment.
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 = ` |
There was a problem hiding this comment.
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.
test/e2e/framework/client.go
Outdated
| 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) |
There was a problem hiding this comment.
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)
test/e2e/framework/client.go
Outdated
| for { | ||
| select { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
|
@shrutiyam-glitch: The following test failed, say
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. |
Adds e2e test for the python runtime sandbox example.
Test file: test/e2e/pythonruntime_test.go
Scenarios covered -
Test cases -