Skip to content

Commit 14fb5f9

Browse files
authoredApr 14, 2025··
Fix Announce Regression (#1171)
* explicit port declarationg at get endpoint when any is used * add unit test for IPAddres.Any cluster announce * change version
1 parent fa9ca3d commit 14fb5f9

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed
 

‎Version.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<!-- VersionPrefix property for builds and packages -->
33
<PropertyGroup>
4-
<VersionPrefix>1.0.62</VersionPrefix>
4+
<VersionPrefix>1.0.63</VersionPrefix>
55
</PropertyGroup>
66
</Project>

‎libs/server/StoreWrapper.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public IPEndPoint GetClusterEndpoint()
294294
{
295295
socket.Connect("8.8.8.8", 65530);
296296
var endPoint = socket.LocalEndPoint as IPEndPoint;
297-
return endPoint;
297+
return new IPEndPoint(endPoint.Address, localEndPoint.Port);
298298
}
299299
}
300300
else if (localEndPoint.Address.Equals(IPAddress.IPv6Any))
@@ -303,7 +303,7 @@ public IPEndPoint GetClusterEndpoint()
303303
{
304304
socket.Connect("2001:4860:4860::8888", 65530);
305305
var endPoint = socket.LocalEndPoint as IPEndPoint;
306-
return endPoint;
306+
return new IPEndPoint(endPoint.Address, localEndPoint.Port);
307307
}
308308
}
309309
return localEndPoint;

‎test/Garnet.test.cluster/ClusterConfigTests.cs

+25
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,30 @@ public void ClusterAnnounceRecoverTest()
135135
ClassicAssert.AreEqual(clusterAnnounceEndpoint.Address.ToString(), clusterNodesEndpoint.Address.ToString());
136136
ClassicAssert.AreEqual(clusterAnnounceEndpoint.Port, clusterNodesEndpoint.Port);
137137
}
138+
139+
[Test, Order(3)]
140+
[Category("CLUSTER-CONFIG"), CancelAfter(1000)]
141+
public void ClusterAnyIPAnnounce()
142+
{
143+
context.nodes = new GarnetServer[1];
144+
context.nodes[0] = context.CreateInstance(new IPEndPoint(IPAddress.Any, 7000));
145+
context.nodes[0].Start();
146+
147+
context.endpoints = TestUtils.GetShardEndPoints(1, IPAddress.Loopback, 7000);
148+
context.CreateConnection();
149+
150+
var config = context.clusterTestUtils.ClusterNodes(0, logger: context.logger);
151+
var origin = config.Origin;
152+
153+
var endpoint = origin.ToIPEndPoint();
154+
ClassicAssert.AreEqual(7000, endpoint.Port);
155+
156+
using var client = TestUtils.GetGarnetClient(config.Origin);
157+
client.Connect();
158+
var resp = client.PingAsync().GetAwaiter().GetResult();
159+
ClassicAssert.AreEqual("PONG", resp);
160+
resp = client.QuitAsync().GetAwaiter().GetResult();
161+
ClassicAssert.AreEqual("OK", resp);
162+
}
138163
}
139164
}

0 commit comments

Comments
 (0)
Please sign in to comment.