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

add test and docs update for detached fork process #24524

Closed
wants to merge 1 commit into from

Conversation

nanomosfet
Copy link
Contributor

@nanomosfet nanomosfet commented Nov 20, 2018

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

This addresses issue #17592

@vsemozhetbyt vsemozhetbyt added child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to the documentations. test Issues and PRs related to the tests. labels Nov 20, 2018
@@ -0,0 +1,44 @@
// Copyright Joyent, Inc. and other Node contributors.
Copy link
Member

Choose a reason for hiding this comment

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

AFAIK this copyright is not needed for new tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove it. Thanks for letting me know.

Copy link
Contributor

@codegagan codegagan left a comment

Choose a reason for hiding this comment

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

I would suggest to use arrow functions wherever possible in file test/fixtures/parent-process-nonpersistent-fork.js

Copy link
Member

@lpinca lpinca left a comment

Choose a reason for hiding this comment

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

SGTM with nits addressed.

@nanomosfet
Copy link
Contributor Author

@codegagan Thanks for the suggestion. I was following how they declared anonymous in other tests.

Also do you mean test/parallel/test-child-process-fork-detached.js? The file you mentioned does not have any functions. I prefer arrow functions as well. Should I change those anonymous functions in my main test file?

@vsemozhetbyt

This comment has been minimized.

@nanomosfet
Copy link
Contributor Author

@vsemozhetbyt Thanks for catching that.

I updated the commit message. I couldn't tell if I should use test or docs for the sub system.

I also changed the docs so that is is less than 80 characters with indent preserved.
Let me know what else I can do. :)

@vsemozhetbyt
Copy link
Contributor

@vsemozhetbyt
Copy link
Contributor

cc @nodejs/child_process

@nanomosfet
Copy link
Contributor Author

@vsemozhetbyt Looks like two of the checks failed. Not really sure what to make out of the details of the build. What is going on?

Copy link
Contributor

@codegagan codegagan left a comment

Choose a reason for hiding this comment

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

@nanomosfet you can look at this test file which has used arrow functions

@vsemozhetbyt
Copy link
Contributor

1 Windows job failure may be unrelated. Let's rerun just this job:
https://ci.nodejs.org/job/node-test-commit-windows-fanned/22587/

@nanomosfet
Copy link
Contributor Author

@vsemozhetbyt Nice it looks like that one passed. Is that a flaky test?

Thank you BTW

@vsemozhetbyt
Copy link
Contributor

Flaky tests are usually marked as flaky in CI logs, but maybe we do not know yet that this one is flaky)

@nanomosfet
Copy link
Contributor Author

@vsemozhetbyt I see. What is left to do so we can merge?

I can change the anon. functions to arrow functions but I am afraid to because of rerunning the CI tests again. I can always make another PR to update a few test with arrow functions. I have noticed a lot of PR's where they are updating tests to use arrow functions.

@vsemozhetbyt
Copy link
Contributor

You can do this in another PR or just leave it for one of the Code-and-learn sessions (most of these latest PRs are from such session).

Our rules require at least 48 hours for the review process and 2 approvals. So, for now, we just need to wait a bit)

@@ -325,6 +325,8 @@ changes:
* `args` {string[]} List of string arguments.
* `options` {Object}
* `cwd` {string} Current working directory of the child process.
* `detached` {boolean} If `true`, prepares child to run
Copy link
Member

@Trott Trott Nov 24, 2018

Choose a reason for hiding this comment

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

Probably better to duplicate the text that exists for the detached option under spawn() rather than have two different phrasings like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'd agree. It's almost the same though. I think the difference is just the If true. Should I go ahead make that change?

process.on('exit', function() {
assert.notStrictEqual(childId, -1);
// Killing the child process should not throw an error
process.kill(childId);
Copy link
Member

Choose a reason for hiding this comment

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

This strikes me as having significant potential for leaving stray processes around on CI. Not necessarily blocking, but surely something to keep an eye on after this lands....

Copy link
Contributor Author

@nanomosfet nanomosfet Nov 24, 2018

Choose a reason for hiding this comment

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

Yeah I totally agree. One of my checks was to make sure that no node processes were running after I ran the test individually.

@Trott
Copy link
Member

Trott commented Nov 24, 2018

I would prefer either leaving the functions as they are, or else changing them here. Changing them to arrow functions in a separate PR is just churn for no good reason. Again, not blocking. Just my own preference.

This tests child process fork component in detached mode
by spawning a parent process that creates a child process.
We kill the parent process and check if the child is still
running.

Fixes: nodejs#17592
@nanomosfet
Copy link
Contributor Author

nanomosfet commented Nov 24, 2018

@codegagan Updated PR to use arrow functions
@vsemozhetbyt fixed typo

nit: nonPersistantNode -> nonPersistentNode here and below.

@Trott - fork detached docs now match spwan detached. Both are now

 * `detached` {boolean} Prepare child to run independently of its parent
    process. Specific behavior depends on the platform, see
    [`options.detached`][]).

Re ran test and no stray node processes

Let me know what else I can do. Thank you for your time <3 :)

Edit: also rebased to tip of nodejs/node

@vsemozhetbyt
Copy link
Contributor

@Trott
Copy link
Member

Trott commented Nov 24, 2018

Looks good to me. Can someone in @nodejs/child_process (or someone else knowledgable about potential pitfalls here) take a look?

Trott pushed a commit to Trott/io.js that referenced this pull request Nov 28, 2018
This tests child process fork component in detached mode
by spawning a parent process that creates a child process.
We kill the parent process and check if the child is still
running.

Fixes: nodejs#17592

PR-URL: nodejs#24524
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@Trott
Copy link
Member

Trott commented Nov 28, 2018

Landed in f051737.

Thanks for the contribution! 🎉

(If you're interested in other possible contributions to Node.js but don't have a good idea of where to start looking, some ideas are posted at https://www.nodetodo.org/next-steps/.)

@Trott Trott closed this Nov 28, 2018
targos pushed a commit that referenced this pull request Nov 29, 2018
This tests child process fork component in detached mode
by spawning a parent process that creates a child process.
We kill the parent process and check if the child is still
running.

Fixes: #17592

PR-URL: #24524
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@BridgeAR BridgeAR mentioned this pull request Dec 5, 2018
4 tasks
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
This tests child process fork component in detached mode
by spawning a parent process that creates a child process.
We kill the parent process and check if the child is still
running.

Fixes: nodejs#17592

PR-URL: nodejs#24524
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
BethGriggs pushed a commit that referenced this pull request Feb 12, 2019
This tests child process fork component in detached mode
by spawning a parent process that creates a child process.
We kill the parent process and check if the child is still
running.

Fixes: #17592

PR-URL: #24524
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@BethGriggs BethGriggs mentioned this pull request Feb 12, 2019
rvagg pushed a commit that referenced this pull request Feb 28, 2019
This tests child process fork component in detached mode
by spawning a parent process that creates a child process.
We kill the parent process and check if the child is still
running.

Fixes: #17592

PR-URL: #24524
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to the documentations. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants