|
| 1 | +using System.Threading.Tasks; |
| 2 | +using Xunit; |
| 3 | + |
| 4 | +namespace StackExchange.Redis.Tests; |
| 5 | + |
| 6 | +public class HighIntegrityMovedUnitTests(ITestOutputHelper log) |
| 7 | +{ |
| 8 | + [Theory] |
| 9 | + [InlineData(false)] |
| 10 | + [InlineData(true)] |
| 11 | + public async Task HighIntegritySurvivesMovedResponse(bool highIntegrity) |
| 12 | + { |
| 13 | + using var server = new InProcessTestServer(log) { ServerType = ServerType.Cluster }; |
| 14 | + var secondary = server.AddEmptyNode(); |
| 15 | + |
| 16 | + var config = server.GetClientConfig(); |
| 17 | + config.HighIntegrity = highIntegrity; |
| 18 | + using var client = await ConnectionMultiplexer.ConnectAsync(config); |
| 19 | + |
| 20 | + RedisKey a = "a", b = "b"; // known to be in different slots |
| 21 | + Assert.NotEqual(ServerSelectionStrategy.GetHashSlot(a), ServerSelectionStrategy.GetHashSlot(b)); |
| 22 | + |
| 23 | + var db = client.GetDatabase(); |
| 24 | + var x = db.StringIncrementAsync(a); |
| 25 | + var y = db.StringIncrementAsync(b); |
| 26 | + await x; |
| 27 | + await y; |
| 28 | + Assert.Equal(1, await db.StringGetAsync(a)); |
| 29 | + Assert.Equal(1, await db.StringGetAsync(b)); |
| 30 | + |
| 31 | + // now force a -MOVED response |
| 32 | + server.Migrate(a, secondary); |
| 33 | + x = db.StringIncrementAsync(a); |
| 34 | + y = db.StringIncrementAsync(b); |
| 35 | + await x; |
| 36 | + await y; |
| 37 | + Assert.Equal(2, await db.StringGetAsync(a)); |
| 38 | + Assert.Equal(2, await db.StringGetAsync(b)); |
| 39 | + } |
| 40 | +} |
0 commit comments