Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 test: add failure message to Eventually().Should(bool) everywhere #4943

Merged

Conversation

damdo
Copy link
Member

@damdo damdo commented Apr 22, 2024

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
In Gomega, when Eventually().Should() fails, the failure returns a

  [FAILED] Timed out after 1200.001s.
  Expected
      <bool>: false
  to be true

Which takes a bit of time to then debug further.

There is a more immediate way to add some context to this, by adding a failure message to the should like so: .Should(x, "message"). This PR does this for all the current occurrences of this construct.

Release note:

test: add failure message to Eventually().Should(bool) everywhere

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 22, 2024
@damdo
Copy link
Member Author

damdo commented Apr 22, 2024

/assign @nrb @richardcase

@damdo damdo force-pushed the should-bool-add-failure-message branch 3 times, most recently from c0bcd79 to c7e937e Compare April 22, 2024 09:01
@nrb
Copy link
Contributor

nrb commented Apr 22, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 22, 2024
@damdo damdo changed the title 🌱 test: add failure message to to Eventually().Should(bool) everywhere 🌱 test: add failure message to Eventually().Should(bool) everywhere Apr 23, 2024
Copy link
Contributor

@AndiDog AndiDog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM and great change!

@@ -58,7 +58,7 @@ func waitForMachineDeploymentDeleted(ctx context.Context, input waitForMachineDe
err := input.Getter.Get(ctx, key, mp)
notFound := apierrors.IsNotFound(err)
return notFound
}, intervals...).Should(BeTrue())
}, intervals...).Should(BeTrue(), fmt.Sprintf("Eventually failed waiting for MachineDeployment %s to be deleted", input.MachineDeployment.GetName()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please change all occurrences into %q instead of %s? If a value is empty by mistake, which is very likely when writing tests, it's super-hard to see two spaces as compared to a quoted string that clearly says it's empty: waiting for MachineDeployment to be deleted vs. waiting for MachineDeployment "" to be deleted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion! Updated thanks Andreas!

@damdo damdo force-pushed the should-bool-add-failure-message branch from c7e937e to e6ffff5 Compare April 24, 2024 10:36
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 24, 2024
@damdo damdo force-pushed the should-bool-add-failure-message branch from e6ffff5 to a7c55e1 Compare April 24, 2024 10:36
@damdo
Copy link
Member Author

damdo commented Apr 24, 2024

/test pull-cluster-api-provider-aws-e2e
/test pull-cluster-api-provider-aws-e2e-eks

@damdo damdo requested a review from AndiDog April 24, 2024 14:43
Copy link
Contributor

@AndiDog AndiDog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 24, 2024
@damdo
Copy link
Member Author

damdo commented May 2, 2024

/assign @richardcase @dlipovetsky

@dlipovetsky
Copy link
Contributor

/approve

Thanks for improving the tests!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dlipovetsky

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 2, 2024
@k8s-ci-robot k8s-ci-robot merged commit a17f2ba into kubernetes-sigs:main May 2, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants