Skip to content

How to test controller's reconciliation function that requeues? #3290

Closed Answered by camilamacedo86
hellt asked this question in Support
Discussion options

You must be logged in to vote

Hi @hellt ,

  1. Testing Reconciliation with Requeue

If I understand your question when testing reconciliation functions that requeue, you can simulate the requeue behavior by repeatedly invoking the reconciliation function until it no longer returns a requeue result. This simulates what would happen in a real cluster.

With Ginkgo and ENVTEST, I think you could do something like:

```go
It("should reconcile and handle requeue", func() {
    req := reconcile.Request{
        NamespacedName: types.NamespacedName{Name: "yourCRName", Namespace: "default"},
    }
    // Using Eventually to repeatedly reconcile until no requeue is returned
    Eventually(func() bool {
        res, err := reconciler…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by camilamacedo86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
2 participants