Skip to content

Fix flake in TestToProvenance and TestWriteProvenance #25

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

Merged
merged 2 commits into from
Jan 22, 2022

Conversation

puerco
Copy link
Member

@puerco puerco commented Jan 22, 2022

What type of PR is this?

/kind failing-test
/kind flake

What this PR does / why we need it:

The TestToProvenance test was flaking because the order of the provenance subjects was unpredictable causing require.Equal to fail to match the SUT against the known example.

The same flake was happening in TestWriteProvenance. So a second commit introduces a function to compare
provenance Subjects that both tests share.

This change modifies the check to compare the Subject hashes one by one and avoid the 1/3 chance that the test would flake.

Signed-off-by: Adolfo García Veytia (Puerco) [email protected]

Which issue(s) this PR fixes:

Related to flakes in #24 and #18

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fixed flakes in `TestWriteProvenance` and `TestToProvenance` where the test would fail one every three runs

The `TestToProvenance` test was flaking because the order of the
provenance subjects was unpredicatable and require.Equal did not
always match the SUT and the know example.

This change modifies the check to compare the Subject hashes one
by one and avoid the 1/3 chance that the test would flake.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
@puerco puerco added the kind/flake Categorizes issue or PR as related to a flaky test. label Jan 22, 2022
@k8s-ci-robot k8s-ci-robot added the kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. label Jan 22, 2022
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 22, 2022
This commit adds two new function compareSubjects() and testStatement()
to reuse the logic and fix a flake in TestWriteProvenance()

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 22, 2022
@puerco puerco changed the title Fix flake in TestToProvenance Fix flake in TestToProvenance and TestWriteProvenance Jan 22, 2022
Copy link
Member

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

Thanks
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 22, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cpanato, puerco

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 merged commit 5311463 into kubernetes-sigs:main Jan 22, 2022
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/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. kind/flake Categorizes issue or PR as related to a flaky test. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

3 participants