2023-09-11 11:59:33 +02:00
|
|
|
|
//using DistTestCore.Codex;
|
|
|
|
|
|
//using Logging;
|
|
|
|
|
|
//using static DistTestCore.Helpers.FullConnectivityHelper;
|
2023-05-10 09:55:36 +02:00
|
|
|
|
|
2023-09-11 11:59:33 +02:00
|
|
|
|
//namespace DistTestCore.Helpers
|
|
|
|
|
|
//{
|
|
|
|
|
|
// public class PeerConnectionTestHelpers : IFullConnectivityImplementation
|
|
|
|
|
|
// {
|
|
|
|
|
|
// private readonly FullConnectivityHelper helper;
|
2023-05-18 10:42:04 +02:00
|
|
|
|
|
2023-09-11 11:59:33 +02:00
|
|
|
|
// public PeerConnectionTestHelpers(BaseLog log)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// helper = new FullConnectivityHelper(log, this);
|
|
|
|
|
|
// }
|
2023-05-10 09:55:36 +02:00
|
|
|
|
|
2023-09-11 11:59:33 +02:00
|
|
|
|
// public void AssertFullyConnected(IEnumerable<IOnlineCodexNode> nodes)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// AssertFullyConnected(nodes.Select(n => ((OnlineCodexNode)n).CodexAccess));
|
|
|
|
|
|
// }
|
2023-08-24 11:32:32 +02:00
|
|
|
|
|
2023-09-11 11:59:33 +02:00
|
|
|
|
// public void AssertFullyConnected(IEnumerable<CodexAccess> nodes)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// helper.AssertFullyConnected(nodes);
|
|
|
|
|
|
// }
|
2023-05-10 09:55:36 +02:00
|
|
|
|
|
2023-09-11 11:59:33 +02:00
|
|
|
|
// public string Description()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// return "Peer Discovery";
|
|
|
|
|
|
// }
|
2023-05-10 09:55:36 +02:00
|
|
|
|
|
2023-09-11 11:59:33 +02:00
|
|
|
|
// public string ValidateEntry(Entry entry, Entry[] allEntries)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var result = string.Empty;
|
|
|
|
|
|
// foreach (var peer in entry.Response.table.nodes)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var expected = GetExpectedDiscoveryEndpoint(allEntries, peer);
|
|
|
|
|
|
// if (expected != peer.address)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// result += $"Node:{entry.Node.GetName()} has incorrect peer table entry. Was: '{peer.address}', expected: '{expected}'. ";
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return result;
|
|
|
|
|
|
// }
|
2023-05-12 09:11:05 +02:00
|
|
|
|
|
2023-09-11 11:59:33 +02:00
|
|
|
|
// public PeerConnectionState Check(Entry from, Entry to)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var peerId = to.Response.id;
|
2023-05-29 09:13:38 +02:00
|
|
|
|
|
2023-09-11 11:59:33 +02:00
|
|
|
|
// var response = from.Node.GetDebugPeer(peerId);
|
|
|
|
|
|
// if (!response.IsPeerFound)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// return PeerConnectionState.NoConnection;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (!string.IsNullOrEmpty(response.peerId) && response.addresses.Any())
|
|
|
|
|
|
// {
|
|
|
|
|
|
// return PeerConnectionState.Connection;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return PeerConnectionState.Unknown;
|
|
|
|
|
|
// }
|
2023-05-11 12:44:53 +02:00
|
|
|
|
|
2023-09-11 11:59:33 +02:00
|
|
|
|
// private static string GetExpectedDiscoveryEndpoint(Entry[] allEntries, CodexDebugTableNodeResponse node)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var peer = allEntries.SingleOrDefault(e => e.Response.table.localNode.peerId == node.peerId);
|
|
|
|
|
|
// if (peer == null) return $"peerId: {node.peerId} is not known.";
|
2023-05-29 08:35:46 +02:00
|
|
|
|
|
2023-09-11 11:59:33 +02:00
|
|
|
|
// var ip = peer.Node.Container.Pod.PodInfo.Ip;
|
|
|
|
|
|
// var discPort = peer.Node.Container.Recipe.GetPortByTag(CodexContainerRecipe.DiscoveryPortTag);
|
|
|
|
|
|
// return $"{ip}:{discPort.Number}";
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|