Merge branch 'regress/peer-discovery'

This commit is contained in:
benbierens 2023-07-17 08:56:29 +02:00
commit 3257e42a02
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
10 changed files with 52 additions and 26 deletions

View File

@ -6,7 +6,7 @@ namespace DistTestCore
{
public override IOnlineCodexNode SetupCodexBootstrapNode(Action<ICodexSetup> setup)
{
throw new Exception("AutoBootstrapDistTest creates and attaches a single boostrap node for you. " +
throw new Exception("AutoBootstrapDistTest creates and attaches a single bootstrap node for you. " +
"If you want to control the bootstrap node from your test, please use DistTest instead.");
}
@ -21,7 +21,8 @@ namespace DistTestCore
[SetUp]
public void SetUpBootstrapNode()
{
BootstrapNode = BringOnline(CreateCodexSetup(1))[0];
var setup = CreateCodexSetup(1).WithName("BOOTSTRAP");
BootstrapNode = BringOnline(setup)[0];
}
protected IOnlineCodexNode BootstrapNode { get; private set; } = null!;

View File

@ -22,12 +22,12 @@ namespace DistTestCore.Codex
public CodexDebugResponse GetDebugInfo()
{
return Http(TimeSpan.FromSeconds(2)).HttpGetJson<CodexDebugResponse>("debug/info");
return Http(TimeSpan.FromSeconds(60)).HttpGetJson<CodexDebugResponse>("debug/info");
}
public CodexDebugPeerResponse GetDebugPeer(string peerId)
{
return GetDebugPeer(peerId, TimeSpan.FromSeconds(2));
return GetDebugPeer(peerId, TimeSpan.FromSeconds(10));
}
public CodexDebugPeerResponse GetDebugPeer(string peerId, TimeSpan timeout)

View File

@ -1,6 +1,5 @@
using DistTestCore.Marketplace;
using KubernetesWorkflow;
using System.Net.Sockets;
namespace DistTestCore.Codex
{
@ -9,8 +8,8 @@ namespace DistTestCore.Codex
#if Arm64
public const string DockerImage = "codexstorage/nim-codex:sha-6dd7e55";
#else
//public const string DockerImage = "thatbenbierens/nim-codex:dhting";
public const string DockerImage = "codexstorage/nim-codex:sha-6dd7e55";
public const string DockerImage = "thatbenbierens/nim-codex:loopingyeah";
//public const string DockerImage = "codexstorage/nim-codex:sha-6dd7e55";
#endif
public const string MetricsPortTag = "metrics_port";
public const string DiscoveryPortTag = "discovery-port";
@ -19,7 +18,16 @@ namespace DistTestCore.Codex
public static readonly TimeSpan MaxUploadTimePerMegabyte = TimeSpan.FromSeconds(2.0);
public static readonly TimeSpan MaxDownloadTimePerMegabyte = TimeSpan.FromSeconds(2.0);
protected override string Image => DockerImage;
public static string DockerImageOverride = string.Empty;
protected override string Image
{
get
{
if (!string.IsNullOrEmpty(DockerImageOverride)) return DockerImageOverride;
return DockerImage;
}
}
protected override void Initialize(StartupConfig startupConfig)
{
@ -48,7 +56,7 @@ namespace DistTestCore.Codex
}
if (config.BlockTTL != null)
{
AddEnvVar("BLOCK_TTL", config.BlockTTL.ToString()!);
AddEnvVar("CODEX_BLOCK_TTL", config.BlockTTL.ToString()!);
}
if (config.MetricsEnabled)
{

View File

@ -30,7 +30,7 @@ namespace DistTestCore
var group = CreateCodexGroup(codexSetup, containers, codexNodeFactory);
var podInfo = group.Containers.RunningPod.PodInfo;
LogEnd($"Started {codexSetup.NumberOfNodes} nodes at location '{podInfo.K8SNodeName}'={podInfo.Ip}. They are: {group.Describe()}");
LogEnd($"Started {codexSetup.NumberOfNodes} nodes of image '{containers.Containers.First().Recipe.Image}' at location '{podInfo.K8SNodeName}'={podInfo.Ip}. They are: {group.Describe()}");
LogSeparator();
return group;
}

View File

@ -17,7 +17,7 @@ namespace DistTestCore
{
kubeConfigFile = GetNullableEnvVarOrDefault("KUBECONFIG", null);
logPath = GetEnvVarOrDefault("LOGPATH", "CodexTestLogs");
logDebug = GetEnvVarOrDefault("LOGDEBUG", "true").ToLowerInvariant() == "true";
logDebug = GetEnvVarOrDefault("LOGDEBUG", "false").ToLowerInvariant() == "true";
dataFilesPath = GetEnvVarOrDefault("DATAFILEPATH", "TestDataFiles");
codexLogLevel = ParseEnum.Parse<CodexLogLevel>(GetEnvVarOrDefault("LOGLEVEL", nameof(CodexLogLevel.Trace)));
runnerLocation = ParseEnum.Parse<TestRunnerLocation>(GetEnvVarOrDefault("RUNNERLOCATION", nameof(TestRunnerLocation.ExternalToCluster)));

View File

@ -52,12 +52,12 @@ namespace DistTestCore.Helpers
private static void RetryWhilePairs(List<Pair> pairs, Action action)
{
var timeout = DateTime.UtcNow + TimeSpan.FromMinutes(10);
var timeout = DateTime.UtcNow + TimeSpan.FromSeconds(30);
while (pairs.Any() && timeout > DateTime.UtcNow)
{
action();
if (pairs.Any()) Time.Sleep(TimeSpan.FromSeconds(5));
if (pairs.Any()) Time.Sleep(TimeSpan.FromSeconds(2));
}
}
@ -140,6 +140,12 @@ namespace DistTestCore.Helpers
}
}
public override string ToString()
{
if (Response == null || string.IsNullOrEmpty(Response.id)) return "UNKNOWN";
return Response.id;
}
private static string GetExpectedDiscoveryEndpoint(Entry[] allEntries, CodexDebugTableNodeResponse node)
{
var peer = allEntries.SingleOrDefault(e => e.Response.table.localNode.peerId == node.peerId);
@ -188,10 +194,15 @@ namespace DistTestCore.Helpers
return GetResultMessage() + GetTimePostfix();
}
public override string ToString()
{
return $"[{GetMessage()}]";
}
private string GetResultMessage()
{
var aName = A.Response.id;
var bName = B.Response.id;
var aName = A.ToString();
var bName = B.ToString();
if (Success)
{
@ -203,8 +214,8 @@ namespace DistTestCore.Helpers
private string GetTimePostfix()
{
var aName = A.Response.id;
var bName = B.Response.id;
var aName = A.ToString();
var bName = B.ToString();
return $" ({aName}->{bName}: {aToBTime.TotalMinutes} seconds, {bName}->{aName}: {bToATime.TotalSeconds} seconds)";
}

View File

@ -127,16 +127,18 @@ namespace DistTestCore
private T Retry<T>(Func<T> operation, string description)
{
return Time.Retry(operation, timeSet.HttpCallRetryTimeout(), timeSet.HttpCallRetryDelay(), description);
return Time.Retry(operation, GetTimeout(), timeSet.HttpCallRetryDelay(), description);
}
private HttpClient GetClient()
{
if (timeoutOverride.HasValue)
{
return GetClient(timeoutOverride.Value);
}
return GetClient(timeSet.HttpCallTimeout());
return GetClient(GetTimeout());
}
private TimeSpan GetTimeout()
{
if (timeoutOverride.HasValue) return timeoutOverride.Value;
return timeSet.HttpCallTimeout();
}
private HttpClient GetClient(TimeSpan timeout)

View File

@ -41,7 +41,7 @@ namespace DistTestCore
public TimeSpan K8sOperationTimeout()
{
return TimeSpan.FromMinutes(5);
return TimeSpan.FromMinutes(1);
}
public TimeSpan WaitForMetricTimeout()

View File

@ -43,7 +43,7 @@ namespace Logging
if (!string.IsNullOrEmpty(name)) return name;
var test = TestContext.CurrentContext.Test;
var args = FormatArguments(test);
return $"{test.MethodName}{args}";
return ReplaceInvalidCharacters($"{test.MethodName}{args}");
}
private static string FormatArguments(TestContext.TestAdapter test)
@ -51,5 +51,10 @@ namespace Logging
if (test.Arguments == null || !test.Arguments.Any()) return "";
return $"[{string.Join(',', test.Arguments)}]";
}
private static string ReplaceInvalidCharacters(string name)
{
return name.Replace(":", "_");
}
}
}

View File

@ -1,7 +1,6 @@
using DistTestCore;
using DistTestCore.Helpers;
using NUnit.Framework;
using Utils;
namespace Tests.PeerDiscoveryTests
{