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

Added A Test Policy #4908

Merged
merged 6 commits into from
Mar 20, 2024
Merged

Added A Test Policy #4908

merged 6 commits into from
Mar 20, 2024

Conversation

Samyoul
Copy link
Member

@Samyoul Samyoul commented Mar 11, 2024

The changes of the PR are basically the description. This is based on a status-go crew meeting https://www.notion.so/Sync-Call-67878e2bdbe447ddab0ebc462be8e64f

The human readable policy is below:

status-go Test Policy

Creating Tests

  • All new functionality MUST be introduced with tests that:
    • Prove that the functionality performs as described
    • Can be falsified
    • Are resistant to fuzzing
  • All new integration tests MUST BE validated via a minimum of 1000 tests.
    • This can be achieved using the -count or -test.count flag with the test command eg: -count 1000 / -test.count 1000
    • Where the CI can not support this work flow automatically, the developer MUST perform validation tests via local testing.
      • TODO Add link to issue for CI automation of validation test runs of new integration tests.
    • Ensuring that the test passes consistently every time gives confidence that the test is not flaky.

Flaky Tests

Flaky tests are defined as tests that fail intermittently.

  • All flaky tests / failing tests MUST be resolved.
  • No flaky tests may be introduced into the codebase.

Steps to resolving or reporting flaky tests

Is it me?

Determine who caused the flaky test.

  • Is a new test you’ve written flaky or failing?
    • It was you.
    • You MUST fix the test before merge is acceptable.
  • Has an existing test become flaky?
    • Check rerun reports. TODO add link to rerun reports
      • If the test does not appear in E:Flaky Test or in the last three nightly test runs, it is most likely that the flakiness was introduced by your changes and needs to be addressed before proceeding with the merge.
      • Else the test is already documented as a flaky test (appears in the GitHub issues or in the nightly test runs), proceed to below.
flowchart TB
    A([PR ready for merge]) --> B{Have any test failed?}
    B -->|No| C[🎉 Proceed with merge 🪄]
    B -->|Yes| D{
        Is the failing test introduced
        or altered by this PR?
    }
    D -->|No| E[Check rerun reports.]
    D -->|Yes| F[
        It is likely your changes introduced the flakiness.
        You MUST fix the test before merge is acceptable.
    ]
    F --> A
    E --> G{Does the test appear in `E:Flaky Test` issues<br/> or in the last three nightly test runs?<br/>}
    G -->|Yes| I[The flakiness needs reporting]
    G -->|No| F
    I --> J([Proceed to Reporting flow])

Reporting Flaky Tests

If an old test fails and/or seems flaky either locally or in CI, you MUST report the event.

  • Check the status-go GitHub repo issues for the test name(s) failing.
  • If the test appears in the list of flaky test issues
    • If the issue is open
      • Add a comment to the issue
      • Detail that you have experienced the test being flaky and in what context (local vs CI, link to the PR or branch).
    • If the issue is closed
      • Reopen the issue OR create a new issue referencing the previous issue
        • Either is fine, use your best judgement in this case.
      • Detail that you have experienced the test being flaky and in what context (local vs CI, link to the PR or branch).
  • If the test does not appear in the list of flaky test issues
    • create a new issue
      • The issue title should include the flaky test name
      • The issue should use the E:Flaky Test label
    • Detail that you have experienced the test being flaky and in what context (local vs CI, link to the PR or branch).
flowchart TB
    A([Ready to report a flaky test]) --> B[Check the `status-go` GitHub repo<br/>issues for the test name failing.]
    B --> C{Does the test appear in<br/>the list of `E: Flaky Test` issues?}
    C -->|No| D[
	    Create a new issue
      - The issue title should include the flaky test name
      - The issue should use the `E:Flaky Test` label
    ]
    D --> E[
	    Detail which test is flaky and in what context:
	    local vs CI, link to the PR or branch.
    ]
    E --> J
    C -->|Yes| F{Is the issue open?}
    F -->|No| G((Either))
    H --> E
    G --> I[Reopen the issue]
    G --> D
    I --> H
    F -->|Yes| H[Add a comment to the issue]
    J([End])

@status-im-auto
Copy link
Member

status-im-auto commented Mar 11, 2024

Jenkins Builds

