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

eunit: Add possibility to scale timeouts #7635

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

tomas-abrahamsson
Copy link
Contributor

Add an option to eunit:test(..., Options):

{scale_timeouts, N}

Motivation: I ran a bunch of tests on an s390 qemu guest on an x86_64 host to test some NIF code on big endian. This executed much slower, and some of the unit tests timed out. The default eunit timeout is 5 seconds. One can increase it, for example by using a test generator with a {timeout, Seconds, TestOrTests} and change xyz_test/0 to xyz_test/1. But this becomes tedious when there are many tests. And to commit such a change to the test code just to accommodate for an unusually slow host doesn't seem like an attractive way to go. Being able to scale the timeouts seems like a good middle ground.

Note that eunit can already read the $EUNIT environment var for one-off runs from the command line with increased timeouts.

I made the PR to target the maint branch. Let me know if I should change it to the master branch instead.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

CT Test Results

    2 files    12 suites   5m 20s ⏱️
105 tests 103 ✔️ 2 💤 0
121 runs  119 ✔️ 2 💤 0

Results for commit 0d75a4b.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

lib/eunit/src/eunit.erl Outdated Show resolved Hide resolved
lib/eunit/test/eunit_SUITE.erl Show resolved Hide resolved
lib/eunit/test/eunit_SUITE.erl Show resolved Hide resolved
lib/eunit/test/eunit_SUITE.erl Outdated Show resolved Hide resolved
@u3s u3s self-assigned this Sep 8, 2023
@u3s u3s added team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI and removed testing currently being tested, tag is used by OTP internal CI labels Sep 8, 2023
@tomas-abrahamsson
Copy link
Contributor Author

tomas-abrahamsson commented Sep 11, 2023

Sorry for the delay in updating, for some reason, I failed to notice your comments until just recently.

I (force-)pushed an updated version.

@u3s
Copy link
Contributor

u3s commented Sep 12, 2023

Note that eunit can already read the $EUNIT environment var for one-off runs from the command line with increased timeouts.

What do you mean with above note? I think setting increased hardcoded timeout for all tests is NOT as good as setting a scaling factor (proposed in PR) which is more sensible.

@tomas-abrahamsson
Copy link
Contributor Author

Exactly, I agree. When I first ran the tests on the slow host, I looked for a way to up the timeout without having to change tools along the way (rebar, makefiles etc). My first (ditched) attempt was actually to introduce an env variable and read that. Then I discovered the EUNIT var.
So I mean the note mostly as info to any future readers that don't know about the env var but think such a thing should exist.

@u3s u3s added this to the OTP-26.2 milestone Sep 13, 2023
@u3s u3s added the testing currently being tested, tag is used by OTP internal CI label Sep 20, 2023
lib/eunit/src/eunit.erl Outdated Show resolved Hide resolved
Add an option to eunit:test(..., Options):

  {scale_timeouts, N}

to be able to increase the timeouts by some factor, or
decrease it if the factor is below 1.0.

This applies to both the the default 5 second timeout,
and to timeouts specified as {timeout, Seconds, Test}
in eunit test generators.
@u3s u3s merged commit 139927f into erlang:maint Sep 27, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants