Skip to content

Add RESP3 dual-protocol testing alongside RESP2#153

Merged
niemyjski merged 2 commits intomainfrom
feat/resp3-dual-protocol-testing
Mar 17, 2026
Merged

Add RESP3 dual-protocol testing alongside RESP2#153
niemyjski merged 2 commits intomainfrom
feat/resp3-dual-protocol-testing

Conversation

@niemyjski
Copy link
Member

@niemyjski niemyjski commented Mar 17, 2026

Summary

  • Run the entire test suite under both RESP2 (default) and RESP3 protocols to validate compatibility ahead of potential RESP3 adoption.
  • SharedConnection now maintains two static ConnectionMultiplexer instances (one per protocol) with the same double-check locking pattern.
  • Each of the 9 Redis test classes gains a virtual RedisProtocol? Protocol property and a corresponding *Resp3Tests subclass that overrides it to RedisProtocol.Resp3.
  • Skips the destructive DatabaseTimeoutDuringDequeueHandledCorrectly test in RESP3 since it blocks the entire Redis server for 5 seconds with a Lua busy-loop and destabilizes subsequent tests when run twice.

Total test count: 888 → 1738 (every Redis integration test now runs under both protocols)

RESP3 Compatibility Notes

All Foundatio.Redis features (caching, queues, messaging, locks, storage, jobs) pass under RESP3 with no library code changes required. Areas we were watching:

  • Lua script RedisResult casts ((int), (double), (long), (long[])) — StackExchange.Redis normalizes these correctly under RESP3.
  • Pub/sub behavior — works correctly in our usage patterns. Note StackExchange.Redis#2783 documents a known issue with RESP3 pub/sub in subscription-heavy scenarios; our tests pass but this is worth monitoring.
  • FlushAllAsync / cluster operations — work identically under both protocols.

Test plan

  • dotnet build Foundatio.Redis.slnx — 0 warnings, 0 errors
  • dotnet test Foundatio.Redis.slnx — 1738 total, 1691 passed, 47 skipped, 0 failed
  • Baseline (original code without changes) — 888 total, 865 passed, 23 skipped, 0 failed
  • RESP2 tests remain green (no regressions)

Run the entire test suite under both RESP2 (default) and RESP3 protocols
to validate compatibility ahead of potential RESP3 adoption.

Changes:
- SharedConnection: maintain two static ConnectionMultiplexer instances
  (one per protocol) with the same double-check locking pattern
- Each of the 9 Redis test classes gains a virtual Protocol property and
  a corresponding *Resp3Tests subclass that overrides it to Resp3
- RedisLockTests uses a constructor parameter to avoid virtual-call-in-
  constructor warnings
- RedisQueueTests.DatabaseTimeoutDuringDequeueHandledCorrectly is skipped
  in the RESP3 subclass because it blocks the entire Redis server for 5s
  and would destabilize subsequent tests when run twice

Related: StackExchange/StackExchange.Redis#2783
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the Foundatio.Redis integration test suite to validate compatibility across both RESP2 (default) and RESP3 by running each Redis-focused test class under both protocols using a shared connection abstraction.

Changes:

  • Introduces protocol-aware Redis connection creation via SharedConnection.GetMuxer(..., protocol) with separate cached multiplexers for RESP2 and RESP3.
  • Adds a protected virtual RedisProtocol? Protocol hook to Redis integration test classes and creates *Resp3Tests subclasses to run the same tests under RESP3.
  • Skips the known-destructive dequeue-timeout test in the RESP3 suite to avoid destabilizing the shared Redis instance.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Foundatio.Redis.Tests/SharedConnection.cs Adds protocol parameter and maintains separate RESP2/RESP3 multiplexers.
tests/Foundatio.Redis.Tests/Storage/RedisFileStorageTests.cs Makes storage tests protocol-selectable and adds RESP3 subclass.
tests/Foundatio.Redis.Tests/Queues/RedisQueueTests.cs Makes queue tests protocol-selectable, adds RESP3 subclass, and skips destructive test under RESP3.
tests/Foundatio.Redis.Tests/Messaging/RedisMessageBusTests.cs Makes message bus tests protocol-selectable and adds RESP3 subclass.
tests/Foundatio.Redis.Tests/Locks/RedisLockTests.cs Adds protocol selection via constructor wiring and adds RESP3 subclass.
tests/Foundatio.Redis.Tests/Jobs/RedisJobQueueTests.cs Makes job queue tests protocol-selectable and adds RESP3 subclass.
tests/Foundatio.Redis.Tests/Caching/ScopedRedisHybridCacheClientTests.cs Makes scoped hybrid cache tests protocol-selectable and adds RESP3 subclass.
tests/Foundatio.Redis.Tests/Caching/ScopedRedisCacheClientTests.cs Makes scoped cache tests protocol-selectable and adds RESP3 subclass.
tests/Foundatio.Redis.Tests/Caching/RedisHybridCacheClientTests.cs Makes hybrid cache tests protocol-selectable and adds RESP3 subclass.
tests/Foundatio.Redis.Tests/Caching/RedisCacheClientTests.cs Makes cache tests protocol-selectable and adds RESP3 subclass.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Adds documentation to clarify that separate ConnectionMultiplexer instances are cached for RESP2 and RESP3, allowing the test suite to run against both protocols without reconnecting.
@niemyjski niemyjski merged commit 49483b6 into main Mar 17, 2026
3 checks passed
@niemyjski niemyjski deleted the feat/resp3-dual-protocol-testing branch March 17, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants