Skip to content

Add e2e tests for warmpool rollout #562

Open
shrutiyam-glitch wants to merge 2 commits intokubernetes-sigs:mainfrom
shrutiyam-glitch:e2e-rollout-test
Open

Add e2e tests for warmpool rollout #562
shrutiyam-glitch wants to merge 2 commits intokubernetes-sigs:mainfrom
shrutiyam-glitch:e2e-rollout-test

Conversation

@shrutiyam-glitch
Copy link
Copy Markdown
Contributor

The added tests verify the behavior of the SandboxWarmPool controller when its associated SandboxTemplate is updated, ensuring that sandboxes are handled correctly according to the configured UpdateStrategy.

Follow up on #347.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 9, 2026

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit 65255b7
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/69d7d7f1b30e910008c97942

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 9, 2026
@k8s-ci-robot k8s-ci-robot requested a review from justinsb April 9, 2026 16:46
@k8s-ci-robot
Copy link
Copy Markdown
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 igooch 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 a review from vicentefb April 9, 2026 16:46
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 9, 2026
Copy link
Copy Markdown

@codebot-robot codebot-robot left a comment

Choose a reason for hiding this comment

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

Overall, this PR introduces solid E2E test coverage for the SandboxWarmPool rollout behavior and update strategies. However, there are a few areas where the tests can be improved to ensure stability, prevent false positives, and increase maintainability:

  1. Update Conflicts: Directly calling .Get() followed immediately by .Update() on Kubernetes resources is susceptible to OptimisticLockErrors if a controller updates the object's status concurrently. Consider using retry.RetryOnConflict.
  2. Timing, Flakiness, and False Positives:
    • Avoid using time.Sleep to wait for reconciliations, as it slows down tests and introduces flakiness. Wait for the ObservedGeneration to update instead.
    • Direct usage of tc.List might fail if the local informer cache is slightly delayed. Wrapping it in require.Eventually is a safer approach used elsewhere in your tests.
    • The verifySandboxStaysSame function may assert the state before the controller has processed the template update, which would falsely pass even if a bug exists.
  3. Performance: When iterating over sandboxList.Items, iterate by index (&sandboxList.Items[i]) instead of by range value to prevent copying large objects and avoid pointer issues.
  4. Code Cleanup and Maintainability:
    • Consider extracting repetitive logic, such as the block used to find the active sandbox, into helper functions.
    • Clean up unused function parameters, such as _ *framework.TestContext in your helper functions.

Please review the detailed inline comments for specific suggestions.

(This review was generated by Overseer)

})
}

func verifySandboxStaysSame(t *testing.T, tc *framework.TestContext, ns *corev1.Namespace, poolSandboxName string, sandboxWarmpoolID types.NamespacedName) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This check is evaluated immediately after updating the template. Because the controller processes updates asynchronously, this assertion may succeed before the controller has even processed the update, leading to a false positive test pass. You should add a small delay (e.g., time.Sleep as used in TestWarmPoolRolloutMetadataUpdate) or verify that the warmpool's ObservedGeneration (if tracked) has updated to ensure the controller has genuinely decided to keep the sandbox unchanged.

return true
}
if err != nil {
return false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we log the error t.Logf here so that it's easier to debug please

verify: verifySandboxStaysSame,
},
{
name: "onreplenish",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

are you also testing that it creates a new sandbox and that sandbox has the updated spec ? i think the full lifecycle would be useful to test out here otherwise rollout could be broken without us knowing

templateA := createSandboxTemplate(tc, ns, "template-a")
require.NoError(t, tc.CreateWithCleanup(t.Context(), templateA))

templateB := createSandboxTemplate(tc, ns, "template-b")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i know that templateA and templateB have identical specs, but down in this test are you checking that the annotation SandboxTemplateRefAnnotation is also being updated ?

"sigs.k8s.io/controller-runtime/pkg/client"
)

func createSandboxTemplate(_ *framework.TestContext, ns *corev1.Namespace, name string) *extensionsv1alpha1.SandboxTemplate {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

super nit: do we need _ *framework.TestContext since it's not being used ?

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

4 participants