@@ -80,7 +80,7 @@ var _ = SIGDescribe("CronJob", func() {
80
80
81
81
ginkgo .By ("Ensuring at least two running jobs exists by listing jobs explicitly" )
82
82
jobs , err := f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (ctx , metav1.ListOptions {})
83
- framework .ExpectNoError (err , "Failed to list the CronJobs in namespace %s" , f .Namespace .Name )
83
+ framework .ExpectNoError (err , "Failed to list jobs in namespace %s" , f .Namespace .Name )
84
84
activeJobs , _ := filterActiveJobs (jobs )
85
85
gomega .Expect (len (activeJobs )).To (gomega .BeNumerically (">=" , 2 ))
86
86
@@ -109,7 +109,7 @@ var _ = SIGDescribe("CronJob", func() {
109
109
110
110
ginkgo .By ("Ensuring no job exists by listing jobs explicitly" )
111
111
jobs , err := f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (ctx , metav1.ListOptions {})
112
- framework .ExpectNoError (err , "Failed to list the CronJobs in namespace %s" , f .Namespace .Name )
112
+ framework .ExpectNoError (err , "Failed to list jobs in namespace %s" , f .Namespace .Name )
113
113
gomega .Expect (jobs .Items ).To (gomega .BeEmpty ())
114
114
115
115
ginkgo .By ("Removing cronjob" )
@@ -140,7 +140,7 @@ var _ = SIGDescribe("CronJob", func() {
140
140
141
141
ginkgo .By ("Ensuring exactly one running job exists by listing jobs explicitly" )
142
142
jobs , err := f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (ctx , metav1.ListOptions {})
143
- framework .ExpectNoError (err , "Failed to list the CronJobs in namespace %s" , f .Namespace .Name )
143
+ framework .ExpectNoError (err , "Failed to list jobs in namespace %s" , f .Namespace .Name )
144
144
activeJobs , _ := filterActiveJobs (jobs )
145
145
gomega .Expect (activeJobs ).To (gomega .HaveLen (1 ))
146
146
@@ -213,7 +213,7 @@ var _ = SIGDescribe("CronJob", func() {
213
213
214
214
ginkgo .By ("Ensuring at least one running jobs exists by listing jobs explicitly" )
215
215
jobs , err := f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (ctx , metav1.ListOptions {})
216
- framework .ExpectNoError (err , "Failed to list the CronJobs in namespace %s" , f .Namespace .Name )
216
+ framework .ExpectNoError (err , "Failed to list jobs in namespace %s" , f .Namespace .Name )
217
217
activeJobs , _ := filterActiveJobs (jobs )
218
218
gomega .Expect (activeJobs ).ToNot (gomega .BeEmpty ())
219
219
@@ -261,6 +261,31 @@ var _ = SIGDescribe("CronJob", func() {
261
261
framework .ExpectNoError (err , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
262
262
})
263
263
264
+ ginkgo .It ("should set the cronjob-scheduled-timestamp annotation on a job" , func (ctx context.Context ) {
265
+ ginkgo .By ("Creating a cronjob" )
266
+ cronJob := newTestCronJob ("concurrent" , "*/1 * * * ?" , batchv1 .AllowConcurrent ,
267
+ nil , nil , nil )
268
+ cronJob , err := createCronJob (ctx , f .ClientSet , f .Namespace .Name , cronJob )
269
+ framework .ExpectNoError (err , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
270
+
271
+ ginkgo .By ("Ensuring CronJobsScheduledAnnotation annotation exists on the newely created job" )
272
+ err = waitForJobsAtLeast (ctx , f .ClientSet , f .Namespace .Name , 1 )
273
+ framework .ExpectNoError (err , "Failed to ensure a job exists in namespace %s" , f .Namespace .Name )
274
+
275
+ jobs , err := f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (ctx , metav1.ListOptions {})
276
+ framework .ExpectNoError (err , "Failed to list jobs in namespace %s" , f .Namespace .Name )
277
+ gomega .Expect (jobs .Items [0 ].Annotations ).Should (gomega .HaveKey (batchv1 .CronJobScheduledTimestampAnnotation ),
278
+ "missing cronjob-scheduled-timestamp annotation" )
279
+ ginkgo .By ("Ensuring CronJobsScheduledAnnotation annotation parses to RFC3339" )
280
+ timeAnnotation := jobs .Items [0 ].Annotations [batchv1 .CronJobScheduledTimestampAnnotation ]
281
+ _ , err = time .Parse (time .RFC3339 , timeAnnotation )
282
+ framework .ExpectNoError (err , "Failed to parse cronjob-scheduled-timestamp annotation: %q" , timeAnnotation )
283
+
284
+ ginkgo .By ("Removing cronjob" )
285
+ err = deleteCronJob (ctx , f .ClientSet , f .Namespace .Name , cronJob .Name )
286
+ framework .ExpectNoError (err , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
287
+ })
288
+
264
289
// deleted jobs should be removed from the active list
265
290
ginkgo .It ("should remove from active list jobs that have been deleted" , func (ctx context.Context ) {
266
291
ginkgo .By ("Creating a ForbidConcurrent cronjob" )
0 commit comments