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

Exit gracefully on linux #12139

Merged
merged 6 commits into from
Mar 7, 2018
Merged

Exit gracefully on linux #12139

merged 6 commits into from
Mar 7, 2018

Conversation

ckerr
Copy link
Member

@ckerr ckerr commented Mar 6, 2018

  1. Fixes not ok 11 app module app.exit(exitCode) exits gracefully on macos #12050 which was caused by a timing issue. The singleton fixture was reporting its readiness before app had emitted a 'ready' signal. At times, this could cause the parent test harness to run its tests before the child Electron process had finished starting its event loop.

  2. Rewrites the exit_gracefully_on_macos() test to run on other platforms too.

This code is ready for review but is a WIP in the sense that I need confirmation from CI about the portability of the rewritten test.

Singleton now sends the "we've started" message out only after it's
received a `'ready'` event from `app`. Previously it sent the message
out immediately, resulting in the parent test trying to manipulate it
before Singleton's event loop was fully bootstrapped.
Rewrite the "exits gracefully on macos" spec to run on Linux too.
@ckerr ckerr requested a review from a team March 6, 2018 07:02
In the 'exits gracefully' test for app.exit(exitCode),
print the relevant error information if the test fails.
Copy link
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

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

🚀 ty for this, solves such a key flake

@codebytere
Copy link
Member

codebytere commented Mar 6, 2018

@ckerr it appears it's successful on mac and linux but that it's failing on windows. After 👀-ing some documentation, it looks like

Windows does not support sending signals, but Node.js offers some emulation with process.kill(), and subprocess.kill(). Sending signal 0 can be used to test for the existence of a process. Sending SIGINT, SIGTERM, and SIGKILL cause the unconditional termination of the target process.

I think this is still workable cross-platform but we'll have to include a separate handler for win32 processes in the test for CI to go ✅

Windows does not support sending signals, but Node.js offers some
emulation with process.kill(), and subprocess.kill(). Sending signal 0
can be used to test for the existence of a process. Sending SIGINT,
SIGTERM, and SIGKILL cause the unconditional termination of the target
process.

So, we'll need a different approach if we want to test this in win32.
@ckerr
Copy link
Member Author

ckerr commented Mar 6, 2018

@codebytere, thank you for doing the win32 research on this!

I agree we'll need a different approach for win32. Simulating SIGTERM is a good Node feature, but forcing an unconditional exit doesn't give us a meaningful test when we're looking for a graceful shutdown. So let's limit this implementation of the test to macOS and Linux.

@codebytere
Copy link
Member

in that case, i'll merge when CI goes ✅✨

@codebytere codebytere merged commit 65ee977 into master Mar 7, 2018
@codebytere codebytere deleted the exit-gracefully-on-linux branch March 7, 2018 03:01
@alexeykuzmin
Copy link
Contributor

I would vote for backporting the change to 2-0-x. Flaky tests is pain.

@ckerr, @codebytere

codebytere pushed a commit that referenced this pull request Mar 7, 2018
* Fix timing issue in singleton fixture.

Singleton now sends the "we've started" message out only after it's
received a `'ready'` event from `app`. Previously it sent the message
out immediately, resulting in the parent test trying to manipulate it
before Singleton's event loop was fully bootstrapped.

* Check for graceful exits on Linux, too.

Rewrite the "exits gracefully on macos" spec to run on Linux too.

* Check for graceful exits everywhere.

* Tweak comment

* Better error logging in api-app-spec.js. (#12122)

In the 'exits gracefully' test for app.exit(exitCode),
print the relevant error information if the test fails.

* Run the exit-gracefully test on macOS and Linux.

Windows does not support sending signals, but Node.js offers some
emulation with process.kill(), and subprocess.kill(). Sending signal 0
can be used to test for the existence of a process. Sending SIGINT,
SIGTERM, and SIGKILL cause the unconditional termination of the target
process.

So, we'll need a different approach if we want to test this in win32.
@codebytere
Copy link
Member

done, pr up

sethlu pushed a commit to sethlu/electron that referenced this pull request May 3, 2018
* Fix timing issue in singleton fixture.

Singleton now sends the "we've started" message out only after it's
received a `'ready'` event from `app`. Previously it sent the message
out immediately, resulting in the parent test trying to manipulate it
before Singleton's event loop was fully bootstrapped.

* Check for graceful exits on Linux, too.

Rewrite the "exits gracefully on macos" spec to run on Linux too.

* Check for graceful exits everywhere.

* Tweak comment

* Better error logging in api-app-spec.js. (electron#12122)

In the 'exits gracefully' test for app.exit(exitCode),
print the relevant error information if the test fails.

* Run the exit-gracefully test on macOS and Linux.

Windows does not support sending signals, but Node.js offers some
emulation with process.kill(), and subprocess.kill(). Sending signal 0
can be used to test for the existence of a process. Sending SIGINT,
SIGTERM, and SIGKILL cause the unconditional termination of the target
process.

So, we'll need a different approach if we want to test this in win32.
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.

not ok 11 app module app.exit(exitCode) exits gracefully on macos
3 participants