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

Adjust number of test cases #496

Closed
wants to merge 4 commits into from

Conversation

Niols
Copy link
Contributor

@Niols Niols commented Nov 8, 2023

For now, we have relied on withMaxSuccess to reduce the number of tests. This does not allow for an increase of the number of tests in CI or nightly. This PR uses the proper mechanism.

@Niols Niols changed the base branch from main to genesis/point-scheduler November 8, 2023 15:06
@Niols Niols added the Genesis PRs related to Genesis testing and implementation label Nov 8, 2023
@Niols
Copy link
Contributor Author

Niols commented Nov 8, 2023

The PR seems to make the “can rollback” test flaky because it discards way too many objects. I don't think we should merge it until that is taken care of.

@Niols Niols force-pushed the niols/ajust-test-cases branch from a1764ec to d370f82 Compare November 9, 2023 13:57
@Niols Niols force-pushed the niols/ajust-test-cases branch 2 times, most recently from 677ae88 to 1c4365a Compare November 14, 2023 12:43
@Niols Niols force-pushed the niols/ajust-test-cases branch from 1c4365a to 2dd7f18 Compare November 14, 2023 12:43
Copy link
Contributor

@facundominguez facundominguez left a comment

Choose a reason for hiding this comment

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

LGTM

github-merge-queue bot pushed a commit that referenced this pull request Nov 17, 2023
_This PR has been initially devised as part of the Genesis project, in
#496. It now
targets `main` because we believe it might benefit the project as a
whole._

### Description

This PR aims at normalising the adjustments of the number of QuickCheck
tests in the whole codebase.

`ouroboros-consensus:unstable-consensus-testlib` provides utilities in a
module `Test.Util.TestEnv` to help describing a difference of behaviour
of tests when ran in a `dev` (default), `ci` or `nightly` environment.
This is typically used to change the number of test cases that
QuickCheck generates. This number will be 100 in `dev`, 10,000 in `ci`
and 100,000 in `nightly` by default.

Now, for some tests, 100 is too much and so we end up wanting to run ten
times less than that (or any other ratio, really). The proper way to do
this without hard-coding a value (say 10 tests) which would then be the
same independently of the environment is by adjusting the value option
`QuickCheckTests`, with something like:
```haskell
adjustOption (\(QuickCheckTests n) -> QuickCheckTests (1 `max` (div n 10)))
  :: TestTree -> TestTree
```

This is what is being done in various places of the code base in
slightly different ways. This PR introduces a helper
`adjustQuickCheckTests` and uses it consistently across the code base.
This helper allows writing “let's run 10⨉ less tests” as
```haskell
adjustQuickCheckTests (`div` 10)
  :: TestTree -> TestTree
```

### Bonus questions

I have two bonus questions which I think could be taken care of in this
PR.

First, I have seen in various place a helper:
```haskell
adjustTestEnv :: TestTree -> TestEnv -> TestTree
adjustTestEnv tree = \case
  Nightly -> tree
  _       -> adjustQuickCheckTests (`div` 10) tree
```
I have the impression that this could be simplified as simply
``adjustQuickCheckTests (`div` 10)``. What do you think?

Second, a lot of places hardcode a number of tests with `localOption
(QuickCheckTests 14)` for instance. I would be tempted to replace this
by something like ``adjustQuickCheckTests (`div` 7)``, which would give
a similar result but would behave better when test environments are
indeed used in CI or nightly. What do you think?
@Niols
Copy link
Contributor Author

Niols commented Dec 6, 2023

Has to be adapted to target #819; I will do that today.

Niols added a commit that referenced this pull request Dec 6, 2023
Reimplementation of #496 targetting #819, which include the more general
changes of #500.
@Niols Niols mentioned this pull request Dec 6, 2023
@Niols
Copy link
Contributor Author

Niols commented Dec 6, 2023

See #821.

@Niols Niols closed this Dec 6, 2023
@Niols Niols deleted the niols/ajust-test-cases branch December 6, 2023 16:32
@Niols Niols restored the niols/ajust-test-cases branch December 6, 2023 16:32
@Niols Niols deleted the niols/ajust-test-cases branch December 6, 2023 16:32
Niols added a commit that referenced this pull request Dec 6, 2023
Reimplementation of #496 targetting #819, which include the more general
changes of #500.
facundominguez pushed a commit that referenced this pull request Dec 14, 2023
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
facundominguez pushed a commit that referenced this pull request Dec 15, 2023
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
facundominguez pushed a commit that referenced this pull request Dec 15, 2023
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
Niols added a commit that referenced this pull request Jan 23, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
nbacquey pushed a commit that referenced this pull request Feb 26, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
nbacquey pushed a commit that referenced this pull request Feb 26, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
nbacquey pushed a commit that referenced this pull request Feb 27, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
nbacquey pushed a commit that referenced this pull request Feb 27, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
nbacquey pushed a commit that referenced this pull request Feb 27, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
nbacquey pushed a commit that referenced this pull request Feb 27, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
Niols added a commit that referenced this pull request Feb 29, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
nbacquey pushed a commit that referenced this pull request Mar 11, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
facundominguez pushed a commit that referenced this pull request Mar 11, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
amesgen pushed a commit that referenced this pull request Mar 25, 2024
* Rename `BlockTree.prettyPrint` into `prettyBlockTree`
* Move `PointSchedule`'s pretty-printing closer to its type
* Move `GenesisTest`'s printing closer to its type
* Adjust number of test cases
    Reimplementation of #496 targetting #819, which include the more general
    changes of #500.
* Add a pretty-printer for the current state of the node under test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Genesis PRs related to Genesis testing and implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants