-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Refactor the message pass to the assert module in Test cluster setup master #16065
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
694d8f6
Refactor the message argument pass to the assert module.
66396bf
Revert "Refactor the message argument pass to the assert module."
aa354e1
Refactor the message argument pass to the assert module.
e769f54
Make message smaller to fit on less than 80 character long.
b31652d
Change indentation for concatenation for assert message
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
// USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
'use strict'; | ||
require('../common'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const cluster = require('cluster'); | ||
|
||
|
@@ -38,7 +38,7 @@ if (cluster.isWorker) { | |
}; | ||
|
||
const totalWorkers = 2; | ||
let onlineWorkers = 0; | ||
let settings; | ||
|
||
// Setup master | ||
cluster.setupMaster({ | ||
|
@@ -49,7 +49,7 @@ if (cluster.isWorker) { | |
cluster.once('setup', function() { | ||
checks.setupEvent = true; | ||
|
||
const settings = cluster.settings; | ||
settings = cluster.settings; | ||
if (settings && | ||
settings.args && settings.args[0] === 'custom argument' && | ||
settings.silent === true && | ||
|
@@ -58,37 +58,34 @@ if (cluster.isWorker) { | |
} | ||
}); | ||
|
||
let correctIn = 0; | ||
let correctInput = 0; | ||
|
||
cluster.on('online', function lisenter(worker) { | ||
|
||
onlineWorkers++; | ||
cluster.on('online', common.mustCall(function listener(worker) { | ||
|
||
worker.once('message', function(data) { | ||
correctIn += (data === 'custom argument' ? 1 : 0); | ||
if (correctIn === totalWorkers) { | ||
correctInput += (data === 'custom argument' ? 1 : 0); | ||
if (correctInput === totalWorkers) { | ||
checks.args = true; | ||
} | ||
worker.kill(); | ||
}); | ||
|
||
// All workers are online | ||
if (onlineWorkers === totalWorkers) { | ||
checks.workers = true; | ||
} | ||
}); | ||
}, totalWorkers)); | ||
|
||
// Start all workers | ||
cluster.fork(); | ||
cluster.fork(); | ||
|
||
// Check all values | ||
process.once('exit', function() { | ||
assert.ok(checks.workers, 'Not all workers went online'); | ||
assert.ok(checks.args, 'The arguments was noy send to the worker'); | ||
const argsMsg = `The arguments was not send for one or more worker. | ||
There was ${correctInput} worker that receive | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentations will be preserved when they show up in assertions. Can you change this to using concatenations instead? |
||
argument, ${totalWorkers} were expected`; | ||
assert.ok(checks.args, argsMsg); | ||
assert.ok(checks.setupEvent, 'The setup event was never emitted'); | ||
const m = 'The settingsObject do not have correct properties'; | ||
assert.ok(checks.settingsObject, m); | ||
const settingObjectMsg = `The settingsObject do not have correct | ||
properties : ${JSON.stringify(settings)}`; | ||
assert.ok(checks.settingsObject, settingObjectMsg); | ||
}); | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change actually needed at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's to be able to stringify the "settings" variable inside the assert message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BridgeAR Hey, just wanna be sure about "This effects the test subsystem and the commit message do not follow the guidelines that are linked when opening a PR. It would be nice if this could be fixed." you want me to rewrite each commit message to make sure they follow the guide line ?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbeatj If you are comfortable with git, you can do a
git rebase master -i
and squash all the commits with one left as something liketest: improve the assertion message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbeatj Also you can leave this to whoever lands this and they would do that for you.