Skip to content

Commit

Permalink
chore: fix unstable test of restore controller
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei committed Oct 20, 2023
1 parent d6a5266 commit 7a68d68
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controllers/dataprotection/restore_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ package dataprotection
import (
"fmt"
"strconv"
"strings"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/types"

batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -243,11 +245,17 @@ var _ = Describe("Restore Controller test", func() {
By("mock jobs are completed")
mockRestoreJobsCompleted(restore)

var firstJobName string
Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(restore), func(g Gomega, r *dpv1alpha1.Restore) {
g.Expect(r.Status.Actions.PrepareData).ShouldNot(BeEmpty())
g.Expect(r.Status.Actions.PrepareData[0].Status).Should(Equal(dpv1alpha1.RestoreActionCompleted))
firstJobName = strings.ReplaceAll(r.Status.Actions.PrepareData[0].ObjectKey, "Job/", "")
})).Should(Succeed())

By("wait for deleted first job")
Eventually(testapps.CheckObjExists(&testCtx,
types.NamespacedName{Name: firstJobName, Namespace: testCtx.DefaultNamespace}, &batchv1.Job{}, false)).Should(Succeed())

By("after the first job is completed, next job will be created")
checkJobAndPVCSCount(restore, 1, replicas, startingIndex)

Expand Down

0 comments on commit 7a68d68

Please sign in to comment.