tests: add a test to validate pause and resume feature#351
tests: add a test to validate pause and resume feature#351darthsuburbus wants to merge 1 commit intokubernetes-sigs:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: darthsuburbus The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @darthsuburbus! |
|
Hi @darthsuburbus. Thanks for your PR. I'm waiting for a kubernetes-sigs 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. DetailsInstructions 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. |
✅ Deploy Preview for agent-sandbox canceled.
|
| LabelSelector: "", | ||
| Conditions: []metav1.Condition{ | ||
| { | ||
| Message: "Pod does not exist, replicas is 0; Service Exists", |
There was a problem hiding this comment.
In your WaitForObject calls, you are asserting the exact Message string inside the Conditions array (e.g., "Pod does not exist, replicas is 0; Service Exists" and "Pod is Ready; Service Exists").
While these strictly match the controller's current output, testing against exact human-readable message strings is generally an anti-pattern in K8s e2e tests.
Suggestion: Modify your predicates.SandboxHasStatus (or create a new predicate) to only assert against Type, Status, and Reason. The Reason field (DependenciesReady / SandboxNotReady) is meant for programmatic consumption for example.
| }, | ||
| Resources: corev1.VolumeResourceRequirements{ | ||
| Requests: corev1.ResourceList{ | ||
| corev1.ResourceStorage: resource.MustParse("1Gi"), |
There was a problem hiding this comment.
nit: could we drop this down to 50Mi or 100Mi to be gentler on the test cluster's dynamic provisioner, depending on your storage class's minimums ?
|
|
||
| // execWriteFileToPod writes content to a file inside a running pod via kubectl exec. | ||
| // The -i flag is required to forward stdin to the remote process. | ||
| func execWriteFileToPod(ctx context.Context, namespace, podName, filePath, content string) error { |
There was a problem hiding this comment.
Currently, execWriteFileToPod and execReadFileFromPod use os/exec to invoke the local kubectl CLI. This introduces an environmental dependency on the test runner's kubectl binary and kubeconfig, which can lead to flaky tests in CI. Looking at the rest of our e2e test suite (like shutdown_test.go), we consistently rely on the client-go API via our test framework and avoid shelling out to external binaries.
Suggestion: Let's keep this test pure-Go and self-contained by using client-go to execute the read/write commands directly against the API server.
vicentefb
left a comment
There was a problem hiding this comment.
Thanks! This is a very valuable test that was missing. Overall, the logic is very solid. You're correctly simulating the exact behavior the controller executes when Replicas hits 0 (where it deletes the pod but retains the Sandbox CR and PVCs ), and then successfully validating the recovery. Left some comments.
Description
Add a e2e test that tests out the pause and resume functionality implemented in #82:
This test addresses the request made in #248.
Testing Done