Skip to content

Commit b1ef9a5

Browse files
committed
- improve "moved" test for "did the client already know the new node?"
- fix where RESP3 default is specified for the toy server
1 parent 1cb363f commit b1ef9a5

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

tests/StackExchange.Redis.Tests/InProcessTestServer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public ConfigurationOptions GetClientConfig(bool withPubSub = true /*, WriteMode
8585
AsyncTimeout = 5000,
8686
AllowAdmin = true,
8787
Tunnel = Tunnel,
88+
Protocol = TestContext.Current.GetProtocol(),
8889
// WriteMode = (BufferedStreamWriter.WriteMode)writeMode,
8990
};
9091
if (!string.IsNullOrEmpty(Password)) config.Password = Password;

tests/StackExchange.Redis.Tests/MovedUnitTests.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace StackExchange.Redis.Tests;
1111
/// When a MOVED error points to the same endpoint, the client should reconnect before retrying,
1212
/// allowing the DNS record/proxy/load balancer to route to a different underlying server host.
1313
/// </summary>
14+
[RunPerProtocol]
1415
public class MovedUnitTests(ITestOutputHelper log)
1516
{
1617
private RedisKey Me([CallerMemberName] string callerName = "") => callerName;
@@ -48,13 +49,16 @@ public async Task CrossSlotDisallowed(ServerType serverType)
4849
}
4950

5051
[Theory]
51-
[InlineData(true)]
52-
[InlineData(false)]
53-
public async Task KeyMigrationFollowed(bool allowFollowRedirects)
52+
[InlineData(true, false)]
53+
[InlineData(false, false)]
54+
[InlineData(true, true)]
55+
[InlineData(false, true)]
56+
public async Task KeyMigrationFollowed(bool allowFollowRedirects, bool toNewUnknownNode)
5457
{
5558
RedisKey key = Me();
5659
using var server = new InProcessTestServer(log) { ServerType = ServerType.Cluster };
57-
var secondNode = server.AddEmptyNode();
60+
// depending on the test, we might not want the client to know about the second node yet
61+
var secondNode = toNewUnknownNode ? null : server.AddEmptyNode();
5862

5963
await using var muxer = await server.ConnectAsync();
6064
var db = muxer.GetDatabase();
@@ -63,6 +67,11 @@ public async Task KeyMigrationFollowed(bool allowFollowRedirects)
6367
var value = await db.StringGetAsync(key);
6468
Assert.Equal("value", (string?)value);
6569

70+
if (toNewUnknownNode) // if deferred, the client doesn't know about this yet
71+
{
72+
secondNode = server.AddEmptyNode();
73+
}
74+
6675
server.Migrate(key, secondNode);
6776

6877
if (allowFollowRedirects)

tests/StackExchange.Redis.Tests/TestBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,6 @@ public IInternalConnectionMultiplexer CreateClient()
635635
{
636636
var config = _server.GetClientConfig();
637637
config.AllowAdmin = _allowAdmin;
638-
config.Protocol = TestContext.Current.GetProtocol();
639638
if (_channelPrefix is not null)
640639
{
641640
config.ChannelPrefix = RedisChannel.Literal(_channelPrefix);

0 commit comments

Comments
 (0)