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

test: add and use tmpdir.hasEnoughSpace() #47767

Merged
merged 1 commit into from
May 1, 2023

Conversation

tniessen
Copy link
Member

@tniessen tniessen commented Apr 28, 2023

In general, we assume that the tmpdir will provide sufficient space for most tests. Some tests, however, require hundreds of megabytes or even gigabytes of space, which often causes them to fail, especially on our macOS infrastructure. The most recent reliability report contains more than 20 related CI failures.

This change adds a new function hasEnoughSpace() to the tmpdir module that uses statfsSync() (thanks @SheikhSajid and @cjihrig!) to guess whether allocating a certain amount of space within the temporary directory will succeed.

This change also updates the most frequently failing tests to use the new function such that the relevant parts of the tests are skipped if tmpdir has insufficient space. Hopefully, this will significantly reduce the number of related CI failures.

Refs: nodejs/reliability#549

@tniessen tniessen added fs Issues and PRs related to the fs subsystem / file system. test Issues and PRs related to the tests. labels Apr 28, 2023
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Apr 28, 2023
@marco-ippolito
Copy link
Member

marco-ippolito commented Apr 28, 2023

what about hasEnoughSpace so it will return true if the operation is possible

@tniessen
Copy link
Member Author

what about hasEnoughSpace so it will return true if the operation is possible

We usually have a conditional skip() before the actual test definition, so with hasEnoughSpace(), either all call sites would need to use a negation or the order of skip() and test would need to be reversed.

@richardlau
Copy link
Member

what about hasEnoughSpace so it will return true if the operation is possible

We usually have a conditional skip() before the actual test definition, so with hasEnoughSpace(), either all call sites would need to use a negation or the order of skip() and test would need to be reversed.

I wouldn't block on it, but that is exactly what we're currently doing for the similar methods in common: e.g.

if (!common.hasCrypto)
common.skip('missing crypto');
if (!common.enoughTestMem)
common.skip('memory-intensive test');

@tniessen
Copy link
Member Author

