@@ -180,7 +180,6 @@ var _ = SIGDescribe("Deployment", func() {
180
180
},
181
181
},
182
182
}
183
- // TODO add watch tooling
184
183
_ , err := f .ClientSet .AppsV1 ().Deployments (testNamespaceName ).Create (context .TODO (), & testDeployment , metav1.CreateOptions {})
185
184
framework .ExpectNoError (err , "failed to create Deployment %v in namespace %v" , testDeploymentName , testNamespaceName )
186
185
@@ -189,21 +188,28 @@ var _ = SIGDescribe("Deployment", func() {
189
188
dplmtWatch , err := f .ClientSet .AppsV1 ().Deployments (testNamespaceName ).Watch (context .TODO (), metav1.ListOptions {LabelSelector : testDeploymentLabelsFlat , TimeoutSeconds : & dplmtWatchTimeoutSeconds })
190
189
framework .ExpectNoError (err , "Failed to setup watch on newly created Deployment" )
191
190
191
+ foundEvent := false
192
192
dplmtWatchChan := dplmtWatch .ResultChan ()
193
193
for event := range dplmtWatchChan {
194
194
if event .Type == watch .Added {
195
+ foundEvent = true
195
196
break
196
197
}
197
198
}
199
+ framework .ExpectEqual (foundEvent , true , "failed to find watch event %v" , watch .Added )
200
+
198
201
ginkgo .By ("waiting for all Replicas to be Ready" )
202
+ foundEvent = false
199
203
for event := range dplmtWatchChan {
200
204
deployment , ok := event .Object .(* appsv1.Deployment )
201
205
framework .ExpectEqual (ok , true , "unable to convert event.Object type" )
202
206
if deployment .Status .AvailableReplicas == testDeploymentDefaultReplicas &&
203
207
deployment .Status .ReadyReplicas == testDeploymentDefaultReplicas {
208
+ foundEvent = true
204
209
break
205
210
}
206
211
}
212
+ framework .ExpectEqual (foundEvent , true , "failed to see scale of replicas" )
207
213
208
214
ginkgo .By ("patching the Deployment" )
209
215
deploymentPatch , err := json .Marshal (map [string ]interface {}{
@@ -227,20 +233,27 @@ var _ = SIGDescribe("Deployment", func() {
227
233
_ , err = f .ClientSet .AppsV1 ().Deployments (testNamespaceName ).Patch (context .TODO (), testDeploymentName , types .StrategicMergePatchType , []byte (deploymentPatch ), metav1.PatchOptions {})
228
234
framework .ExpectNoError (err , "failed to patch Deployment" )
229
235
236
+ foundEvent = false
230
237
for event := range dplmtWatchChan {
231
238
if event .Type == watch .Modified {
239
+ foundEvent = true
232
240
break
233
241
}
234
242
}
243
+ framework .ExpectEqual (foundEvent , true , "failed to see scale of replicas" )
244
+
235
245
ginkgo .By ("waiting for Replicas to scale" )
246
+ foundEvent = false
236
247
for event := range dplmtWatchChan {
237
248
deployment , ok := event .Object .(* appsv1.Deployment )
238
249
framework .ExpectEqual (ok , true , "unable to convert event.Object type" )
239
250
if deployment .Status .AvailableReplicas == testDeploymentMinimumReplicas &&
240
251
deployment .Status .ReadyReplicas == testDeploymentMinimumReplicas {
252
+ foundEvent = true
241
253
break
242
254
}
243
255
}
256
+ framework .ExpectEqual (foundEvent , true , "failed to see scale of replicas" )
244
257
245
258
ginkgo .By ("listing Deployments" )
246
259
deploymentsList , err := f .ClientSet .AppsV1 ().Deployments ("" ).List (context .TODO (), metav1.ListOptions {LabelSelector : testDeploymentLabelsFlat })
@@ -272,11 +285,14 @@ var _ = SIGDescribe("Deployment", func() {
272
285
// currently this hasn't been able to hit the endpoint replaceAppsV1NamespacedDeploymentStatus
273
286
_ , err = dc .Resource (deploymentResource ).Namespace (testNamespaceName ).Update (context .TODO (), & testDeploymentUpdateUnstructured , metav1.UpdateOptions {}) //, "status")
274
287
framework .ExpectNoError (err , "failed to update the DeploymentStatus" )
288
+ foundEvent = false
275
289
for event := range dplmtWatchChan {
276
290
if event .Type == watch .Modified {
291
+ foundEvent = true
277
292
break
278
293
}
279
294
}
295
+ framework .ExpectEqual (foundEvent , true , "failed to find watch event %v" , watch .Modified )
280
296
281
297
ginkgo .By ("fetching the DeploymentStatus" )
282
298
deploymentGetUnstructured , err := dc .Resource (deploymentResource ).Namespace (testNamespaceName ).Get (context .TODO (), testDeploymentName , metav1.GetOptions {}, "status" )
@@ -286,18 +302,25 @@ var _ = SIGDescribe("Deployment", func() {
286
302
framework .ExpectNoError (err , "failed to convert the unstructured response to a Deployment" )
287
303
framework .ExpectEqual (deploymentGet .Spec .Template .Spec .Containers [0 ].Image , testDeploymentUpdateImage , "failed to update image" )
288
304
framework .ExpectEqual (deploymentGet .ObjectMeta .Labels ["test-deployment" ], "updated" , "failed to update labels" )
305
+ foundEvent = false
289
306
for event := range dplmtWatchChan {
290
307
if event .Type == watch .Modified {
308
+ foundEvent = true
291
309
break
292
310
}
293
311
}
312
+ framework .ExpectEqual (foundEvent , true , "failed to find watch event %v" , watch .Modified )
313
+
314
+ foundEvent = false
294
315
for event := range dplmtWatchChan {
295
316
deployment , ok := event .Object .(* appsv1.Deployment )
296
317
framework .ExpectEqual (ok , true , "unable to convert event.Object type" )
297
318
if deployment .Status .ReadyReplicas == testDeploymentDefaultReplicas {
319
+ foundEvent = true
298
320
break
299
321
}
300
322
}
323
+ framework .ExpectEqual (foundEvent , true , "failed to see scale of replicas" )
301
324
302
325
ginkgo .By ("patching the DeploymentStatus" )
303
326
deploymentStatusPatch , err := json .Marshal (map [string ]interface {}{
@@ -319,11 +342,14 @@ var _ = SIGDescribe("Deployment", func() {
319
342
framework .ExpectNoError (err , "failed to convert the unstructured response to a Deployment" )
320
343
framework .ExpectEqual (deploymentGet .Spec .Template .Spec .Containers [0 ].Image , testDeploymentUpdateImage , "failed to update image" )
321
344
framework .ExpectEqual (deploymentGet .ObjectMeta .Labels ["test-deployment" ], "updated" , "failed to update labels" )
345
+ foundEvent = false
322
346
for event := range dplmtWatchChan {
323
347
if event .Type == watch .Modified {
348
+ foundEvent = true
324
349
break
325
350
}
326
351
}
352
+ framework .ExpectEqual (foundEvent , true , "failed to find watch event %v" , watch .Modified )
327
353
for event := range dplmtWatchChan {
328
354
deployment , ok := event .Object .(* appsv1.Deployment )
329
355
framework .ExpectEqual (ok , true , "unable to convert event.Object type" )
@@ -335,13 +361,17 @@ var _ = SIGDescribe("Deployment", func() {
335
361
ginkgo .By ("deleting the Deployment" )
336
362
err = f .ClientSet .AppsV1 ().Deployments (testNamespaceName ).DeleteCollection (context .TODO (), metav1.DeleteOptions {}, metav1.ListOptions {LabelSelector : testDeploymentLabelsFlat })
337
363
framework .ExpectNoError (err , "failed to delete Deployment via collection" )
364
+
365
+ foundEvent = false
338
366
for event := range dplmtWatchChan {
339
367
deployment , ok := event .Object .(* appsv1.Deployment )
340
368
framework .ExpectEqual (ok , true , "unable to convert event.Object type" )
341
369
if event .Type == watch .Deleted && deployment .ObjectMeta .Name == testDeploymentName {
370
+ foundEvent = true
342
371
break
343
372
}
344
373
}
374
+ framework .ExpectEqual (foundEvent , true , "failed to find watch event %v" , watch .Deleted )
345
375
})
346
376
})
347
377
0 commit comments