Skip to content

Commit 67733c6

Browse files
authored
Merge pull request kubernetes#119485 from carlory/cleanup-e2e-apps-framework-equal
e2e_apps: stop using deprecated framework.ExpectEqual
2 parents a321897 + 98bad64 commit 67733c6

File tree

9 files changed

+161
-166
lines changed

9 files changed

+161
-166
lines changed

test/e2e/apps/controller_revision.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() {
142142
ginkgo.By(fmt.Sprintf("Confirm DaemonSet %q successfully created with %q label", dsName, dsLabelSelector))
143143
dsList, err := csAppsV1.DaemonSets("").List(ctx, metav1.ListOptions{LabelSelector: dsLabelSelector})
144144
framework.ExpectNoError(err, "failed to list Daemon Sets")
145-
framework.ExpectEqual(len(dsList.Items), 1, "filtered list wasn't found")
145+
gomega.Expect(dsList.Items).To(gomega.HaveLen(1), "filtered list wasn't found")
146146

147147
ds, err := c.AppsV1().DaemonSets(ns).Get(ctx, dsName, metav1.GetOptions{})
148148
framework.ExpectNoError(err)
@@ -151,7 +151,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() {
151151
ginkgo.By(fmt.Sprintf("Listing all ControllerRevisions with label %q", dsLabelSelector))
152152
revs, err := csAppsV1.ControllerRevisions("").List(ctx, metav1.ListOptions{LabelSelector: dsLabelSelector})
153153
framework.ExpectNoError(err, "Failed to list ControllerRevision: %v", err)
154-
framework.ExpectEqual(len(revs.Items), 1, "Failed to find any controllerRevisions")
154+
gomega.Expect(revs.Items).To(gomega.HaveLen(1), "Failed to find any controllerRevisions")
155155

156156
// Locate the current ControllerRevision from the list
157157
var initialRevision *appsv1.ControllerRevision
@@ -169,7 +169,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() {
169169
payload := "{\"metadata\":{\"labels\":{\"" + initialRevision.Name + "\":\"patched\"}}}"
170170
patchedControllerRevision, err := csAppsV1.ControllerRevisions(ns).Patch(ctx, initialRevision.Name, types.StrategicMergePatchType, []byte(payload), metav1.PatchOptions{})
171171
framework.ExpectNoError(err, "failed to patch ControllerRevision %s in namespace %s", initialRevision.Name, ns)
172-
framework.ExpectEqual(patchedControllerRevision.Labels[initialRevision.Name], "patched", "Did not find 'patched' label for this ControllerRevision. Current labels: %v", patchedControllerRevision.Labels)
172+
gomega.Expect(patchedControllerRevision.Labels).To(gomega.HaveKeyWithValue(initialRevision.Name, "patched"), "Did not find 'patched' label for this ControllerRevision. Current labels: %v", patchedControllerRevision.Labels)
173173
framework.Logf("%s has been patched", patchedControllerRevision.Name)
174174

175175
ginkgo.By("Create a new ControllerRevision")
@@ -216,7 +216,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() {
216216
return err
217217
})
218218
framework.ExpectNoError(err, "failed to update ControllerRevision in namespace: %s", ns)
219-
framework.ExpectEqual(updatedControllerRevision.Labels[currentControllerRevision.Name], "updated", "Did not find 'updated' label for this ControllerRevision. Current labels: %v", currentControllerRevision.Labels)
219+
gomega.Expect(updatedControllerRevision.Labels).To(gomega.HaveKeyWithValue(currentControllerRevision.Name, "updated"), "Did not find 'updated' label for this ControllerRevision. Current labels: %v", updatedControllerRevision.Labels)
220220
framework.Logf("%s has been updated", updatedControllerRevision.Name)
221221

222222
ginkgo.By("Generate another ControllerRevision by patching the Daemonset")
@@ -242,7 +242,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() {
242242

243243
list, err := csAppsV1.ControllerRevisions(ns).List(ctx, metav1.ListOptions{})
244244
framework.ExpectNoError(err, "failed to list ControllerRevision")
245-
framework.ExpectEqual(list.Items[0].Revision, int64(3), "failed to find the expected revision for the Controller")
245+
gomega.Expect(list.Items[0].Revision).To(gomega.Equal(int64(3)), "failed to find the expected revision for the Controller")
246246
framework.Logf("ControllerRevision %q has revision %d", list.Items[0].Name, list.Items[0].Revision)
247247
})
248248
})

test/e2e/apps/cronjob.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,12 @@ var _ = SIGDescribe("CronJob", func() {
342342
ginkgo.By("getting")
343343
gottenCronJob, err := cjClient.Get(ctx, createdCronJob.Name, metav1.GetOptions{})
344344
framework.ExpectNoError(err)
345-
framework.ExpectEqual(gottenCronJob.UID, createdCronJob.UID)
345+
gomega.Expect(gottenCronJob.UID).To(gomega.Equal(createdCronJob.UID))
346346

347347
ginkgo.By("listing")
348348
cjs, err := cjClient.List(ctx, metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
349349
framework.ExpectNoError(err)
350-
framework.ExpectEqual(len(cjs.Items), 1, "filtered list should have 1 item")
350+
gomega.Expect(cjs.Items).To(gomega.HaveLen(1), "filtered list should have 1 item")
351351

352352
ginkgo.By("watching")
353353
framework.Logf("starting watch")
@@ -359,7 +359,7 @@ var _ = SIGDescribe("CronJob", func() {
359359
ginkgo.By("cluster-wide listing")
360360
clusterCJs, err := clusterCJClient.List(ctx, metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
361361
framework.ExpectNoError(err)
362-
framework.ExpectEqual(len(clusterCJs.Items), 1, "filtered list should have 1 items")
362+
gomega.Expect(clusterCJs.Items).To(gomega.HaveLen(1), "filtered list should have 1 item")
363363

364364
ginkgo.By("cluster-wide watching")
365365
framework.Logf("starting watch")
@@ -370,7 +370,7 @@ var _ = SIGDescribe("CronJob", func() {
370370
patchedCronJob, err := cjClient.Patch(ctx, createdCronJob.Name, types.MergePatchType,
371371
[]byte(`{"metadata":{"annotations":{"patched":"true"}}}`), metav1.PatchOptions{})
372372
framework.ExpectNoError(err)
373-
framework.ExpectEqual(patchedCronJob.Annotations["patched"], "true", "patched object should have the applied annotation")
373+
gomega.Expect(patchedCronJob.Annotations).To(gomega.HaveKeyWithValue("patched", "true"), "patched object should have the applied annotation")
374374

375375
ginkgo.By("updating")
376376
var cjToUpdate, updatedCronJob *batchv1.CronJob
@@ -384,7 +384,7 @@ var _ = SIGDescribe("CronJob", func() {
384384
return err
385385
})
386386
framework.ExpectNoError(err)
387-
framework.ExpectEqual(updatedCronJob.Annotations["updated"], "true", "updated object should have the applied annotation")
387+
gomega.Expect(updatedCronJob.Annotations).To(gomega.HaveKeyWithValue("updated", "true"), "updated object should have the applied annotation")
388388

389389
framework.Logf("waiting for watch events with expected annotations")
390390
for sawAnnotations := false; !sawAnnotations; {
@@ -394,7 +394,7 @@ var _ = SIGDescribe("CronJob", func() {
394394
if !ok {
395395
framework.Fail("Watch channel is closed.")
396396
}
397-
framework.ExpectEqual(evt.Type, watch.Modified)
397+
gomega.Expect(evt.Type).To(gomega.Equal(watch.Modified))
398398
watchedCronJob, isCronJob := evt.Object.(*batchv1.CronJob)
399399
if !isCronJob {
400400
framework.Failf("expected CronJob, got %T", evt.Object)
@@ -427,7 +427,7 @@ var _ = SIGDescribe("CronJob", func() {
427427
if !patchedStatus.Status.LastScheduleTime.Equal(&now1) {
428428
framework.Failf("patched object should have the applied lastScheduleTime %#v, got %#v instead", cjStatus.LastScheduleTime, patchedStatus.Status.LastScheduleTime)
429429
}
430-
framework.ExpectEqual(patchedStatus.Annotations["patchedstatus"], "true", "patched object should have the applied annotation")
430+
gomega.Expect(patchedStatus.Annotations).To(gomega.HaveKeyWithValue("patchedstatus", "true"), "patched object should have the applied annotation")
431431

432432
ginkgo.By("updating /status")
433433
// we need to use RFC3339 version since conversion over the wire cuts nanoseconds
@@ -454,7 +454,7 @@ var _ = SIGDescribe("CronJob", func() {
454454
framework.ExpectNoError(err)
455455
statusUID, _, err := unstructured.NestedFieldCopy(gottenStatus.Object, "metadata", "uid")
456456
framework.ExpectNoError(err)
457-
framework.ExpectEqual(string(createdCronJob.UID), statusUID, fmt.Sprintf("createdCronJob.UID: %v expected to match statusUID: %v ", createdCronJob.UID, statusUID))
457+
gomega.Expect(string(createdCronJob.UID)).To(gomega.Equal(statusUID), "createdCronJob.UID: %v expected to match statusUID: %v ", createdCronJob.UID, statusUID)
458458

459459
// CronJob resource delete operations
460460
expectFinalizer := func(cj *batchv1.CronJob, msg string) {
@@ -508,7 +508,7 @@ func ensureHistoryLimits(ctx context.Context, c clientset.Interface, ns string,
508508
activeJobs, finishedJobs := filterActiveJobs(jobs)
509509
if len(finishedJobs) != 1 {
510510
framework.Logf("Expected one finished job in namespace %s; activeJobs=%v; finishedJobs=%v", ns, activeJobs, finishedJobs)
511-
framework.ExpectEqual(len(finishedJobs), 1)
511+
gomega.Expect(finishedJobs).To(gomega.HaveLen(1))
512512
}
513513

514514
// Job should get deleted when the next job finishes the next minute
@@ -524,7 +524,7 @@ func ensureHistoryLimits(ctx context.Context, c clientset.Interface, ns string,
524524
activeJobs, finishedJobs = filterActiveJobs(jobs)
525525
if len(finishedJobs) != 1 {
526526
framework.Logf("Expected one finished job in namespace %s; activeJobs=%v; finishedJobs=%v", ns, activeJobs, finishedJobs)
527-
framework.ExpectEqual(len(finishedJobs), 1)
527+
gomega.Expect(finishedJobs).To(gomega.HaveLen(1))
528528
}
529529

530530
ginkgo.By("Removing cronjob")

test/e2e/apps/daemon_set.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
221221
newNode, err := setDaemonSetNodeLabels(ctx, c, node.Name, nodeSelector)
222222
framework.ExpectNoError(err, "error setting labels on node")
223223
daemonSetLabels, _ := separateDaemonSetNodeLabels(newNode.Labels)
224-
framework.ExpectEqual(len(daemonSetLabels), 1)
224+
gomega.Expect(daemonSetLabels).To(gomega.HaveLen(1))
225225
err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, e2edaemonset.CheckDaemonPodOnNodes(f, ds, []string{newNode.Name}))
226226
framework.ExpectNoError(err, "error waiting for daemon pods to be running on new nodes")
227227
err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName)
@@ -240,7 +240,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
240240
ds, err = c.AppsV1().DaemonSets(ns).Patch(ctx, dsName, types.StrategicMergePatchType, []byte(patch), metav1.PatchOptions{})
241241
framework.ExpectNoError(err, "error patching daemon set")
242242
daemonSetLabels, _ = separateDaemonSetNodeLabels(greenNode.Labels)
243-
framework.ExpectEqual(len(daemonSetLabels), 1)
243+
gomega.Expect(daemonSetLabels).To(gomega.HaveLen(1))
244244
err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, e2edaemonset.CheckDaemonPodOnNodes(f, ds, []string{greenNode.Name}))
245245
framework.ExpectNoError(err, "error waiting for daemon pods to be running on new nodes")
246246
err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName)
@@ -284,7 +284,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
284284
newNode, err := setDaemonSetNodeLabels(ctx, c, node.Name, nodeSelector)
285285
framework.ExpectNoError(err, "error setting labels on node")
286286
daemonSetLabels, _ := separateDaemonSetNodeLabels(newNode.Labels)
287-
framework.ExpectEqual(len(daemonSetLabels), 1)
287+
gomega.Expect(daemonSetLabels).To(gomega.HaveLen(1))
288288
err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, e2edaemonset.CheckDaemonPodOnNodes(f, ds, []string{newNode.Name}))
289289
framework.ExpectNoError(err, "error waiting for daemon pods to be running on new nodes")
290290
err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName)
@@ -351,7 +351,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
351351
waitForHistoryCreated(ctx, c, ns, label, 1)
352352
first := curHistory(listDaemonHistories(ctx, c, ns, label), ds)
353353
firstHash := first.Labels[appsv1.DefaultDaemonSetUniqueLabelKey]
354-
framework.ExpectEqual(first.Revision, int64(1))
354+
gomega.Expect(first.Revision).To(gomega.Equal(int64(1)))
355355
checkDaemonSetPodsLabels(listDaemonPods(ctx, c, ns, label), firstHash)
356356

357357
ginkgo.By("Update daemon pods image.")
@@ -372,7 +372,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
372372
framework.ExpectNoError(err)
373373
waitForHistoryCreated(ctx, c, ns, label, 2)
374374
cur := curHistory(listDaemonHistories(ctx, c, ns, label), ds)
375-
framework.ExpectEqual(cur.Revision, int64(2))
375+
gomega.Expect(cur.Revision).To(gomega.Equal(int64(2)))
376376
gomega.Expect(cur.Labels).NotTo(gomega.HaveKeyWithValue(appsv1.DefaultDaemonSetUniqueLabelKey, firstHash))
377377
checkDaemonSetPodsLabels(listDaemonPods(ctx, c, ns, label), firstHash)
378378
})
@@ -401,7 +401,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
401401
waitForHistoryCreated(ctx, c, ns, label, 1)
402402
cur := curHistory(listDaemonHistories(ctx, c, ns, label), ds)
403403
hash := cur.Labels[appsv1.DefaultDaemonSetUniqueLabelKey]
404-
framework.ExpectEqual(cur.Revision, int64(1))
404+
gomega.Expect(cur.Revision).To(gomega.Equal(int64(1)))
405405
checkDaemonSetPodsLabels(listDaemonPods(ctx, c, ns, label), hash)
406406

407407
ginkgo.By("Update daemon pods image.")
@@ -430,7 +430,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
430430
waitForHistoryCreated(ctx, c, ns, label, 2)
431431
cur = curHistory(listDaemonHistories(ctx, c, ns, label), ds)
432432
hash = cur.Labels[appsv1.DefaultDaemonSetUniqueLabelKey]
433-
framework.ExpectEqual(cur.Revision, int64(2))
433+
gomega.Expect(cur.Revision).To(gomega.Equal(int64(2)))
434434
checkDaemonSetPodsLabels(listDaemonPods(ctx, c, ns, label), hash)
435435
})
436436

@@ -484,7 +484,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
484484
schedulableNodes, err = e2enode.GetReadySchedulableNodes(ctx, c)
485485
framework.ExpectNoError(err)
486486
if len(schedulableNodes.Items) < 2 {
487-
framework.ExpectEqual(len(existingPods), 0)
487+
gomega.Expect(existingPods).To(gomega.BeEmpty())
488488
} else {
489489
gomega.Expect(existingPods).NotTo(gomega.BeEmpty())
490490
}
@@ -571,7 +571,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
571571
waitForHistoryCreated(ctx, c, ns, label, 1)
572572
cur := curHistory(listDaemonHistories(ctx, c, ns, label), ds)
573573
hash := cur.Labels[appsv1.DefaultDaemonSetUniqueLabelKey]
574-
framework.ExpectEqual(cur.Revision, int64(1))
574+
gomega.Expect(cur.Revision).To(gomega.Equal(int64(1)))
575575
checkDaemonSetPodsLabels(listDaemonPods(ctx, c, ns, label), hash)
576576

577577
newVersion := "2"
@@ -822,7 +822,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
822822
waitForHistoryCreated(ctx, c, ns, label, 2)
823823
cur = curHistory(listDaemonHistories(ctx, c, ns, label), ds)
824824
hash = cur.Labels[appsv1.DefaultDaemonSetUniqueLabelKey]
825-
framework.ExpectEqual(cur.Revision, int64(2))
825+
gomega.Expect(cur.Revision).To(gomega.Equal(int64(2)))
826826
checkDaemonSetPodsLabels(listDaemonPods(ctx, c, ns, label), hash)
827827
})
828828

@@ -854,7 +854,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
854854
ginkgo.By("listing all DaemonSets")
855855
dsList, err := cs.AppsV1().DaemonSets("").List(ctx, metav1.ListOptions{LabelSelector: labelSelector})
856856
framework.ExpectNoError(err, "failed to list Daemon Sets")
857-
framework.ExpectEqual(len(dsList.Items), 1, "filtered list wasn't found")
857+
gomega.Expect(dsList.Items).To(gomega.HaveLen(1), "filtered list wasn't found")
858858

859859
ginkgo.By("DeleteCollection of the DaemonSets")
860860
err = dsClient.DeleteCollection(ctx, metav1.DeleteOptions{GracePeriodSeconds: &one}, metav1.ListOptions{LabelSelector: labelSelector})
@@ -863,7 +863,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() {
863863
ginkgo.By("Verify that ReplicaSets have been deleted")
864864
dsList, err = c.AppsV1().DaemonSets("").List(ctx, metav1.ListOptions{LabelSelector: labelSelector})
865865
framework.ExpectNoError(err, "failed to list DaemonSets")
866-
framework.ExpectEqual(len(dsList.Items), 0, "filtered list should have no daemonset")
866+
gomega.Expect(dsList.Items).To(gomega.BeEmpty(), "filtered list should have no daemonset")
867867
})
868868

869869
/* Release: v1.22
@@ -1207,7 +1207,7 @@ func checkDaemonSetPodsLabels(podList *v1.PodList, hash string) {
12071207
podHash := pod.Labels[appsv1.DefaultDaemonSetUniqueLabelKey]
12081208
gomega.Expect(podHash).ToNot(gomega.BeEmpty())
12091209
if len(hash) > 0 {
1210-
framework.ExpectEqual(podHash, hash, "unexpected hash for pod %s", pod.Name)
1210+
gomega.Expect(podHash).To(gomega.Equal(hash), "unexpected hash for pod %s", pod.Name)
12111211
}
12121212
}
12131213
}
@@ -1253,7 +1253,7 @@ func curHistory(historyList *appsv1.ControllerRevisionList, ds *appsv1.DaemonSet
12531253
foundCurHistories++
12541254
}
12551255
}
1256-
framework.ExpectEqual(foundCurHistories, 1)
1256+
gomega.Expect(foundCurHistories).To(gomega.Equal(1))
12571257
gomega.Expect(curHistory).NotTo(gomega.BeNil())
12581258
return curHistory
12591259
}

0 commit comments

Comments
 (0)