Skip to content

Commit

Permalink
Gomega Expect change after Ginkgo v2
Browse files Browse the repository at this point in the history
Pass an explicit instance to the Eventually/Consistently functions
  • Loading branch information
razo7 committed Aug 2, 2023
1 parent ac38920 commit 238926d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions controllers/fenceagentsremediation_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ var _ = Describe("FAR Controller", func() {
})
It("should have finalizer, taint, while the two VAs and one pod will be deleted", func() {
By("Searching for remediation taint")
Eventually(func() bool {
Expect(k8sClient.Get(context.Background(), nodeKey, node)).To(Succeed())
Expect(k8sClient.Get(context.Background(), farNamespacedName, underTestFAR)).To(Succeed())
Eventually(func(g Gomega) bool {
g.Expect(k8sClient.Get(context.Background(), nodeKey, node)).To(Succeed())
g.Expect(k8sClient.Get(context.Background(), farNamespacedName, underTestFAR)).To(Succeed())
res, _ := cliCommandsEquality(underTestFAR)
return utils.TaintExists(node.Spec.Taints, &farNoExecuteTaint) && res
}, 100*time.Millisecond, 10*time.Millisecond).Should(BeTrue(), "taint should be added, and command format is correct")
Expand Down Expand Up @@ -184,8 +184,8 @@ var _ = Describe("FAR Controller", func() {

By("Not having finalizer")
farNamespacedName.Name = underTestFAR.Name
Eventually(func() bool {
Expect(k8sClient.Get(context.Background(), farNamespacedName, underTestFAR)).To(Succeed())
Eventually(func(g Gomega) bool {
g.Expect(k8sClient.Get(context.Background(), farNamespacedName, underTestFAR)).To(Succeed())
return controllerutil.ContainsFinalizer(underTestFAR, v1alpha1.FARFinalizer)
}, 100*time.Millisecond, 10*time.Millisecond).Should(BeFalse(), "finalizer shouldn't be added")

Expand Down
8 changes: 4 additions & 4 deletions test/e2e/far_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,19 @@ func cleanupTestedResources(va *storagev1.VolumeAttachment, pod *corev1.Pod) {
func wasFarTaintAdded(nodeName string) {
farTaint := utils.CreateFARNoExecuteTaint()
var node *corev1.Node
Eventually(func() bool {
Eventually(func(g Gomega) bool {
var err error
node, err = utils.GetNodeWithName(k8sClient, nodeName)
Expect(err).ToNot(HaveOccurred())
g.Expect(err).ToNot(HaveOccurred())
return utils.TaintExists(node.Spec.Taints, &farTaint)
}, 1*time.Second, "200ms").Should(BeTrue())
log.Info("FAR taint was added", "node name", node.Name, "taint key", farTaint.Key, "taint effect", farTaint.Effect)
}

// waitForNodeHealthyCondition waits until the node's ready condition matches the given status, and it fails after timeout
func waitForNodeHealthyCondition(node *corev1.Node, condStatus corev1.ConditionStatus) {
Eventually(func() corev1.ConditionStatus {
Expect(k8sClient.Get(context.Background(), client.ObjectKeyFromObject(node), node)).To(Succeed())
Eventually(func(g Gomega) corev1.ConditionStatus {
g.Expect(k8sClient.Get(context.Background(), client.ObjectKeyFromObject(node), node)).To(Succeed())
for _, cond := range node.Status.Conditions {
if cond.Type == corev1.NodeReady {
return cond.Status
Expand Down

0 comments on commit 238926d

Please sign in to comment.