Skip to content

Commit

Permalink
Fix Bugs, Caused by Hello Respones Types #811 (#818)
Browse files Browse the repository at this point in the history
* Fix Bugs, Caused by Hello Respones Types #811

* Fix: RespTests.cs update

NewlineCount 바뀌었어요
  • Loading branch information
yuseok-kim-edushare authored Nov 22, 2024
1 parent c84c8c7 commit 987777f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions libs/server/Resp/BasicCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1463,13 +1463,13 @@ void ProcessHelloCommand(byte? respProtocolVersion, ReadOnlySpan<byte> username,
this.clientName = clientName;
}

(string, string)[] helloResult =
(string, object)[] helloResult =
[
("server", "redis"),
("version", storeWrapper.redisProtocolVersion),
("garnet_version", storeWrapper.version),
("proto", $"{this.respProtocolVersion}"),
("id", "63"),
("proto", this.respProtocolVersion),
("id", 63),
("mode", storeWrapper.serverOptions.EnableCluster ? "cluster" : "standalone"),
("role", storeWrapper.serverOptions.EnableCluster && storeWrapper.clusterProvider.IsReplica() ? "replica" : "master"),
];
Expand All @@ -1488,8 +1488,16 @@ void ProcessHelloCommand(byte? respProtocolVersion, ReadOnlySpan<byte> username,
{
while (!RespWriteUtils.WriteAsciiBulkString(helloResult[i].Item1, ref dcurr, dend))
SendAndReset();
while (!RespWriteUtils.WriteAsciiBulkString(helloResult[i].Item2, ref dcurr, dend))
SendAndReset();
if (helloResult[i].Item2 is int intValue)
{
while (!RespWriteUtils.WriteInteger(intValue, ref dcurr, dend))
SendAndReset();
}
else
{
while (!RespWriteUtils.WriteAsciiBulkString(helloResult[i].Item2.ToString(), ref dcurr, dend))
SendAndReset();
}
}
while (!RespWriteUtils.WriteAsciiBulkString("modules", ref dcurr, dend))
SendAndReset();
Expand Down
2 changes: 1 addition & 1 deletion test/Garnet.test/RespTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3420,7 +3420,7 @@ public void AsyncTest1()
// We use newline counting for HELLO response as the exact length can vary slightly across versions
using var lightClientRequest = TestUtils.CreateRequest(countResponseType: CountResponseType.Newlines);

var expectedNewlineCount = 32; // 32 '\n' characters expected in response
var expectedNewlineCount = 30; // 30 '\n' characters expected in response
var response = lightClientRequest.Execute($"hello 3", expectedNewlineCount);
ClassicAssert.IsTrue(response.Length is > 180 and < 190);

Expand Down

0 comments on commit 987777f

Please sign in to comment.