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

replace ExpectEqual(someBoolean, ...) #105678

Open
21 of 22 tasks
pohly opened this issue Oct 14, 2021 · 105 comments · Fixed by #106764
Open
21 of 22 tasks

replace ExpectEqual(someBoolean, ...) #105678

pohly opened this issue Oct 14, 2021 · 105 comments · Fixed by #106764
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. sig/testing Categorizes an issue or PR as relevant to SIG Testing. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@pohly
Copy link
Contributor

pohly commented Oct 14, 2021

What would you like to be added?

The test/e2e tests are full of assertions which compare a boolean against true or false, often without any additional explanation. When those assertions fail, the error message is useless for understanding what went wrong, often just saying:

      Apr 22 09:03:41.130: Expected
          <bool>: false
      to equal
          <bool>: true

Including an explanation is better, but then we still have the distracting noise about the comparison:

      Apr 22 09:08:49.598: Failed to do XYZ
      Expected
          <bool>: false
      to equal
          <bool>: true

All of those assertions should be replace with if (<failure check>) framework.Failf(<informative message>).

Such locations can be found by grepping:

$ git grep 'Expect.*Equal([^,]*, *\(true\|false\)' | wc -l
272

Some progress has been made in the meantime:

  • v1.23.0: 250
  • v1.24.0-beta.0: 177

However, we were down to 175 at some point, so the number is going back up.

Example:

test/e2e/storage/vsphere/vsphere_volume_diskformat.go:  framework.ExpectEqual(isAttached, true)
=>
if (!isAttached) {
   framework.Failf("volume %s is not attached", ...)
}

Some other places compare values. Those should be replaced with a comparison assertion. Example:

test/e2e/upgrades/apps/etcd.go: framework.ExpectEqual(ratio > 0.75, true)
=>
gomega.Expect(ratio).To(gomega.BeNumerically(">", 0.75), "ratio too small")

It makes sense to split this work into individual PRs, one per OWNERS file under test/e2e. Here's a list of directories:

When creating a PR, use <directory>: enhance assertions as title. Use one commit per PR, squash when addressing feedback. Unless noted otherwise, @chetak123 will work on PRs. Help may be welcome.

/sig testing
/help

Why is this needed?

Better output for developers when tests fail.

@pohly pohly added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 14, 2021
@k8s-ci-robot
Copy link
Contributor

@pohly:
This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

What would you like to be added?

The test/e2e tests are full of assertions which compare a boolean against true or false, often without any additional explanation. When those assertions fail, the Ginkgo error message is useless for understanding what went wrong, basically just saying "expected false to be true".

All of those assertions should be replace with if (<failure check>) framework.Failf(<informative message>).

Such locations can be found by grepping:

$ git grep 'Expect.*Equal([^,]*, *\(true\|false\)' | wc -l
272

Example:

test/e2e/storage/vsphere/vsphere_volume_diskformat.go:  framework.ExpectEqual(isAttached, true)
=>
if (!isAttached) {
  framework.Failf("volume %s is not attached", ...)
}

Some other places compare values. Those should be replaced with a comparison assertion. Example:

test/e2e/upgrades/apps/etcd.go: framework.ExpectEqual(ratio > 0.75, true)
=>
gomega.Expect(ratio).To(gomega.BeNumerically(">", 0.75), "ratio too small")

/sig testing
/help

Why is this needed?

Better output for developers when tests fail.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added sig/testing Categorizes an issue or PR as relevant to SIG Testing. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 14, 2021
@aojea
Copy link
Member

aojea commented Oct 14, 2021

/good-first-issue

@k8s-ci-robot
Copy link
Contributor

@aojea:
This request has been marked as suitable for new contributors.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-good-first-issue command.

In response to this:

/good-first-issue

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. label Oct 14, 2021
@BenTheElder
Copy link
Member

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 14, 2021
@rishabhkumar296
Copy link

I would like to take this up as my first issue

@chetak123
Copy link
Member

/assign @chetak123

@BurhanuddinMerchant
Copy link

I would like to take up this issue as my first issue

@chetak123
Copy link
Member

Hello @BurhanuddinMerchant I am already working on this issue , can you please take some other issue ?

@BurhanuddinMerchant
Copy link

Hello @BurhanuddinMerchant I am already working on this issue , can you please take some other issue ?

Okay sure ,how do I un assign myself from this issue?

@chetak123
Copy link
Member

I don't think you are assigned to this issue.

@BurhanuddinMerchant
Copy link

Oh okay

@chetak123
Copy link
Member

Hey @NikhilSharmaWe as discussed in pr #105860 (comment) I am assuming that you are only working for tests under test/e2e/storage area.

@pohly
Copy link
Contributor Author

pohly commented Oct 26, 2021

@NikhilSharmaWe also finished the work on test/e2e/upgrades/apps, see #105774

@NikhilSharmaWe
Copy link
Member

@pohly and @chetak123 only one PR is to be made for the correction under test/e2e/storage/, so how can we distribute the task and also make only single PR. Or can we make multiple PR's

@pohly
Copy link
Contributor Author

pohly commented Oct 26, 2021

I have added a TODO list to the issue description. I'll try to keep that up-to-date with what has been done and who is working on it.

@pohly
Copy link
Contributor Author

pohly commented Oct 26, 2021

@NikhilSharmaWe: you can continue with test/e2e/storage in #105860.

@NikhilSharmaWe
Copy link
Member

@pohly what is to be changed in this case
Screenshot (530)

@NikhilSharmaWe
Copy link
Member

@chetak123 can you inform on which directory you are working.

@chetak123
Copy link
Member

Currently working on apimachinery

k8s-publishing-bot pushed a commit to kubernetes/kms that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/apiserver that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/kube-aggregator that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/sample-apiserver that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/sample-controller that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/apiextensions-apiserver that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/metrics that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/cli-runtime that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/sample-cli-plugin that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/kube-proxy that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/cri-api that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/kubelet that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/kube-scheduler that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/controller-manager that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/cloud-provider that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/kube-controller-manager that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/cluster-bootstrap that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/csi-translation-lib that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/mount-utils that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/legacy-cloud-providers that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/kubectl that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/pod-security-admission that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/dynamic-resource-allocation that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
k8s-publishing-bot pushed a commit to kubernetes/endpointslice that referenced this issue Dec 20, 2023
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes/kubernetes#105678.

Kubernetes-commit: c8f9ebfb72b6569b4e2ec9733f6998afc6602135
richabanker pushed a commit to richabanker/kubernetes that referenced this issue Jan 9, 2024
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes#105678.
atwamahmoud pushed a commit to atwamahmoud/kubernetes that referenced this issue Jan 10, 2024
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes#105678.
jiahuif pushed a commit to jiahuif-forks/kubernetes that referenced this issue Jan 23, 2024
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes#105678.
dinhxuanvu pushed a commit to dinhxuanvu/kubernetes that referenced this issue Mar 28, 2024
The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for kubernetes#105678.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. sig/testing Categorizes an issue or PR as relevant to SIG Testing. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet