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

fix #14320 (tasyncawait.nim is recently very flaky) + avoid hardcoding service ports everywhere + flakyAssert #14327

Merged
merged 9 commits into from
May 13, 2020

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented May 12, 2020

IIUC the reason tasyncawait starting giving Address already in use errors since 5/6/2020, 3:44:15 AM is that some unrelated test was added around that time and it surfaced a pre-existing time-window bug where 2 processes (testament runs tests in parallel) try to bind to same port; a lot of tests were using the same port 10335, which gave Address already in use error.

This PR uses OS to get a port everywhere, and also refactors to remove some code duplication. Unfortunately a lot of tests use the "copy paste" approach, which, while quick and easy for the person who copy pastes, makes maintenance/evolving/bug fixing/increasing generality/etc hard. Eg, any bug fix or code evolution involves N times the amount of work after code is copy pasted N times. This is what happened in this PR.

Copy pasting (even test files) is almost always the wrong thing to do and should be rejected in code review in favor of refactoring as needed.

flakyAssert

this PR also adds flakyAssert, a replacement for assert for tests that are known to fail, see doc comments in PR + rationale. This sill show FLAKY_SUCCESS (with notifySuccess = true and on success) or FLAKY_FAILURE, along with context where it came from, and makes it easy to find in source code where a flake happens, so that it can eventually be fixed, and without disabling entire tests altogether. Testament may swallow the FLAKY_SUCCESS/FLAKY_FAILURE if the entire test succeeds, as usual, but in future work we can refine the logic (in just 1 place) to also log those messages to some file that can be shown in summary along with existing summary.

tests/async/tasyncawait.nim Outdated Show resolved Hide resolved
@timotheecour timotheecour force-pushed the pr_fix_14320_tasyncawait_flaky branch from 1e85a5a to e26cfde Compare May 13, 2020 02:40
@timotheecour timotheecour changed the title hotfix #14320 tasyncawait.nim is recently very flaky fix #14320 (tasyncawait.nim is recently very flaky) + avoid hardcoding service ports everywhere May 13, 2020
@Varriount
Copy link
Contributor

Is this still a draft?

@timotheecour
Copy link
Member Author

timotheecour commented May 13, 2020

Is this still a draft?

ya i wanna see which tests fail first (eg: i'm re-enabling tests/async/tasyncssl.nim after those changes to see if it works). But feedback welcome

@timotheecour timotheecour force-pushed the pr_fix_14320_tasyncawait_flaky branch from e5c99ad to 3481f10 Compare May 13, 2020 07:51
@timotheecour timotheecour marked this pull request as ready for review May 13, 2020 08:54
@timotheecour timotheecour changed the title fix #14320 (tasyncawait.nim is recently very flaky) + avoid hardcoding service ports everywhere fix #14320 (tasyncawait.nim is recently very flaky) + avoid hardcoding service ports everywhere + flakyAssert May 13, 2020
@Araq Araq merged commit 1648f1d into nim-lang:devel May 13, 2020
@timotheecour timotheecour deleted the pr_fix_14320_tasyncawait_flaky branch May 13, 2020 09:09
EchoPouet pushed a commit to EchoPouet/Nim that referenced this pull request Jun 13, 2020
…ardcoding service ports everywhere + flakyAssert (nim-lang#14327)

* hotfix nim-lang#14320 tasyncawait.nim is recently very flaky
* fix nim-lang#14327
* add flakyAssert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tests/async/tasyncawait.nim is recently very flaky
4 participants