-
-
Notifications
You must be signed in to change notification settings - Fork 36
Add Redis integration tests #225
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: main
Are you sure you want to change the base?
Conversation
nfriedly
left a comment
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.
Hey, thanks, this is awesome!
I have a couple of thoughts below, but nothing too major.
test/redis-integration-test.ts
Outdated
| // If SCRIPT LOAD, send to all master nodes | ||
| if (command[0] === 'SCRIPT' && command[1] === 'LOAD') { | ||
| const nodes = client.nodes('master') | ||
| await Promise.all( | ||
| nodes.map(async (node) => | ||
| node.call(command[0], ...command.slice(1)), | ||
| ), | ||
| ) | ||
| // Return the result from one of them (they should be identical) | ||
| const result = await client.call(command[0], ...command.slice(1)) | ||
| return result as RedisReply | ||
| } |
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.
Hum, the change I made was to avoid needing something like this, but I suppose that was for node-redis. Is there something we could do to make the same thing easier with ioredis?
Otherwise we should probably add this to the documentation.
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.
Also, could we get the result from the Promise.all return value instead of doing an extra client.call at the end?
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.
You're absolutely right. The manual broadcasting with Promise.all was specifically needed because ioredis (unlike node-redis) doesn't automatically route SCRIPT LOAD commands to the correct node when using raw commands, causing NOSCRIPT errors in cluster mode. [Check my first commit] (Workflow failed)
I’m thinking of a better solution 🤔
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.
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.
Wdyt about this? c0a3621
Hum.. I'm not sure. I think I like the earlier solution better. I'm concerned that fallback is going to end up being the most common case if we let it happen silently; I'd prefer that we do something to ensure the script is loaded onto each server. Maybe do both in parallel?
Also, this is getting farther away from the original intent of this PR - would you mind making a new branch and PR with c0a3621, then removing it from this one?
| "test:unit": "jest test/store-test.ts", | ||
| "test:integration": "jest test/redis-integration-test.ts", | ||
| "test:lib": "jest", | ||
| "test": "run-s lint test:*", | ||
| "test": "run-s lint test:lib", |
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 this could be simplified by dropping test:lib:
| "test:unit": "jest test/store-test.ts", | |
| "test:integration": "jest test/redis-integration-test.ts", | |
| "test:lib": "jest", | |
| "test": "run-s lint test:*", | |
| "test": "run-s lint test:lib", | |
| "test:unit": "jest test/store-test.ts", | |
| "test:integration": "jest test/redis-integration-test.ts", | |
| "test": "run-s lint test:*", |
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.
Or, alternatively, if we want npm test to work without a local redis server, make it this:
| "test:unit": "jest test/store-test.ts", | |
| "test:integration": "jest test/redis-integration-test.ts", | |
| "test:lib": "jest", | |
| "test": "run-s lint test:*", | |
| "test": "run-s lint test:lib", | |
| "test:unit": "jest test/store-test.ts", | |
| "test:integration": "jest test/redis-integration-test.ts", | |
| "test": "run-s lint test:unit", |
…nnection checks and streamlining sendCommandCluster implementation
| @@ -0,0 +1,13 @@ | |||
| version: '3' | |||
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 the Compose file required if we are already mentioning services in the CI file?
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.
We actually don’t need a compose file, but it is required (or recommended) for quickly deploying a Redis cluster on local.
Add Docker Compose configuration and Redis integration tests
docker-compose.ymlfile to define Redis and Redis Cluster services.This enhances the testing environment and ensures compatibility with Redis functionalities.