Click to see older builds (21)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 61bb4ad #1 2024-03-11 16:41:00 ~2 min linux 📦zip
✔️ 61bb4ad #1 2024-03-11 16:42:53 ~4 min ios 📦zip
✔️ 61bb4ad #1 2024-03-11 16:43:33 ~5 min android 📦aar
✖️ 61bb4ad #1 2024-03-11 17:13:18 ~35 min tests 📄log
✖️ 61bb4ad #2 2024-03-11 18:31:41 ~34 min tests 📄log
✔️ 52f3cc4 #2 2024-03-13 22:56:13 ~1 min linux 📦zip
✔️ 52f3cc4 #2 2024-03-13 22:57:35 ~2 min ios 📦zip
✔️ 52f3cc4 #2 2024-03-13 23:00:04 ~5 min android 📦aar
✖️ 52f3cc4 #3 2024-03-13 23:30:21 ~35 min tests 📄log
✔️ b611df7 #3 2024-03-13 23:30:08 ~1 min linux 📦zip
✔️ b611df7 #3 2024-03-13 23:30:28 ~1 min android 📦aar
✔️ b611df7 #3 2024-03-13 23:31:34 ~2 min ios 📦zip
✖️ b611df7 #4 2024-03-14 00:03:41 ~33 min tests 📄log
✔️ 6602d49 #4 2024-03-13 23:33:14 ~1 min android 📦aar
✔️ 6602d49 #4 2024-03-13 23:34:26 ~2 min ios 📦zip
✔️ 6602d49 #4 2024-03-13 23:35:01 ~3 min linux 📦zip
✔️ 6602d49 #5 2024-03-14 00:42:42 ~38 min tests 📄log
✔️ b64cd0b #5 2024-03-14 01:37:20 ~1 min linux 📦zip
✔️ b64cd0b #5 2024-03-14 01:37:24 ~1 min android 📦aar
✔️ b64cd0b #5 2024-03-14 01:38:40 ~2 min ios 📦zip
✖️ b64cd0b #6 2024-03-14 01:55:54 ~19 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 86dcbda #6 2024-03-14 12:50:47 ~2 min android 📦aar
✔️ 86dcbda #6 2024-03-14 12:52:46 ~4 min linux 📦zip
✔️ 86dcbda #6 2024-03-14 12:53:51 ~5 min ios 📦zip
✖️ 86dcbda #7 2024-03-14 13:22:32 ~33 min tests 📄log
✔️ 747a2a6 #7 2024-03-15 11:44:46 ~1 min linux 📦zip
✔️ 747a2a6 #7 2024-03-15 11:46:19 ~2 min ios 📦zip
✖️ 747a2a6 #8 2024-03-15 11:48:01 ~4 min tests 📄log
✔️ 747a2a6 #7 2024-03-15 11:48:50 ~5 min android 📦aar
✔️ 747a2a6 #9 2024-03-18 14:43:19 ~37 min tests 📄log

_docs/policies/tests.md Outdated Show resolved Hide resolved
_docs/policies/tests.md Outdated Show resolved Hide resolved
_docs/policies/tests.md Outdated Show resolved Hide resolved
- Prove that the functionality performs as described
- Can be falsified
- Are resistant to fuzzing
- All new tests MUST BE validated via 1000 local tests. Ensuring that the test runs and passes consistently every time gives confidence that the test is not flaky.
Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence I sort of disagree. Sort of because perhaps we should differentiate the type of test we want to rerun hundreds of times because a good portion of unit tests are so deterministic in nature that this recommendation seems out of place or wasted effort to even worry about. Could we change the wording to something more flexible or realistic?

The tricky thing is that we haven't ever (or have we?) agreed on how to classify status-go's tests. If they all go in the same bucket as "tests" it becomes harder for us to express which ones we really want devs to increase -count.

Copy link
Member

Choose a reason for hiding this comment

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

I guess we should say that integration tests should be rerun

Copy link
Member Author

Choose a reason for hiding this comment

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

That is reasonable. Let's change the language to:

Suggested change
- All new tests MUST BE validated via 1000 local tests. Ensuring that the test runs and passes consistently every time gives confidence that the test is not flaky.
- All new integration tests MUST BE validated via at least 10000 local tests. Ensuring that the test runs and passes consistently every time gives confidence that the test is not flaky.

