@@ -61,21 +61,21 @@ var _ = SIGDescribe("CronJob", func() {
61
61
cronJob := newTestCronJob ("concurrent" , "*/1 * * * ?" , batchv1beta1 .AllowConcurrent ,
62
62
sleepCommand , nil )
63
63
cronJob , err := createCronJob (f .ClientSet , f .Namespace .Name , cronJob )
64
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
64
+ framework . ExpectNoError (err , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
65
65
66
66
ginkgo .By ("Ensuring more than one job is running at a time" )
67
67
err = waitForActiveJobs (f .ClientSet , f .Namespace .Name , cronJob .Name , 2 )
68
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to wait for active jobs in CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
68
+ framework . ExpectNoError (err , "Failed to wait for active jobs in CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
69
69
70
70
ginkgo .By ("Ensuring at least two running jobs exists by listing jobs explicitly" )
71
71
jobs , err := f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (metav1.ListOptions {})
72
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to list the CronJobs in namespace %s" , f .Namespace .Name )
72
+ framework . ExpectNoError (err , "Failed to list the CronJobs in namespace %s" , f .Namespace .Name )
73
73
activeJobs , _ := filterActiveJobs (jobs )
74
74
gomega .Expect (len (activeJobs ) >= 2 ).To (gomega .BeTrue ())
75
75
76
76
ginkgo .By ("Removing cronjob" )
77
77
err = deleteCronJob (f .ClientSet , f .Namespace .Name , cronJob .Name )
78
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
78
+ framework . ExpectNoError (err , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
79
79
})
80
80
81
81
// suspended should not schedule jobs
@@ -86,20 +86,20 @@ var _ = SIGDescribe("CronJob", func() {
86
86
t := true
87
87
cronJob .Spec .Suspend = & t
88
88
cronJob , err := createCronJob (f .ClientSet , f .Namespace .Name , cronJob )
89
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
89
+ framework . ExpectNoError (err , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
90
90
91
91
ginkgo .By ("Ensuring no jobs are scheduled" )
92
92
err = waitForNoJobs (f .ClientSet , f .Namespace .Name , cronJob .Name , false )
93
93
gomega .Expect (err ).To (gomega .HaveOccurred ())
94
94
95
95
ginkgo .By ("Ensuring no job exists by listing jobs explicitly" )
96
96
jobs , err := f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (metav1.ListOptions {})
97
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to list the CronJobs in namespace %s" , f .Namespace .Name )
97
+ framework . ExpectNoError (err , "Failed to list the CronJobs in namespace %s" , f .Namespace .Name )
98
98
gomega .Expect (jobs .Items ).To (gomega .HaveLen (0 ))
99
99
100
100
ginkgo .By ("Removing cronjob" )
101
101
err = deleteCronJob (f .ClientSet , f .Namespace .Name , cronJob .Name )
102
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
102
+ framework . ExpectNoError (err , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
103
103
})
104
104
105
105
// only single active job is allowed for ForbidConcurrent
@@ -108,20 +108,20 @@ var _ = SIGDescribe("CronJob", func() {
108
108
cronJob := newTestCronJob ("forbid" , "*/1 * * * ?" , batchv1beta1 .ForbidConcurrent ,
109
109
sleepCommand , nil )
110
110
cronJob , err := createCronJob (f .ClientSet , f .Namespace .Name , cronJob )
111
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
111
+ framework . ExpectNoError (err , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
112
112
113
113
ginkgo .By ("Ensuring a job is scheduled" )
114
114
err = waitForActiveJobs (f .ClientSet , f .Namespace .Name , cronJob .Name , 1 )
115
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to schedule CronJob %s" , cronJob .Name )
115
+ framework . ExpectNoError (err , "Failed to schedule CronJob %s" , cronJob .Name )
116
116
117
117
ginkgo .By ("Ensuring exactly one is scheduled" )
118
118
cronJob , err = getCronJob (f .ClientSet , f .Namespace .Name , cronJob .Name )
119
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to get CronJob %s" , cronJob .Name )
119
+ framework . ExpectNoError (err , "Failed to get CronJob %s" , cronJob .Name )
120
120
gomega .Expect (cronJob .Status .Active ).Should (gomega .HaveLen (1 ))
121
121
122
122
ginkgo .By ("Ensuring exactly one running job exists by listing jobs explicitly" )
123
123
jobs , err := f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (metav1.ListOptions {})
124
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to list the CronJobs in namespace %s" , f .Namespace .Name )
124
+ framework . ExpectNoError (err , "Failed to list the CronJobs in namespace %s" , f .Namespace .Name )
125
125
activeJobs , _ := filterActiveJobs (jobs )
126
126
gomega .Expect (activeJobs ).To (gomega .HaveLen (1 ))
127
127
@@ -131,7 +131,7 @@ var _ = SIGDescribe("CronJob", func() {
131
131
132
132
ginkgo .By ("Removing cronjob" )
133
133
err = deleteCronJob (f .ClientSet , f .Namespace .Name , cronJob .Name )
134
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
134
+ framework . ExpectNoError (err , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
135
135
})
136
136
137
137
// only single active job is allowed for ReplaceConcurrent
@@ -140,30 +140,30 @@ var _ = SIGDescribe("CronJob", func() {
140
140
cronJob := newTestCronJob ("replace" , "*/1 * * * ?" , batchv1beta1 .ReplaceConcurrent ,
141
141
sleepCommand , nil )
142
142
cronJob , err := createCronJob (f .ClientSet , f .Namespace .Name , cronJob )
143
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
143
+ framework . ExpectNoError (err , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
144
144
145
145
ginkgo .By ("Ensuring a job is scheduled" )
146
146
err = waitForActiveJobs (f .ClientSet , f .Namespace .Name , cronJob .Name , 1 )
147
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to schedule CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
147
+ framework . ExpectNoError (err , "Failed to schedule CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
148
148
149
149
ginkgo .By ("Ensuring exactly one is scheduled" )
150
150
cronJob , err = getCronJob (f .ClientSet , f .Namespace .Name , cronJob .Name )
151
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to get CronJob %s" , cronJob .Name )
151
+ framework . ExpectNoError (err , "Failed to get CronJob %s" , cronJob .Name )
152
152
gomega .Expect (cronJob .Status .Active ).Should (gomega .HaveLen (1 ))
153
153
154
154
ginkgo .By ("Ensuring exactly one running job exists by listing jobs explicitly" )
155
155
jobs , err := f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (metav1.ListOptions {})
156
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to list the jobs in namespace %s" , f .Namespace .Name )
156
+ framework . ExpectNoError (err , "Failed to list the jobs in namespace %s" , f .Namespace .Name )
157
157
activeJobs , _ := filterActiveJobs (jobs )
158
158
gomega .Expect (activeJobs ).To (gomega .HaveLen (1 ))
159
159
160
160
ginkgo .By ("Ensuring the job is replaced with a new one" )
161
161
err = waitForJobReplaced (f .ClientSet , f .Namespace .Name , jobs .Items [0 ].Name )
162
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to replace CronJob %s in namespace %s" , jobs .Items [0 ].Name , f .Namespace .Name )
162
+ framework . ExpectNoError (err , "Failed to replace CronJob %s in namespace %s" , jobs .Items [0 ].Name , f .Namespace .Name )
163
163
164
164
ginkgo .By ("Removing cronjob" )
165
165
err = deleteCronJob (f .ClientSet , f .Namespace .Name , cronJob .Name )
166
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
166
+ framework . ExpectNoError (err , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
167
167
})
168
168
169
169
// shouldn't give us unexpected warnings
@@ -172,21 +172,21 @@ var _ = SIGDescribe("CronJob", func() {
172
172
cronJob := newTestCronJob ("concurrent" , "*/1 * * * ?" , batchv1beta1 .AllowConcurrent ,
173
173
nil , nil )
174
174
cronJob , err := createCronJob (f .ClientSet , f .Namespace .Name , cronJob )
175
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
175
+ framework . ExpectNoError (err , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
176
176
177
177
ginkgo .By ("Ensuring at least two jobs and at least one finished job exists by listing jobs explicitly" )
178
178
err = waitForJobsAtLeast (f .ClientSet , f .Namespace .Name , 2 )
179
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure at least two job exists in namespace %s" , f .Namespace .Name )
179
+ framework . ExpectNoError (err , "Failed to ensure at least two job exists in namespace %s" , f .Namespace .Name )
180
180
err = waitForAnyFinishedJob (f .ClientSet , f .Namespace .Name )
181
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure at least on finished job exists in namespace %s" , f .Namespace .Name )
181
+ framework . ExpectNoError (err , "Failed to ensure at least on finished job exists in namespace %s" , f .Namespace .Name )
182
182
183
183
ginkgo .By ("Ensuring no unexpected event has happened" )
184
184
err = waitForEventWithReason (f .ClientSet , f .Namespace .Name , cronJob .Name , []string {"MissingJob" , "UnexpectedJob" })
185
185
gomega .Expect (err ).To (gomega .HaveOccurred ())
186
186
187
187
ginkgo .By ("Removing cronjob" )
188
188
err = deleteCronJob (f .ClientSet , f .Namespace .Name , cronJob .Name )
189
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
189
+ framework . ExpectNoError (err , "Failed to delete CronJob %s in namespace %s" , cronJob .Name , f .Namespace .Name )
190
190
})
191
191
192
192
// deleted jobs should be removed from the active list
@@ -195,15 +195,15 @@ var _ = SIGDescribe("CronJob", func() {
195
195
cronJob := newTestCronJob ("forbid" , "*/1 * * * ?" , batchv1beta1 .ForbidConcurrent ,
196
196
sleepCommand , nil )
197
197
cronJob , err := createCronJob (f .ClientSet , f .Namespace .Name , cronJob )
198
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
198
+ framework . ExpectNoError (err , "Failed to create CronJob in namespace %s" , f .Namespace .Name )
199
199
200
200
ginkgo .By ("Ensuring a job is scheduled" )
201
201
err = waitForActiveJobs (f .ClientSet , f .Namespace .Name , cronJob .Name , 1 )
202
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure a %s cronjob is scheduled in namespace %s" , cronJob .Name , f .Namespace .Name )
202
+ framework . ExpectNoError (err , "Failed to ensure a %s cronjob is scheduled in namespace %s" , cronJob .Name , f .Namespace .Name )
203
203
204
204
ginkgo .By ("Ensuring exactly one is scheduled" )
205
205
cronJob , err = getCronJob (f .ClientSet , f .Namespace .Name , cronJob .Name )
206
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure exactly one %s cronjob is scheduled in namespace %s" , cronJob .Name , f .Namespace .Name )
206
+ framework . ExpectNoError (err , "Failed to ensure exactly one %s cronjob is scheduled in namespace %s" , cronJob .Name , f .Namespace .Name )
207
207
gomega .Expect (cronJob .Status .Active ).Should (gomega .HaveLen (1 ))
208
208
209
209
ginkgo .By ("Deleting the job" )
@@ -217,15 +217,15 @@ var _ = SIGDescribe("CronJob", func() {
217
217
218
218
ginkgo .By ("Ensuring the job is not in the cronjob active list" )
219
219
err = waitForJobNotActive (f .ClientSet , f .Namespace .Name , cronJob .Name , job .Name )
220
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure the %s cronjob is not in active list in namespace %s" , cronJob .Name , f .Namespace .Name )
220
+ framework . ExpectNoError (err , "Failed to ensure the %s cronjob is not in active list in namespace %s" , cronJob .Name , f .Namespace .Name )
221
221
222
222
ginkgo .By ("Ensuring MissingJob event has occurred" )
223
223
err = waitForEventWithReason (f .ClientSet , f .Namespace .Name , cronJob .Name , []string {"MissingJob" })
224
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure missing job event has occurred for %s cronjob in namespace %s" , cronJob .Name , f .Namespace .Name )
224
+ framework . ExpectNoError (err , "Failed to ensure missing job event has occurred for %s cronjob in namespace %s" , cronJob .Name , f .Namespace .Name )
225
225
226
226
ginkgo .By ("Removing cronjob" )
227
227
err = deleteCronJob (f .ClientSet , f .Namespace .Name , cronJob .Name )
228
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to remove %s cronjob in namespace %s" , cronJob .Name , f .Namespace .Name )
228
+ framework . ExpectNoError (err , "Failed to remove %s cronjob in namespace %s" , cronJob .Name , f .Namespace .Name )
229
229
})
230
230
231
231
// cleanup of successful finished jobs, with limit of one successful job
@@ -235,37 +235,37 @@ var _ = SIGDescribe("CronJob", func() {
235
235
cronJob := newTestCronJob ("concurrent-limit" , "*/1 * * * ?" , batchv1beta1 .AllowConcurrent ,
236
236
successCommand , & successLimit )
237
237
cronJob , err := createCronJob (f .ClientSet , f .Namespace .Name , cronJob )
238
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to create allowconcurrent cronjob with custom history limits in namespace %s" , f .Namespace .Name )
238
+ framework . ExpectNoError (err , "Failed to create allowconcurrent cronjob with custom history limits in namespace %s" , f .Namespace .Name )
239
239
240
240
// Job is going to complete instantly: do not check for an active job
241
241
// as we are most likely to miss it
242
242
243
243
ginkgo .By ("Ensuring a finished job exists" )
244
244
err = waitForAnyFinishedJob (f .ClientSet , f .Namespace .Name )
245
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure a finished cronjob exists in namespace %s" , f .Namespace .Name )
245
+ framework . ExpectNoError (err , "Failed to ensure a finished cronjob exists in namespace %s" , f .Namespace .Name )
246
246
247
247
ginkgo .By ("Ensuring a finished job exists by listing jobs explicitly" )
248
248
jobs , err := f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (metav1.ListOptions {})
249
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure a finished cronjob exists by listing jobs explicitly in namespace %s" , f .Namespace .Name )
249
+ framework . ExpectNoError (err , "Failed to ensure a finished cronjob exists by listing jobs explicitly in namespace %s" , f .Namespace .Name )
250
250
_ , finishedJobs := filterActiveJobs (jobs )
251
251
gomega .Expect (len (finishedJobs ) == 1 ).To (gomega .BeTrue ())
252
252
253
253
// Job should get deleted when the next job finishes the next minute
254
254
ginkgo .By ("Ensuring this job and its pods does not exist anymore" )
255
255
err = waitForJobToDisappear (f .ClientSet , f .Namespace .Name , finishedJobs [0 ])
256
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure that job does not exists anymore in namespace %s" , f .Namespace .Name )
256
+ framework . ExpectNoError (err , "Failed to ensure that job does not exists anymore in namespace %s" , f .Namespace .Name )
257
257
err = waitForJobsPodToDisappear (f .ClientSet , f .Namespace .Name , finishedJobs [0 ])
258
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure that pods for job does not exists anymore in namespace %s" , f .Namespace .Name )
258
+ framework . ExpectNoError (err , "Failed to ensure that pods for job does not exists anymore in namespace %s" , f .Namespace .Name )
259
259
260
260
ginkgo .By ("Ensuring there is 1 finished job by listing jobs explicitly" )
261
261
jobs , err = f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).List (metav1.ListOptions {})
262
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to ensure there is one finished job by listing job explicitly in namespace %s" , f .Namespace .Name )
262
+ framework . ExpectNoError (err , "Failed to ensure there is one finished job by listing job explicitly in namespace %s" , f .Namespace .Name )
263
263
_ , finishedJobs = filterActiveJobs (jobs )
264
264
gomega .Expect (len (finishedJobs ) == 1 ).To (gomega .BeTrue ())
265
265
266
266
ginkgo .By ("Removing cronjob" )
267
267
err = deleteCronJob (f .ClientSet , f .Namespace .Name , cronJob .Name )
268
- gomega . Expect (err ). NotTo ( gomega . HaveOccurred () , "Failed to remove the %s cronjob in namespace %s" , cronJob .Name , f .Namespace .Name )
268
+ framework . ExpectNoError (err , "Failed to remove the %s cronjob in namespace %s" , cronJob .Name , f .Namespace .Name )
269
269
})
270
270
})
271
271
0 commit comments