Skip to content

Commit 64a8e97

Browse files
committed
fixup! Add E2E test for backup repository startup validation
Use pod status checks instead of fixed delays Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
1 parent 4d4c002 commit 64a8e97

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

test/e2e/bsl-mgmt/startup_validation.go

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
. "github.com/onsi/ginkgo/v2"
2626
. "github.com/onsi/gomega"
2727
appsv1api "k8s.io/api/apps/v1"
28+
corev1api "k8s.io/api/core/v1"
2829
"k8s.io/apimachinery/pkg/types"
2930
"sigs.k8s.io/controller-runtime/pkg/client"
3031

@@ -176,6 +177,25 @@ func BackupRepositoryStartupValidation() {
176177
}
177178
return d.Status.ReadyReplicas
178179
}, 2*time.Minute, 5*time.Second).Should(Equal(int32(0)))
180+
181+
// Ensure no Velero pods are running
182+
Eventually(func() int {
183+
podList := &corev1api.PodList{}
184+
err := veleroCfg.ClientToInstallVelero.Kubebuilder.List(oneHourTimeout, podList,
185+
client.InNamespace(veleroCfg.VeleroNamespace),
186+
client.MatchingLabels{"deploy": "velero"})
187+
if err != nil {
188+
return -1
189+
}
190+
runningCount := 0
191+
for _, pod := range podList.Items {
192+
if pod.Status.Phase == corev1api.PodRunning {
193+
runningCount++
194+
}
195+
}
196+
fmt.Printf("Velero pods running: %d\n", runningCount)
197+
return runningCount
198+
}, 30*time.Second, 2*time.Second).Should(Equal(0), "Velero pods should be fully terminated")
179199
})
180200

181201
By("Modify BSL configuration (change prefix)", func() {
@@ -219,8 +239,28 @@ func BackupRepositoryStartupValidation() {
219239
return d.Status.ReadyReplicas
220240
}, 2*time.Minute, 5*time.Second).Should(Equal(int32(1)))
221241

222-
// Wait a bit for controller to start
223-
time.Sleep(5 * time.Second)
242+
// Ensure Velero pod is fully running and ready
243+
Eventually(func() bool {
244+
podList := &corev1api.PodList{}
245+
err := veleroCfg.ClientToInstallVelero.Kubebuilder.List(oneHourTimeout, podList,
246+
client.InNamespace(veleroCfg.VeleroNamespace),
247+
client.MatchingLabels{"deploy": "velero"})
248+
if err != nil || len(podList.Items) != 1 {
249+
return false
250+
}
251+
pod := podList.Items[0]
252+
if pod.Status.Phase != corev1api.PodRunning {
253+
return false
254+
}
255+
// Check all containers are ready
256+
for _, condition := range pod.Status.Conditions {
257+
if condition.Type == corev1api.PodConditionType("Ready") && condition.Status == corev1api.ConditionTrue {
258+
fmt.Println("Velero pod is fully ready")
259+
return true
260+
}
261+
}
262+
return false
263+
}, 1*time.Minute, 2*time.Second).Should(BeTrue(), "Velero pod should be ready")
224264

225265
// Force a reconciliation by adding/updating a label on the repository
226266
// This ensures the startup validation runs

0 commit comments

Comments
 (0)