fix(nodes): locate agents behind a proxy and retry missing countries [CI]
This commit is contained in:
1 parent
1145a53004
commit
0d532caf08
13 files changed
+93
-15
No files matched your search
@@ -48,4 +48,12 @@ public sealed class ClientAddressTests
|
||||
[Fact]
|
||||
public void AMalformedTrustedProxyEntry_FailsAtStartup() =>
|
||||
Assert.Throws<InvalidOperationException>(() => new ClientAddressResolver(new BackendOptions { TrustedProxies = "banana" }));
|
||||
|
||||
[Fact]
|
||||
public void TheFleetLinkAsksTheSameResolver_SoANodeBehindAProxyKeepsItsRealAddress()
|
||||
{
|
||||
Fleet.Server.IClientAddressSource source = new ClientAddressResolver(new BackendOptions { TrustedProxies = "127.0.0.1" });
|
||||
Assert.Equal("198.51.100.7", source.Resolve(IPAddress.Parse("127.0.0.1"), _ => ["198.51.100.7"]));
|
||||
Assert.Equal("203.0.113.9", source.Resolve(IPAddress.Parse("203.0.113.9"), _ => ["198.51.100.7"]));
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,24 @@ public sealed partial class NodeInfoTests
|
||||
Assert.Null(Assert.Single(await service.ListAsync(CancellationToken.None)).Country);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Service_AnUnlocatedNode_IsRetriedFromTheHeartbeat_UntilItHasACountry()
|
||||
{
|
||||
var time = new FakeTimeProvider(DateTimeOffset.Parse("2026-10-06T00:00:00Z"));
|
||||
var service = new NodeInfoService(new MemoryStore(), new FakeGeo(null), time);
|
||||
|
||||
Assert.True(service.ShouldRetryGeo("agt_1"));
|
||||
await service.ObserveAddressAsync("agt_1", NodeKinds.Agent, "", CancellationToken.None);
|
||||
Assert.False(service.ShouldRetryGeo("agt_1"));
|
||||
time.Advance(TimeSpan.FromMinutes(11));
|
||||
Assert.True(service.ShouldRetryGeo("agt_1"));
|
||||
|
||||
var found = new NodeInfoService(new MemoryStore(), new FakeGeo(new GeoInfo("jp", 1, "Example", false)), time);
|
||||
await found.ObserveAddressAsync("agt_2", NodeKinds.Agent, "8.8.8.8", CancellationToken.None);
|
||||
time.Advance(TimeSpan.FromMinutes(11));
|
||||
Assert.False(found.ShouldRetryGeo("agt_2"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Service_PlatformIsSavedAndSurvivesARestart()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user