FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: fix failure in `test/sequential/test-heapdump.js` by RaisinTen · Pull Request #41772 · nodejs/node · GitHub

/ node Public

test: fix failure in test/sequential/test-heapdump.js - #41772

Merged
nodejs-github-bot merged 2 commits into
nodejs:masterfrom
RaisinTen:test/fix-failure-in-test/sequential/test-heapdump.js-when-run-with-sudo
Mar 14, 2022
Merged

test: fix failure in test/sequential/test-heapdump.js#41772
nodejs-github-bot merged 2 commits into
nodejs:masterfrom
RaisinTen:test/fix-failure-in-test/sequential/test-heapdump.js-when-run-with-sudo

Conversation

Copy link
Copy Markdown
Member

The test was failing when it was being run with superuser privileges,
so this changes the test from attempting to write to a read-only file to
attempting to write to a file with the same name as that of an existing
directory, as that is a more reliable way of making
v8.writeHeapSnapshot() throw even when run with sudo.

Fixes: #41643
Signed-off-by: Darshan Sen raisinten@gmail.com

The test was failing when it was being run with superuser privileges,
so this changes the test from attempting to write to a read-only file to
attempting to write to a file with the same name as that of an existing
directory, as that is a more reliable way of making
v8.writeHeapSnapshot() throw even when run with sudo.

Fixes: nodejs#41643
Signed-off-by: Darshan Sen <raisinten@gmail.com>
nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Jan 30, 2022

This comment has been minimized.

Trott commented Jan 30, 2022

Copy link
Copy Markdown
Member

Looks like maybe this change makes it fail on Windows?

aduh95 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Shouldn't the directory be deleted at the end of the test?

Trott commented Jan 30, 2022

Copy link
Copy Markdown
Member

Shouldn't the directory be deleted at the end of the test?

Because we're in a test tmpdir and those are all cleaned up by test.py, it's not strictly necessary and we don't do that in most tests. We do make an exception for large files and try to clean those up.

Signed-off-by: Darshan Sen <raisinten@gmail.com>

This comment has been minimized.

Copy link
Copy Markdown
Member Author

Looks like maybe this change makes it fail on Windows?

@Trott yes that happens because the writeHeapSnapshot() implementation uses things like fopen() instead of uv_fs_open() underneath. Added a TODO.

const readonlyFile = 'ro';
fs.writeFileSync(readonlyFile, Buffer.alloc(0), { mode: 0o444 });
const directory = 'directory';
fs.mkdirSync(directory);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't think this change will keep the test content as same as before

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@mawaregetsuka Yes but the intention is still the same. If you go through the PR description where this was introduced - #41373, it mentions:

this PR makes v8.writeHeapSnapshot throw if the file could not be written

So the current test still attempts to recreate a scenario where the function won't be able to write to the file, so we expect it to throw.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you, now I understand. That's a clever solution

This comment was marked as outdated.

Trott commented Feb 1, 2022

Copy link
Copy Markdown
Member

@nodejs/testing

Copy link
Copy Markdown
Member Author

Can this get a review please?

aduh95 added author ready PRs that have at least one approval, no outstanding review comments, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Mar 12, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 12, 2022

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Copy Markdown
Collaborator

aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 14, 2022
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 14, 2022
nodejs-github-bot merged commit 82181bb into nodejs:master Mar 14, 2022

Copy link
Copy Markdown
Collaborator

Landed in 82181bb

RaisinTen deleted the test/fix-failure-in-test/sequential/test-heapdump.js-when-run-with-sudo branch March 15, 2022 01:01
RaisinTen removed the review wanted PRs that need reviews. label Mar 20, 2022

bengl commented Mar 21, 2022

Copy link
Copy Markdown
Member

This doesn't land on 17.x, and it looks like it's because it's modifying code added in a semver-major, so I'm adding the dont-land-on-17 label. Please comment if you think it should land.

xtx1130 pushed a commit to xtx1130/node that referenced this pull request Apr 25, 2022
The test was failing when it was being run with superuser privileges,
so this changes the test from attempting to write to a read-only file to
attempting to write to a file with the same name as that of an existing
directory, as that is a more reliable way of making
v8.writeHeapSnapshot() throw even when run with sudo.

Fixes: nodejs#41643
Signed-off-by: Darshan Sen <raisinten@gmail.com>

PR-URL: nodejs#41772
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>

Copy link
Copy Markdown
Member

This depends on #41373, which can not be included in v16.x

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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 outstanding review comments, and a CI started. 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.

test/sequential/test-heapdump.js lines 27 through 39 is bound to fail

7 participants


Back | FazBrowse Home | New Git URL