That's also a good point @richardlau. I don't feel strongly about it. Personally, I think that hasEnoughSpace() === true might be misleading, because it does not imply that there will actually be enough space (because file system block allocations aren't entirely predictable, because of race conditions, etc.). On the other hand, hasTooLittleSpace() === true pretty much always means that it's not worth trying.

@tniessen tniessen added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Apr 29, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 29, 2023
@nodejs-github-bot
Copy link
Collaborator

test/common/README.md Outdated Show resolved Hide resolved
@tniessen tniessen force-pushed the test-tmpdir-space branch from f5a4908 to d444ceb Compare April 29, 2023 15:25
@tniessen tniessen added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 29, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 29, 2023
@nodejs-github-bot
Copy link
Collaborator

@MoLow
Copy link
Member

MoLow commented Apr 29, 2023

I am +1 on this, but how do we prevent this method from hiding real issues?

@tniessen
Copy link
Member Author

@MoLow Could you clarify what you are concerned about?

Based on my understanding, for this change to hide real issues, one of these must be true: either there is a bug in hasTooLittleSpace() that causes it to incorrectly return true, or running the test despite hasTooLittleSpace() == true would uncover a real issue. Neither seems likely to me.

Ideally, within our own test infrastructure, hasTooLittleSpace() should never return true, thus, on ideal infrastructure, this change has no effect. Of course, if, for example, all of our macOS infrastructure always had too little space for a certain test, and that particular test would uncover a bug that only manifests on macOS, then this change could hide said bug.

@Trott
Copy link
Member

Trott commented Apr 30, 2023

I would prefer hasEnoughSpace() to be consistent with the common.enoughTestMem boolean, but I understand your concern about the ambiguity of "enough" and I don't feel strongly about it. I'm only commenting to point out the existing enoughTestMem which has not been mentioned yet, in case that consistency is compelling.

I guess I'd also prefer hasInsufficientSpace() to hasTooLittleSpace(). But again, not strongly enough to block, and if I wasn't already leaving a comment, I might not say anything.

@MoLow
Copy link
Member

MoLow commented Apr 30, 2023

if, for example, all of our macOS infrastructure always had too little space for a certain test, and that particular test would uncover a bug that only manifests on macOS, then this change could hide said bug.

I am not sure how unlikely such a scenario is. this recently landed PR is an example of specific filesystem behaviors on different platforms.
assuming this check will only be used with tests that require very large disk space, that will probably reduce the likelihood

In general, we assume that the tmpdir will provide sufficient space for
most tests. Some tests, however, require hundreds of megabytes or even
gigabytes of space, which often causes them to fail, especially on our
macOS infrastructure. The most recent reliability report contains more
than 20 related CI failures.

This change adds a new function hasEnoughSpace() to the tmpdir module
that uses statfsSync() to guess whether allocating a certain amount of
space within the temporary directory will succeed.

This change also updates the most frequently failing tests to use the
new function such that the relevant parts of the tests are skipped if
tmpdir has insufficient space.

Refs: nodejs/reliability#549
@tniessen tniessen force-pushed the test-tmpdir-space branch from d444ceb to a74116b Compare April 30, 2023 10:27
@tniessen tniessen changed the title test: add and use tmpdir.hasTooLittleSpace() test: add and use tmpdir.hasEnoughSpace() Apr 30, 2023
@tniessen
Copy link
Member Author

@marco-ippolito @richardlau @Trott @MoLow Alright, I've changed it to hasEnoughSpace().

@tniessen tniessen added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 30, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 30, 2023
@nodejs-github-bot
Copy link
Collaborator

@tniessen
Copy link
Member Author

tniessen commented May 1, 2023

This needs to be reapproved before the commit-queue label can be added.

@tniessen tniessen added the commit-queue Add this label to land a pull request using GitHub Actions. label May 1, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 1, 2023
@nodejs-github-bot nodejs-github-bot merged commit 609d2b0 into nodejs:main May 1, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 609d2b0

targos pushed a commit that referenced this pull request May 2, 2023
In general, we assume that the tmpdir will provide sufficient space for
most tests. Some tests, however, require hundreds of megabytes or even
gigabytes of space, which often causes them to fail, especially on our
macOS infrastructure. The most recent reliability report contains more
than 20 related CI failures.

This change adds a new function hasEnoughSpace() to the tmpdir module
that uses statfsSync() to guess whether allocating a certain amount of
space within the temporary directory will succeed.

This change also updates the most frequently failing tests to use the
new function such that the relevant parts of the tests are skipped if
tmpdir has insufficient space.

Refs: nodejs/reliability#549
PR-URL: #47767
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Richard Lau <rlau@redhat.com>
@targos targos mentioned this pull request May 2, 2023
targos pushed a commit that referenced this pull request May 3, 2023
In general, we assume that the tmpdir will provide sufficient space for
most tests. Some tests, however, require hundreds of megabytes or even
gigabytes of space, which often causes them to fail, especially on our
macOS infrastructure. The most recent reliability report contains more
than 20 related CI failures.

This change adds a new function hasEnoughSpace() to the tmpdir module
that uses statfsSync() to guess whether allocating a certain amount of
space within the temporary directory will succeed.

This change also updates the most frequently failing tests to use the
new function such that the relevant parts of the tests are skipped if
tmpdir has insufficient space.

Refs: nodejs/reliability#549
PR-URL: #47767
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Richard Lau <rlau@redhat.com>
danielleadams pushed a commit that referenced this pull request Jul 6, 2023
In general, we assume that the tmpdir will provide sufficient space for
most tests. Some tests, however, require hundreds of megabytes or even
gigabytes of space, which often causes them to fail, especially on our
macOS infrastructure. The most recent reliability report contains more
than 20 related CI failures.

This change adds a new function hasEnoughSpace() to the tmpdir module
that uses statfsSync() to guess whether allocating a certain amount of
space within the temporary directory will succeed.

This change also updates the most frequently failing tests to use the
new function such that the relevant parts of the tests are skipped if
tmpdir has insufficient space.

Refs: nodejs/reliability#549
PR-URL: #47767
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Richard Lau <rlau@redhat.com>
MoLow pushed a commit to MoLow/node that referenced this pull request Jul 6, 2023
In general, we assume that the tmpdir will provide sufficient space for
most tests. Some tests, however, require hundreds of megabytes or even
gigabytes of space, which often causes them to fail, especially on our
macOS infrastructure. The most recent reliability report contains more
than 20 related CI failures.

This change adds a new function hasEnoughSpace() to the tmpdir module
that uses statfsSync() to guess whether allocating a certain amount of
space within the temporary directory will succeed.

This change also updates the most frequently failing tests to use the
new function such that the relevant parts of the tests are skipped if
tmpdir has insufficient space.

Refs: nodejs/reliability#549
PR-URL: nodejs#47767
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Richard Lau <rlau@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants