mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-22 12:43:32 +09:00
test(backups): pin a failed RestoreJob listing in the MariaDB cleanup
A RestoreJob listing that fails says nothing about whether a restore reads the dump. Swallowing that error left the whole suite green, while it would let the cleanup delete the dump under a running restore. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
This commit is contained in:
1 parent
f2507b4b84
commit
a6a704768c
1 file changed
+15
@@ -866,6 +866,21 @@ func TestCleanupMariaDBBackup_WaitsForARestoreFromIt(t *testing.T) {
|
||||
t.Fatalf("got res=%+v err=%v removed=%v, want the Backup held while the restore runs", res, err, bucket.removed)
|
||||
}
|
||||
})
|
||||
t.Run("a failed listing deletes nothing", func(t *testing.T) {
|
||||
bucket := &fakeS3Bucket{}
|
||||
r, _ := cleanupReconciler(t, bucket, cleanupOperatorBackup(t), s3CredsSecret("tenant", "creds"), tenantNamespace())
|
||||
r.APIReader = interceptor.NewClient(newMariaDBStrategyTestClient(t).(client.WithWatch), interceptor.Funcs{
|
||||
List: func(ctx context.Context, c client.WithWatch, list client.ObjectList, opts ...client.ListOption) error {
|
||||
if _, ok := list.(*backupsv1alpha1.RestoreJobList); ok {
|
||||
return errors.New("etcdserver: request timed out")
|
||||
}
|
||||
return c.List(ctx, list, opts...)
|
||||
},
|
||||
})
|
||||
if _, err := r.cleanupMariaDBBackup(context.Background(), cleanupBackup(cleanupDumpName)); err == nil || len(bucket.removed) != 0 || !operatorBackupExists(t, r.Client) {
|
||||
t.Fatalf("err=%v removed=%v, want the error returned and nothing deleted", err, bucket.removed)
|
||||
}
|
||||
})
|
||||
t.Run("finished restores and restores of other Backups do not hold it", func(t *testing.T) {
|
||||
bucket := &fakeS3Bucket{}
|
||||
r, _ := cleanupReconciler(t, bucket, cleanupOperatorBackup(t), s3CredsSecret("tenant", "creds"), tenantNamespace(),
|
||||
|
||||
Reference in new issue
Block a user