Skip to content

tests: add a test to validate pause and resume feature#351

Open
darthsuburbus wants to merge 3 commits intokubernetes-sigs:mainfrom
darthsuburbus:topic/as/pvc-pers-e2e
Open

tests: add a test to validate pause and resume feature#351
darthsuburbus wants to merge 3 commits intokubernetes-sigs:mainfrom
darthsuburbus:topic/as/pvc-pers-e2e

Conversation

@darthsuburbus
Copy link

@darthsuburbus darthsuburbus commented Feb 27, 2026

Description

Fixes #248
Add a e2e test that tests out the pause and resume functionality implemented in #82:

  1. Create a Pod with a PVC and some generated data.
  2. Scale the replicas to 0, controller should delete the pod associated with the sandbox.
  3. Sandbox CR should remain consistent.
  4. Scale the replicas to 1, the controller will recreate the pod. Verify that the data is intact on the PVC.

This test addresses the request made in #248.

Testing Done

   pvc_persistence_test.go:68: WaitForObjectNotFound *v1.Namespace (/pvc-persistence-test-1772168327331581080) took 43.463444028s
--- PASS: TestPVCPersistenceAcrossReplicas (89.90s)

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: darthsuburbus
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
Copy link
Contributor

Welcome @darthsuburbus!

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 Feb 27, 2026
@k8s-ci-robot
Copy link
Contributor

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 /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.

Details

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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 27, 2026
@netlify
Copy link

netlify bot commented Feb 27, 2026

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit 6078e62
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/69a6cf9929ebfa0008a69767

@janetkuo janetkuo 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 Feb 27, 2026
Copy link
Member

@vicentefb vicentefb left a comment

Choose a reason for hiding this comment

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

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 3, 2026
@darthsuburbus darthsuburbus force-pushed the topic/as/pvc-pers-e2e branch from 8f8720b to 7103823 Compare March 3, 2026 12:08
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 3, 2026
@darthsuburbus
Copy link
Author

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.

Thanks for the thoughtful feedback, I've addressed all comments. I can squash the commits before merging but keeping them for ease of review for now.

@darthsuburbus darthsuburbus requested a review from vicentefb March 3, 2026 12:28
@@ -0,0 +1,295 @@
// Copyright 2026 The Kubernetes Authors.

Choose a reason for hiding this comment

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

we've stopped putting the dates on newly created files

Suggested change
// Copyright 2026 The Kubernetes Authors.
// Copyright The Kubernetes Authors.

(at least this is true in k/k... if this change results in a failure here you can feel free to disregard this comment)

}
opts := []cmp.Option{
cmpopts.IgnoreFields(metav1.Condition{}, "LastTransitionTime"),
cmpopts.IgnoreFields(metav1.Condition{}, "LastTransitionTime", "Message", "ObservedGeneration"),

Choose a reason for hiding this comment

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

why ignore observedGeneration? Seems that it may be a useful thing to check?


// Namespace
ns := &corev1.Namespace{}
ns.Name = fmt.Sprintf("pvc-persistence-test-%d", time.Now().UnixNano())

Choose a reason for hiding this comment

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

to make this easier to read, can we combine this with L64; just set the value when creating the object struct?

Comment on lines +72 to +75
pvcName := fmt.Sprintf("%s-%s", workspacesPVCTemplateName, pvcSandboxName)
pvc := &corev1.PersistentVolumeClaim{}
pvc.Name = pvcName
pvc.Namespace = ns.Name

Choose a reason for hiding this comment

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

same here; set these values in the object struct directly?

Comment on lines +138 to +140
pod := &corev1.Pod{}
pod.Name = pvcSandboxName
pod.Namespace = ns.Name

Choose a reason for hiding this comment

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

same here

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 6, 2026
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Details

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.

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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test and verify pause resume feature works correctly

5 participants