mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-05-07 18:09:36 +00:00
* ci(docker): build dist-tests images * Update to .net 10, kubernetes client 18.0.13 Kubernetes client 18.0.13 is compatible with Kubernetes 1.34.x. The Kubernetes version is selected automatically by kubeadm in docker desktop (v1.34.1). See https://github.com/kubernetes-client/csharp#version-compatibility for a compatibility table. * Updates to support Kubernetes upgrade * bump openapi.yaml to match openapi.yaml in the logos-storage-nim docker image * bump doc to .net 10 * bump docker to .net 10 * Build image with latest tag always Always build an image with a latest tag (as well as a sha commit hash) when there's a push to master * docker image tag as "latest" only when pushing to master * Update docker image to install doctl * Remove doctl install kubeconfig is now created and uses a plain bearer token instead of using doctl as a credential mgr * Rename and remove all instances of Codex * Further remove CodexNetDeployer as it is no longer needed --------- Co-authored-by: Adam Uhlíř <adam@uhlir.dev>
92 lines
3.5 KiB
C#
92 lines
3.5 KiB
C#
using DistTestCore.Logs;
|
|
using Logging;
|
|
using TaskFactory = Utils.TaskFactory;
|
|
|
|
namespace ContinuousTests
|
|
{
|
|
public class TestLoop
|
|
{
|
|
private readonly EntryPointFactory entryPointFactory;
|
|
private readonly TaskFactory taskFactory;
|
|
private readonly Configuration config;
|
|
private readonly ILog overviewLog;
|
|
private readonly StatusLog statusLog;
|
|
private readonly Type testType;
|
|
private readonly TimeSpan runsEvery;
|
|
private readonly StartupChecker startupChecker;
|
|
private readonly CancellationToken cancelToken;
|
|
private readonly EventWaitHandle runFinishedHandle = new EventWaitHandle(true, EventResetMode.ManualReset);
|
|
private static object testLock = new object();
|
|
|
|
public TestLoop(EntryPointFactory entryPointFactory, TaskFactory taskFactory, Configuration config, ILog overviewLog, StatusLog statusLog, Type testType, TimeSpan runsEvery, StartupChecker startupChecker, CancellationToken cancelToken)
|
|
{
|
|
this.entryPointFactory = entryPointFactory;
|
|
this.taskFactory = taskFactory;
|
|
this.config = config;
|
|
this.overviewLog = overviewLog;
|
|
this.statusLog = statusLog;
|
|
this.testType = testType;
|
|
this.runsEvery = runsEvery;
|
|
this.startupChecker = startupChecker;
|
|
this.cancelToken = cancelToken;
|
|
Name = testType.Name;
|
|
}
|
|
|
|
public string Name { get; }
|
|
public int NumberOfPasses { get; private set; }
|
|
public int NumberOfFailures { get; private set; }
|
|
|
|
public void Begin()
|
|
{
|
|
taskFactory.Run(() =>
|
|
{
|
|
try
|
|
{
|
|
NumberOfPasses = 0;
|
|
NumberOfFailures = 0;
|
|
while (!cancelToken.IsCancellationRequested)
|
|
{
|
|
lock (testLock)
|
|
// In the original design, multiple tests are allowed to interleave their test-moments, increasing test through-put.
|
|
// Since we're still stabilizing some of the basics, this lock limits us to 1 test run at a time.
|
|
{
|
|
WaitHandle.WaitAny(new[] { runFinishedHandle, cancelToken.WaitHandle });
|
|
|
|
cancelToken.ThrowIfCancellationRequested();
|
|
|
|
StartTest();
|
|
|
|
cancelToken.WaitHandle.WaitOne(runsEvery);
|
|
}
|
|
Thread.Sleep(100);
|
|
}
|
|
}
|
|
catch (OperationCanceledException)
|
|
{
|
|
overviewLog.Log("Test-loop " + testType.Name + " is cancelled.");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
overviewLog.Error("Test infra failure: TestLoop failed with " + ex);
|
|
Environment.Exit(-1);
|
|
}
|
|
}, nameof(TestLoop));
|
|
}
|
|
|
|
private void StartTest()
|
|
{
|
|
var test = (ContinuousTest)Activator.CreateInstance(testType)!;
|
|
var handle = new TestHandle(test);
|
|
var run = new SingleTestRun(entryPointFactory, taskFactory, config, overviewLog, statusLog, handle,
|
|
startupChecker, cancelToken, config.LogosStorageDeployment.Id);
|
|
|
|
runFinishedHandle.Reset();
|
|
run.Run(runFinishedHandle, result =>
|
|
{
|
|
if (result) NumberOfPasses++;
|
|
else NumberOfFailures++;
|
|
});
|
|
}
|
|
}
|
|
}
|