Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

CLI Daemon tests #1220

Closed
richardschneider opened this issue Feb 16, 2018 · 8 comments
Closed

CLI Daemon tests #1220

richardschneider opened this issue Feb 16, 2018 · 8 comments
Labels
exp/expert Having worked on the specific codebase is important kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up

Comments

@richardschneider
Copy link
Contributor

Three tests (Addresses.Swarm, SIGINT and SIGTERM) make the assumption that the daemon can be spawned and the process output can be read in real time. This is not true because node's childProcess buffers the output.

What really happens, is the command timeout is detected by execa and the process is then killed and then the test gets the process output, which then tries to the kill process. Also the 1st killing of the process raises a Promise rejection that is unhandled and Node tells us

(node:12988) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The SIGINT and SIGTERM tests really belong to js-ipfsd-ctl, see issue #1192

Is the Addresses.Swarm test really needed? If so, shouldn't it be a core test?

@dryajov
Copy link
Member

dryajov commented Feb 16, 2018

I believe the issues is actually this - https://stackoverflow.com/questions/23429499/stdout-buffer-issue-using-node-child-process, I've ran across it myself, the solution is to increase the buffer to something more reasonable - {maxBuffer: 1024 * 500}.

I'm not sure I agree with this -

The SIGINT and SIGTERM tests really belong to js-ipfsd-ctl, see issue #1192

We want to run this tests as part of each CI run so we make sure it's not broken.

Is the Addresses.Swarm test really needed?

This was due to the fact it was only an issue with the daemon IIRC. But if we can run them as part of core, I think we should.

@dryajov
Copy link
Member

dryajov commented Feb 16, 2018

@richardschneider
Copy link
Contributor Author

@dryajov sorry it's not a buffer size issue. The issue is that nothing is received until the daemon process stops.

@dryajov
Copy link
Member

dryajov commented Feb 16, 2018

@richardschneider we're using https://www.npmjs.com/package/execa to spawn the process, which uses spawn underneath, which returns stdout/stderr as streams, without waiting for the process to finish, the sameway child_process.spawn does.

@dryajov
Copy link
Member

dryajov commented Feb 16, 2018

This is not true because node's childProcess buffers the output.

I think the confusion with this is because execa gets mapped to exec -

const exec = (args) => execa(`${process.cwd()}/src/cli/bin.js`, args, config)

@daviddias
Copy link
Member

I believe this is being handled at #1103, do you confirm?

@daviddias daviddias added kind/bug A bug in existing code (including security flaws) exp/expert Having worked on the specific codebase is important status/ready Ready to be worked P2 Medium: Good to have, but can wait until someone steps up labels Feb 19, 2018
@dryajov
Copy link
Member

dryajov commented Feb 19, 2018

Three tests (Addresses.Swarm, SIGINT and SIGTERM) make the assumption that the daemon can be spawned and the process output can be read in real time. This is not true because node's childProcessbuffers the output.

From my side of things, I was looking specifically into this statement, which I didn't think was accurate - confirmed by my last two comments. As for the failures related to this, I'm not sure where they're being handled.

@daviddias
Copy link
Member

All good now with latest ipfsd-ctl changes. Thank you both! ❤️

@ghost ghost removed the status/ready Ready to be worked label Mar 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/expert Having worked on the specific codebase is important kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up
Projects
None yet
Development

No branches or pull requests

3 participants