Skip to content

Commit b38d7f2

Browse files
committed
Remove watch tooling
1 parent e719b72 commit b38d7f2

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

test/e2e/apps/deployment.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ var _ = SIGDescribe("Deployment", func() {
180180
},
181181
},
182182
}
183-
// TODO add watch tooling
184183
_, err := f.ClientSet.AppsV1().Deployments(testNamespaceName).Create(context.TODO(), &testDeployment, metav1.CreateOptions{})
185184
framework.ExpectNoError(err, "failed to create Deployment %v in namespace %v", testDeploymentName, testNamespaceName)
186185

@@ -189,21 +188,28 @@ var _ = SIGDescribe("Deployment", func() {
189188
dplmtWatch, err := f.ClientSet.AppsV1().Deployments(testNamespaceName).Watch(context.TODO(), metav1.ListOptions{LabelSelector: testDeploymentLabelsFlat, TimeoutSeconds: &dplmtWatchTimeoutSeconds})
190189
framework.ExpectNoError(err, "Failed to setup watch on newly created Deployment")
191190

191+
foundEvent := false
192192
dplmtWatchChan := dplmtWatch.ResultChan()
193193
for event := range dplmtWatchChan {
194194
if event.Type == watch.Added {
195+
foundEvent = true
195196
break
196197
}
197198
}
199+
framework.ExpectEqual(foundEvent, true, "failed to find watch event %v", watch.Added)
200+
198201
ginkgo.By("waiting for all Replicas to be Ready")
202+
foundEvent = false
199203
for event := range dplmtWatchChan {
200204
deployment, ok := event.Object.(*appsv1.Deployment)
201205
framework.ExpectEqual(ok, true, "unable to convert event.Object type")
202206
if deployment.Status.AvailableReplicas == testDeploymentDefaultReplicas &&
203207
deployment.Status.ReadyReplicas == testDeploymentDefaultReplicas {
208+
foundEvent = true
204209
break
205210
}
206211
}
212+
framework.ExpectEqual(foundEvent, true, "failed to see scale of replicas")
207213

208214
ginkgo.By("patching the Deployment")
209215
deploymentPatch, err := json.Marshal(map[string]interface{}{
@@ -227,20 +233,27 @@ var _ = SIGDescribe("Deployment", func() {
227233
_, err = f.ClientSet.AppsV1().Deployments(testNamespaceName).Patch(context.TODO(), testDeploymentName, types.StrategicMergePatchType, []byte(deploymentPatch), metav1.PatchOptions{})
228234
framework.ExpectNoError(err, "failed to patch Deployment")
229235

236+
foundEvent = false
230237
for event := range dplmtWatchChan {
231238
if event.Type == watch.Modified {
239+
foundEvent = true
232240
break
233241
}
234242
}
243+
framework.ExpectEqual(foundEvent, true, "failed to see scale of replicas")
244+
235245
ginkgo.By("waiting for Replicas to scale")
246+
foundEvent = false
236247
for event := range dplmtWatchChan {
237248
deployment, ok := event.Object.(*appsv1.Deployment)
238249
framework.ExpectEqual(ok, true, "unable to convert event.Object type")
239250
if deployment.Status.AvailableReplicas == testDeploymentMinimumReplicas &&
240251
deployment.Status.ReadyReplicas == testDeploymentMinimumReplicas {
252+
foundEvent = true
241253
break
242254
}
243255
}
256+
framework.ExpectEqual(foundEvent, true, "failed to see scale of replicas")
244257

245258
ginkgo.By("listing Deployments")
246259
deploymentsList, err := f.ClientSet.AppsV1().Deployments("").List(context.TODO(), metav1.ListOptions{LabelSelector: testDeploymentLabelsFlat})
@@ -272,11 +285,14 @@ var _ = SIGDescribe("Deployment", func() {
272285
// currently this hasn't been able to hit the endpoint replaceAppsV1NamespacedDeploymentStatus
273286
_, err = dc.Resource(deploymentResource).Namespace(testNamespaceName).Update(context.TODO(), &testDeploymentUpdateUnstructured, metav1.UpdateOptions{}) //, "status")
274287
framework.ExpectNoError(err, "failed to update the DeploymentStatus")
288+
foundEvent = false
275289
for event := range dplmtWatchChan {
276290
if event.Type == watch.Modified {
291+
foundEvent = true
277292
break
278293
}
279294
}
295+
framework.ExpectEqual(foundEvent, true, "failed to find watch event %v", watch.Modified)
280296

281297
ginkgo.By("fetching the DeploymentStatus")
282298
deploymentGetUnstructured, err := dc.Resource(deploymentResource).Namespace(testNamespaceName).Get(context.TODO(), testDeploymentName, metav1.GetOptions{}, "status")
@@ -286,18 +302,25 @@ var _ = SIGDescribe("Deployment", func() {
286302
framework.ExpectNoError(err, "failed to convert the unstructured response to a Deployment")
287303
framework.ExpectEqual(deploymentGet.Spec.Template.Spec.Containers[0].Image, testDeploymentUpdateImage, "failed to update image")
288304
framework.ExpectEqual(deploymentGet.ObjectMeta.Labels["test-deployment"], "updated", "failed to update labels")
305+
foundEvent = false
289306
for event := range dplmtWatchChan {
290307
if event.Type == watch.Modified {
308+
foundEvent = true
291309
break
292310
}
293311
}
312+
framework.ExpectEqual(foundEvent, true, "failed to find watch event %v", watch.Modified)
313+
314+
foundEvent = false
294315
for event := range dplmtWatchChan {
295316
deployment, ok := event.Object.(*appsv1.Deployment)
296317
framework.ExpectEqual(ok, true, "unable to convert event.Object type")
297318
if deployment.Status.ReadyReplicas == testDeploymentDefaultReplicas {
319+
foundEvent = true
298320
break
299321
}
300322
}
323+
framework.ExpectEqual(foundEvent, true, "failed to see scale of replicas")
301324

302325
ginkgo.By("patching the DeploymentStatus")
303326
deploymentStatusPatch, err := json.Marshal(map[string]interface{}{
@@ -319,11 +342,14 @@ var _ = SIGDescribe("Deployment", func() {
319342
framework.ExpectNoError(err, "failed to convert the unstructured response to a Deployment")
320343
framework.ExpectEqual(deploymentGet.Spec.Template.Spec.Containers[0].Image, testDeploymentUpdateImage, "failed to update image")
321344
framework.ExpectEqual(deploymentGet.ObjectMeta.Labels["test-deployment"], "updated", "failed to update labels")
345+
foundEvent = false
322346
for event := range dplmtWatchChan {
323347
if event.Type == watch.Modified {
348+
foundEvent = true
324349
break
325350
}
326351
}
352+
framework.ExpectEqual(foundEvent, true, "failed to find watch event %v", watch.Modified)
327353
for event := range dplmtWatchChan {
328354
deployment, ok := event.Object.(*appsv1.Deployment)
329355
framework.ExpectEqual(ok, true, "unable to convert event.Object type")
@@ -335,13 +361,17 @@ var _ = SIGDescribe("Deployment", func() {
335361
ginkgo.By("deleting the Deployment")
336362
err = f.ClientSet.AppsV1().Deployments(testNamespaceName).DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{LabelSelector: testDeploymentLabelsFlat})
337363
framework.ExpectNoError(err, "failed to delete Deployment via collection")
364+
365+
foundEvent = false
338366
for event := range dplmtWatchChan {
339367
deployment, ok := event.Object.(*appsv1.Deployment)
340368
framework.ExpectEqual(ok, true, "unable to convert event.Object type")
341369
if event.Type == watch.Deleted && deployment.ObjectMeta.Name == testDeploymentName {
370+
foundEvent = true
342371
break
343372
}
344373
}
374+
framework.ExpectEqual(foundEvent, true, "failed to find watch event %v", watch.Deleted)
345375
})
346376
})
347377

0 commit comments

Comments
 (0)