Skip to content

Commit

Permalink
fixup! fix: CI flakes
Browse files Browse the repository at this point in the history
Signed-off-by: Mateus Oliveira <[email protected]>
  • Loading branch information
mateusoliveira43 committed Dec 11, 2024
1 parent a67f159 commit ec40c69
Showing 1 changed file with 95 additions and 86 deletions.
181 changes: 95 additions & 86 deletions internal/controller/nonadminbackup_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ var _ = ginkgo.Describe("Test single reconciles of NonAdminBackup Reconcile func
controllerutil.RemoveFinalizer(nonAdminBackup, finalizer)
}
gomega.Expect(k8sClient.Update(ctx, nonAdminBackup)).To(gomega.Succeed())
gomega.Expect(k8sClient.Delete(ctx, nonAdminBackup)).To(gomega.Succeed())
if nonAdminBackup.GetDeletionTimestamp().IsZero() {
gomega.Expect(k8sClient.Delete(ctx, nonAdminBackup)).To(gomega.Succeed())
}
}
gomega.Expect(deleteTestNamespaces(ctx, nonAdminObjectNamespace, oadpNamespace)).To(gomega.Succeed())
})
Expand Down Expand Up @@ -414,59 +416,59 @@ var _ = ginkgo.Describe("Test single reconciles of NonAdminBackup Reconcile func
},
},
nonAdminBackupExpectedDeleted: true,
result: reconcile.Result{Requeue: true},
}),
ginkgo.Entry("When triggered by NonAdminBackup deleteNonAdmin spec field with Finalizer set, should not delete NonAdminBackup as it's waiting for finalizer to be removed", nonAdminBackupSingleReconcileScenario{
addFinalizer: true,
nonAdminBackupSpec: nacv1alpha1.NonAdminBackupSpec{
BackupSpec: &velerov1.BackupSpec{},
DeleteBackup: true,
},
nonAdminBackupPriorStatus: &nacv1alpha1.NonAdminBackupStatus{
Phase: nacv1alpha1.NonAdminPhaseCreated,
Conditions: []metav1.Condition{
{
Type: string(constant.NonAdminConditionAccepted),
Status: metav1.ConditionTrue,
Reason: "BackupAccepted",
Message: "backup accepted",
LastTransitionTime: metav1.NewTime(time.Now()),
},
{
Type: string(constant.NonAdminConditionQueued),
Status: metav1.ConditionTrue,
Reason: "BackupScheduled",
Message: "Created Velero Backup object",
LastTransitionTime: metav1.NewTime(time.Now()),
},
},
},
nonAdminBackupExpectedStatus: nacv1alpha1.NonAdminBackupStatus{
Phase: nacv1alpha1.NonAdminPhaseDeleting,
Conditions: []metav1.Condition{
{
Type: string(constant.NonAdminConditionAccepted),
Status: metav1.ConditionTrue,
Reason: "BackupAccepted",
Message: "backup accepted",
},
{
Type: string(constant.NonAdminConditionQueued),
Status: metav1.ConditionTrue,
Reason: "BackupScheduled",
Message: "Created Velero Backup object",
},
{
Type: string(constant.NonAdminConditionDeleting),
Status: metav1.ConditionTrue,
Reason: "DeletionPending",
Message: "backup accepted for deletion",
},
},
},
nonAdminBackupExpectedDeleted: false,
result: reconcile.Result{Requeue: true},
result: reconcile.Result{},
}),
// ginkgo.Entry("When triggered by NonAdminBackup deleteNonAdmin spec field with Finalizer set, should not delete NonAdminBackup as it's waiting for finalizer to be removed", nonAdminBackupSingleReconcileScenario{
// nonAdminBackupSpec: nacv1alpha1.NonAdminBackupSpec{
// BackupSpec: &velerov1.BackupSpec{},
// DeleteBackup: true,
// },
// nonAdminBackupPriorStatus: &nacv1alpha1.NonAdminBackupStatus{
// Phase: nacv1alpha1.NonAdminPhaseCreated,
// Conditions: []metav1.Condition{
// {
// Type: string(constant.NonAdminConditionAccepted),
// Status: metav1.ConditionTrue,
// Reason: "BackupAccepted",
// Message: "backup accepted",
// LastTransitionTime: metav1.NewTime(time.Now()),
// },
// {
// Type: string(constant.NonAdminConditionQueued),
// Status: metav1.ConditionTrue,
// Reason: "BackupScheduled",
// Message: "Created Velero Backup object",
// LastTransitionTime: metav1.NewTime(time.Now()),
// },
// },
// },
// nonAdminBackupExpectedStatus: nacv1alpha1.NonAdminBackupStatus{
// Phase: nacv1alpha1.NonAdminPhaseDeleting,
// Conditions: []metav1.Condition{
// {
// Type: string(constant.NonAdminConditionAccepted),
// Status: metav1.ConditionTrue,
// Reason: "BackupAccepted",
// Message: "backup accepted",
// },
// {
// Type: string(constant.NonAdminConditionQueued),
// Status: metav1.ConditionTrue,
// Reason: "BackupScheduled",
// Message: "Created Velero Backup object",
// },
// {
// Type: string(constant.NonAdminConditionDeleting),
// Status: metav1.ConditionTrue,
// Reason: "DeletionPending",
// Message: "backup accepted for deletion",
// },
// },
// },
// nonAdminBackupExpectedDeleted: false,
// addFinalizer: true,
// result: reconcile.Result{},
// }), TODO not real scenario
ginkgo.Entry("When triggered by NonAdminBackup deleteNonAdmin spec field with Finalizer persisting, should not delete NonAdminBackup as it's waiting for Velero Backup object to be deleted", nonAdminBackupSingleReconcileScenario{
createVeleroBackup: true,
addFinalizer: true,
Expand Down Expand Up @@ -552,11 +554,9 @@ var _ = ginkgo.Describe("Test single reconciles of NonAdminBackup Reconcile func
},
},
nonAdminBackupExpectedDeleted: true,
result: reconcile.Result{Requeue: true},
result: reconcile.Result{},
}),
ginkgo.Entry("When triggered by NonAdminBackup forceDeleteNonAdmin spec field with Finalizer set and NonAdminBackup phase Created without DeletionTimestamp, should trigger delete NonAdminBackup and requeue", nonAdminBackupSingleReconcileScenario{
addFinalizer: true,
addNabDeletionTimestamp: false,
ginkgo.Entry("When triggered by NonAdminBackup forceDeleteNonAdmin spec field with Finalizer set and NonAdminBackup phase Created without DeletionTimestamp, should delete NonAdminBackup", nonAdminBackupSingleReconcileScenario{
nonAdminBackupSpec: nacv1alpha1.NonAdminBackupSpec{
BackupSpec: &velerov1.BackupSpec{},
ForceDeleteBackup: true,
Expand All @@ -578,37 +578,21 @@ var _ = ginkgo.Describe("Test single reconciles of NonAdminBackup Reconcile func
Message: "Created Velero Backup object",
LastTransitionTime: metav1.NewTime(time.Now()),
},
},
},
nonAdminBackupExpectedStatus: nacv1alpha1.NonAdminBackupStatus{
Phase: nacv1alpha1.NonAdminPhaseDeleting,
Conditions: []metav1.Condition{
{
Type: string(constant.NonAdminConditionAccepted),
Status: metav1.ConditionTrue,
Reason: "BackupAccepted",
Message: "backup accepted",
},
{
Type: string(constant.NonAdminConditionQueued),
Status: metav1.ConditionTrue,
Reason: "BackupScheduled",
Message: "Created Velero Backup object",
},
{
Type: string(constant.NonAdminConditionDeleting),
Status: metav1.ConditionTrue,
Reason: "DeletionPending",
Message: "backup accepted for deletion",
Type: string(constant.NonAdminConditionDeleting),
Status: metav1.ConditionTrue,
Reason: "DeletionPending",
Message: "backup accepted for deletion",
LastTransitionTime: metav1.NewTime(time.Now()),
},
},
},
nonAdminBackupExpectedDeleted: false,
result: reconcile.Result{Requeue: true},
addFinalizer: true,
addNabDeletionTimestamp: false,
nonAdminBackupExpectedDeleted: true,
result: reconcile.Result{},
}),
ginkgo.Entry("When triggered by NonAdminBackup forceDeleteNonAdmin spec field with Finalizer set, should delete NonAdminBackup and exit", nonAdminBackupSingleReconcileScenario{
addFinalizer: true,
addNabDeletionTimestamp: true,
ginkgo.Entry("When triggered by NonAdminBackup forceDeleteNonAdmin spec field with deletion timestamp and velero backup, should delete velero backup and Requeue", nonAdminBackupSingleReconcileScenario{
nonAdminBackupSpec: nacv1alpha1.NonAdminBackupSpec{
BackupSpec: &velerov1.BackupSpec{},
ForceDeleteBackup: true,
Expand All @@ -634,15 +618,40 @@ var _ = ginkgo.Describe("Test single reconciles of NonAdminBackup Reconcile func
Type: string(constant.NonAdminConditionDeleting),
Status: metav1.ConditionTrue,
Reason: "DeletionPending",
Message: "backup accepted for deletion",
Message: "backup deletion requires setting spec.deleteBackup or spec.forceDeleteBackup to true or finalizer removal",
LastTransitionTime: metav1.NewTime(time.Now()),
},
},
},
nonAdminBackupExpectedStatus: nacv1alpha1.NonAdminBackupStatus{
Phase: nacv1alpha1.NonAdminPhaseDeleting,
Conditions: []metav1.Condition{
{
Type: string(constant.NonAdminConditionAccepted),
Status: metav1.ConditionTrue,
Reason: "BackupAccepted",
Message: "backup accepted",
},
{
Type: string(constant.NonAdminConditionQueued),
Status: metav1.ConditionTrue,
Reason: "BackupScheduled",
Message: "Created Velero Backup object",
},
{
Type: string(constant.NonAdminConditionDeleting),
Status: metav1.ConditionTrue,
Reason: "DeletionPending",
Message: "backup accepted for deletion",
},
},
},
createVeleroBackup: true,
uuidFromTestCase: true,
nonAdminBackupExpectedDeleted: true,
result: reconcile.Result{Requeue: false},
nonAdminBackupExpectedDeleted: false,
addFinalizer: true,
addNabDeletionTimestamp: true,
result: reconcile.Result{Requeue: true},
}),
ginkgo.Entry("When triggered by Requeue(NonAdminBackup phase new), should update NonAdminBackup Phase to Created and Condition to Accepted True and NOT Requeue", nonAdminBackupSingleReconcileScenario{
nonAdminBackupSpec: nacv1alpha1.NonAdminBackupSpec{
Expand Down

0 comments on commit ec40c69

Please sign in to comment.