I also agree with you @ilmotta we should have categories of test. Maybe we can open an issue and place a link to it in the Go Council page to mark this work as needing consensus.

Copy link
Member Author

@Samyoul Samyoul Mar 12, 2024

Choose a reason for hiding this comment

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

I'm also happy to add a definition of "integration tests."

@Samyoul make an issue and define

Copy link
Member Author

Choose a reason for hiding this comment

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

This is done #4935

_docs/policies/tests.md Outdated Show resolved Hide resolved
@rasom
Copy link
Member

rasom commented Mar 11, 2024

you will never merge this because tests fail

Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

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

Nice policy. I agree with it!

_docs/policies/tests.md Outdated Show resolved Hide resolved
_docs/policies/tests.md Outdated Show resolved Hide resolved
- Prove that the functionality performs as described
- Can be falsified
- Are resistant to fuzzing
- All new tests MUST BE validated via 1000 local tests. Ensuring that the test runs and passes consistently every time gives confidence that the test is not flaky.
Copy link
Member

Choose a reason for hiding this comment

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

I guess we should say that integration tests should be rerun

Copy link
Contributor

@osmaczko osmaczko left a comment

Choose a reason for hiding this comment

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

Thanks for this. I believe this is an ideal candidate for a flowchart (Mermaid). It will be much more readable. (Come on, we are developers 🤓 )

flowchart TB
    A[Start: Before merging] --> B{Check rerun reports}
    B -->|Yes| C[Check if test is in flaky tests GitHub issues or in the last three nightly test runs]
    C -->|No| D[Flakiness likely introduced by your changes]
    D --> E[Address flakiness]
    E --> B
    C -->|Yes| F[Add a comment to the existing issue or open a new issue if none exists]
    B -->|No| G[Proceed with merge]
    F --> G

^ It's merely a draft, needs more love. If you don't have time for it, I can come up with something more mature at the end of the week.

- Prove that the functionality performs as described
- Can be falsified
- Are resistant to fuzzing
- All new tests MUST BE validated via 1000 local tests. Ensuring that the test runs and passes consistently every time gives confidence that the test is not flaky.
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be great to automate it and run on CI. What is not a CI check, will never be respected. Some will forget, some will not know (new contributors), some will not run to save time.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree with your points. For now we can include it as part of the policy as this is the behaviour we want regardless of how we enforce the requirement.

I'll raise an issue to explore / implement the automation of "new integration test mega runs". I'll track it via the Go Council project board ... Which doesn't exist yet but we probably should have it as we have multiple improvements to track, and this improvement is dependent on being able to categorise certain tests as "integration test".

Copy link
Member Author

Choose a reason for hiding this comment

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

@Samyoul make issue and somewhere to track Go Council related things

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok this issue is now done #4952

_docs/policies/tests.md Outdated Show resolved Hide resolved
_docs/policies/tests.md Outdated Show resolved Hide resolved
_docs/policies/tests.md Outdated Show resolved Hide resolved
_docs/policies/tests.md Outdated Show resolved Hide resolved
_docs/policies/tests.md Outdated Show resolved Hide resolved
@Samyoul
Copy link
Member Author

Samyoul commented Mar 11, 2024

Thank you for all the feedback and so quickly. I will get back to you on each point.

Also I should probably not have put so many jokes in the document. I'll fix that and turn this document into a serious policy without the memes and edgelording.

Also 🤦 this is just perfection #4908 (comment)

Screenshot 2024-03-11 at 21 57 40

image

_docs/policies/tests.md Outdated Show resolved Hide resolved
_docs/policies/tests.md Outdated Show resolved Hide resolved
_docs/policies/tests.md Outdated Show resolved Hide resolved
Copy link
Contributor

@qfrank qfrank left a comment

Choose a reason for hiding this comment

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

Thank you for your effort ❤️ @Samyoul

Copy link
Contributor

@igor-sirotin igor-sirotin left a comment

Choose a reason for hiding this comment

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

Thank you! ❤️

Copy link
Contributor

@osmaczko osmaczko left a comment

Choose a reason for hiding this comment

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

I really do appreciate!

@Samyoul Samyoul merged commit ade85df into develop Mar 20, 2024
7 checks passed
@Samyoul Samyoul deleted the docs/tests-policy branch March 20, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants