Skip to content

Conversation

@mt-ks
Copy link
Collaborator

@mt-ks mt-ks commented Nov 21, 2025

Add Docker Compose configuration and Redis integration tests

  • Introduced a new docker-compose.yml file to define Redis and Redis Cluster services.
  • Updated CI workflow to include Redis services for testing.
  • Added comprehensive integration tests for both single Redis instance and Redis Cluster, covering key operations like increment, decrement, and TTL handling.

This enhances the testing environment and ensures compatibility with Redis functionalities.

@mt-ks mt-ks requested review from gamemaker1 and nfriedly November 21, 2025 20:19
@mt-ks mt-ks self-assigned this Nov 21, 2025
@mt-ks mt-ks requested a review from wyattjoh November 21, 2025 20:39
Copy link
Member

@nfriedly nfriedly left a 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.

Comment on lines 152 to 163
// 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
}
Copy link
Member

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.

Copy link
Member

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?

Copy link
Collaborator Author

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 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey @nfriedly
Wdyt about this? c0a3621

Copy link
Member

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?

Comment on lines +49 to +52
"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",
Copy link
Member

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:

Suggested change
"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:*",

Copy link
Member

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:

Suggested change
"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",

@@ -0,0 +1,13 @@
version: '3'
Copy link
Member

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?

Copy link
Collaborator Author

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.

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.

4 participants