-
Notifications
You must be signed in to change notification settings - Fork 1.9k
cluster/node events (#1855) #3083
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
base: master
Are you sure you want to change the base?
Conversation
@NaughtySora hi, sorry for big delay! This looks good! Could I ask you to:
|
add test template for the new cluster events
Hi, thank you for the reply @nkaradzhov . I've added the test example from your PR, and I will proceed with the steps above . |
I added documentation inspired by standalone client.
|
testUtils.testWithCluster('foo', async cluster => {
//tests
}, {
serverArguments: [],
numberOfMasters: 3,
numberOfReplicas: 3
});
|
I've found the way to make test more safe and changed docs a bit for more clear description. |
Hi, facing weird test behavior. |
@NaughtySora it looks like we are using an optimization for testing, which tries to minimize connections if there are no commands yet. I made a PR to your repo that fixes the test. |
assert.equal(log.length, disconnect); | ||
|
||
assert.deepEqual( | ||
log.slice(0, nodeConnect), | ||
new Array(numberOfMasters).fill('node-connect'), | ||
); | ||
assert.deepEqual( | ||
log.slice(nodeConnect, nodeReady), | ||
new Array(numberOfMasters).fill('node-ready'), | ||
); | ||
assert.deepEqual( | ||
log.slice(nodeReady, connect), | ||
new Array(1).fill('connect'), | ||
); | ||
assert.deepEqual( | ||
log.slice(connect, nodeDisconnect), | ||
new Array(numberOfMasters).fill('node-disconnect'), | ||
); | ||
assert.deepEqual( | ||
log.slice(nodeDisconnect, disconnect), | ||
new Array(1).fill('disconnect'), | ||
); | ||
|
||
assert.equal(log.includes('error'), false); | ||
assert.equal(log.includes('node-error'), false); | ||
assert.equal(log.includes('node-reconnecting'), false); |
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.
I think we can simplify this by just asserting the log is equal to the expected log. For example:
assert.deepEqual(log, [
'node-connect',
'node-connect',
'node-connect',
'node-ready',
'node-ready',
'node-ready',
'connect',
'node-disconnect',
'node-disconnect',
'node-disconnect',
'disconnect'
]
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.
Total agree with it. I will make a change.
If I get it correctly, if we have 2 masters it will be 2 event for each node-* event.
So the test should be
[
'node-connect',
'node-connect',
'node-ready',
'node-ready',
'connect',
'node-disconnect',
'node-disconnect',
'disconnect',
]
Correct me please if i'm wrong.
dont minimize connections for test
Description
Adding events for cluster client, some people were interested in it.
I have read the issue but didn't see any concrete approved suggestions so i come up with some.
for cluster:
for nodes:
Node events provide host/port to identify a particular node.
I would like to hear suggestions or opinion if this feature needed.
issue #1855
Checklist
Does
npm test
pass with this change (including linting)?I tried to run tests via npm run build and npm test but it fails with timeout "before hook" after 30000ms after 1 hour of going a couple of time. But git checks are fine i guess.
Is the new or changed code fully tested?
I haven't seen any tests for emitting events, i have tested it only locally.
Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
Can't find where i can update desctiption about cluster events.
I saw small section of client events on redis website.
Can't update that.