mirror of
https://github.com/mariadb-operator/mariadb-operator.git
synced 2025-08-08 06:35:58 +00:00
Support history limits in Backup and SqlJob resources
This commit is contained in:

committed by
Martin Montes

parent
a04a6924ea
commit
25f70d42e3
@ -7,6 +7,7 @@ import (
|
||||
batchv1 "k8s.io/api/batch/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/ptr"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
@ -229,8 +230,12 @@ var _ = Describe("SqlJob", func() {
|
||||
}(),
|
||||
},
|
||||
}
|
||||
scheduledSqlJobWithHistoryLimits := scheduledSqlJob.DeepCopy()
|
||||
scheduledSqlJobWithHistoryLimits.ObjectMeta.Name = "sqljob-scheduled-with-history-limits"
|
||||
scheduledSqlJobWithHistoryLimits.Spec.SuccessfulJobsHistoryLimit = ptr.To[int32](5)
|
||||
scheduledSqlJobWithHistoryLimits.Spec.FailedJobsHistoryLimit = ptr.To[int32](5)
|
||||
|
||||
By("Creating SqlJob")
|
||||
By("Creating a scheduled SqlJob")
|
||||
Expect(k8sClient.Create(testCtx, &scheduledSqlJob)).To(Succeed())
|
||||
DeferCleanup(func() {
|
||||
Expect(k8sClient.Delete(testCtx, &scheduledSqlJob)).To(Succeed())
|
||||
@ -241,5 +246,25 @@ var _ = Describe("SqlJob", func() {
|
||||
var cronJob batchv1.CronJob
|
||||
return k8sClient.Get(testCtx, client.ObjectKeyFromObject(&scheduledSqlJob), &cronJob) != nil
|
||||
}, testHighTimeout, testInterval).Should(BeTrue())
|
||||
|
||||
By("Creating a scheduled SqlJob with history limits")
|
||||
Expect(k8sClient.Create(testCtx, scheduledSqlJobWithHistoryLimits)).To(Succeed())
|
||||
DeferCleanup(func() {
|
||||
Expect(k8sClient.Delete(testCtx, scheduledSqlJobWithHistoryLimits)).To(Succeed())
|
||||
})
|
||||
|
||||
By("Expecting to create a CronJob with history limits eventually")
|
||||
Eventually(func() bool {
|
||||
var cronJob batchv1.CronJob
|
||||
err := k8sClient.Get(testCtx, client.ObjectKeyFromObject(scheduledSqlJobWithHistoryLimits), &cronJob)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
isSuccessfulJobHistoryLimitCorrect := *cronJob.Spec.SuccessfulJobsHistoryLimit ==
|
||||
*scheduledSqlJobWithHistoryLimits.Spec.SuccessfulJobsHistoryLimit
|
||||
isFailedJobHistoryLimitCorrect := *cronJob.Spec.FailedJobsHistoryLimit ==
|
||||
*scheduledSqlJobWithHistoryLimits.Spec.FailedJobsHistoryLimit
|
||||
return isSuccessfulJobHistoryLimitCorrect && isFailedJobHistoryLimitCorrect
|
||||
}, testHighTimeout, testInterval).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user