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

Improve test reproducibility #1195

Merged

Conversation

p12tic
Copy link
Contributor

@p12tic p12tic commented Jul 25, 2022

Many tests call Vec*::Random() and similar functions from Eigen, which make the tests not reproducible. This is problematic, because the tests become unstable and even if some of them sometimes fail indicating a problem, it's hard to debug and fix the failure as the exact conditions of the failing test are not known. Initializing random number generators to a static seed fixes the issue.

In order to introduce variation in test execution, ALICEVISION_TEST_RANDOM_SEED environment variable can be set to an integer value. This effectively allows to keep the previous behavior, because this value can be set to a different integer on each test execution.

Copy link
Member

@simogasp simogasp 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 PR!
If you could just change the doxygen format then it is mergeable IMO

src/aliceVision/numeric/numeric.hpp Outdated Show resolved Hide resolved
@p12tic p12tic force-pushed the reproducible-tests-eigen-rand branch 2 times, most recently from d626376 to 1d572b1 Compare July 26, 2022 10:33
* In order to introduce variation in test execution, ALICEVISION_TEST_RANDOM_SEED environment
* variable can be set to an integer value.
*/
void makeRandomOperationsReproducibleInTests();
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest to remove the "inTests" from the generic function name:

Suggested change
void makeRandomOperationsReproducibleInTests();
void makeRandomOperationsReproducible();

Even if it's only used in tests for now, it is not specific to unit tests in itself.

Same for the env var: ALICEVISION_TEST_RANDOM_SEED => ALICEVISION_RANDOM_SEED.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, that's correct. Fixed now, thanks.

Many tests call Vec*::Random() and similar functions from Eigen, which
make the tests not reproducible. This is problematic, because the tests
become unstable and even if some of them sometimes fail indicating a
problem, it's hard to debug and fix the failure as the exact conditions
of the failing test are not known. Initializing random number generators
to a static seed fixes the issue.
@p12tic p12tic force-pushed the reproducible-tests-eigen-rand branch from 1d572b1 to ace04e0 Compare July 29, 2022 09:51
@fabiencastan fabiencastan dismissed simogasp’s stale review August 1, 2022 13:06

requested changes have been done

@fabiencastan fabiencastan merged commit 77c0ebc into alicevision:develop Aug 1, 2022
@p12tic p12tic deleted the reproducible-tests-eigen-rand branch August 4, 2022 13:40
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.

3 participants